├── .gitignore ├── images └── idr_transparent.png ├── idrws-page-handler.php ├── idrws-style.css ├── idrws-admin-page.js ├── idrws-convert.php ├── idrws-webservice.php └── idrws-menu-page.php /.gitignore: -------------------------------------------------------------------------------- 1 | ^output$ -------------------------------------------------------------------------------- /images/idr_transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alienwithin/WordPress_PDFtoHTML5/master/images/idr_transparent.png -------------------------------------------------------------------------------- /idrws-page-handler.php: -------------------------------------------------------------------------------- 1 | '-1'), $atts); 12 | // No ID value 13 | if(strcmp($a['id'], '-1') == 0){ 14 | return ""; 15 | } 16 | $pdf=$a['id']; 17 | $url=IDRWS_PLUGIN_URL."output/".$pdf."/".$pdf."/index.html"; 18 | $iframe = ""; 19 | 20 | 21 | 22 | return $iframe; 23 | } 24 | ?> -------------------------------------------------------------------------------- /idrws-style.css: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Simon Lissack 3 | Company: IDR Solutions 4 | Version: 1.0 5 | */ 6 | 7 | #idrws-left{ 8 | float:left; 9 | width:44%; 10 | height:100%; 11 | border-radius: 4px; 12 | } 13 | 14 | #idrws-right{ 15 | float:right; 16 | width:55%; 17 | height:100%; 18 | } 19 | 20 | #idrws-files-container{ 21 | height:25%; 22 | } 23 | 24 | #idrws-options-menu{ 25 | width:100%; 26 | } 27 | 28 | #idrws-account-container{ 29 | width:100%; 30 | } 31 | 32 | .idrws-option-header{ 33 | background: rgb(238,238,238); 34 | background: -moz-linear-gradient(top, rgba(238,238,238,1) 0%, rgba(204,204,204,1) 100%); 35 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(238,238,238,1)), color-stop(100%,rgba(204,204,204,1))); 36 | background: -webkit-linear-gradient(top, rgba(238,238,238,1) 0%,rgba(204,204,204,1) 100%); 37 | background: -o-linear-gradient(top, rgba(238,238,238,1) 0%,rgba(204,204,204,1) 100%); 38 | background: -ms-linear-gradient(top, rgba(238,238,238,1) 0%,rgba(204,204,204,1) 100%); 39 | background: linear-gradient(to bottom, rgba(238,238,238,1) 0%,rgba(204,204,204,1) 100%); 40 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#cccccc',GradientType=0 ); 41 | 42 | border-radius: 4px; 43 | border:1px solid #aaaaaa; 44 | padding:4px !important; 45 | 46 | } 47 | 48 | #idrws-conversion{ 49 | height:60%; 50 | } 51 | 52 | #idrws-upload{ 53 | display:inline-block; 54 | width:49%; 55 | } 56 | 57 | #idrws_available_pdfs { 58 | width:49%; 59 | height:100%; 60 | display:inline-block; 61 | } 62 | #idrws_selected_pdf{ 63 | visibility:hidden; 64 | width:10px; 65 | } 66 | .idrws-banner-inactive { 67 | visibility: hidden; 68 | } 69 | 70 | #idrws-preview { 71 | width:100%; 72 | height:65.7%; 73 | } 74 | 75 | #idrws_selected_shortcode{ 76 | height:20px; 77 | text-align: center; 78 | } 79 | 80 | .idrws_pdf_short { 81 | width:100%; 82 | height:800px; 83 | margin: 0 auto; 84 | } 85 | 86 | #idrws-file-list{ 87 | vertical-align:top; 88 | display: inline-block; 89 | width:100%; 90 | height:100%; 91 | } 92 | 93 | #idrws-preview-window{ 94 | vertical-align:top; 95 | width:100%; 96 | height:100%; 97 | } 98 | 99 | -------------------------------------------------------------------------------- /idrws-admin-page.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Simon Lissack 3 | Company: IDR Solutions 4 | Version: 1.0 5 | */ 6 | 7 | // jQuery on WP uses compatability mode, meaning $ is unset, alias jQuery function back to j (avoiding $ in case of conflicts) 8 | function j(val){ 9 | return jQuery(val); 10 | } 11 | 12 | j(document).ready(function(){ 13 | j("#idrws_available_pdfs").click(function(){ 14 | j("#idrws_selected_pdf_name").val(j("#idrws_available_pdfs").find(":selected").text()); 15 | console.log("set"); 16 | idrws_set_preview(); 17 | }); 18 | j('#idrws-istrial').bind('change', function(){ 19 | val = this.checked; 20 | idrws_toggle_login(val); 21 | }); 22 | idrws_toggle_login(j('#idrws-istrial').val()); 23 | 24 | }); 25 | 26 | function idrws_set_preview(){ 27 | var pdfName=j("#idrws_available_pdfs").find(":selected").text(); 28 | var output=outputLoc+"/"+pdfName+"/"+pdfName+"/index.html"; 29 | var pdfID=j("#idrws_available_pdfs").val(); 30 | 31 | j("#idrws_selected_pdf").val(pdfID); 32 | idrws_iframe_load(); 33 | 34 | } 35 | 36 | function idrws_iframe_load(){ 37 | var pdfName=j("#idrws_available_pdfs").find(":selected").text(); 38 | console.log(pdfName); 39 | if(pdfName === "" || pdfName === undefined){ 40 | return; 41 | } 42 | 43 | try { 44 | var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); 45 | var url = outputLoc+pdfName+"/"+pdfName+"/index.html"; 46 | xmlhttp.onreadystatechange=function(){ 47 | if (xmlhttp.readyState==4) { 48 | if(xmlhttp.status==200){ 49 | idrws_show_iframe(pdfName); 50 | }else if (xmlhttp.status==404){ 51 | idrws_show_convert(pdfName); 52 | } 53 | xmlhttp.onreadystatechange=null; 54 | } 55 | }; 56 | 57 | xmlhttp.open("GET",url,false); 58 | xmlhttp.send(); 59 | } catch (e) { 60 | console.log(e); 61 | idrws_show_convert(pdfName); 62 | } 63 | } 64 | 65 | function idrws_show_iframe(pdfName){ 66 | j('#idrws-preview').show(); 67 | j("#idrws-preview").attr('src', outputLoc+"/"+pdfName+"/"+pdfName+"/index.html"); 68 | j('#idrws_selected_shortcode').show(); 69 | j('#idrws_selected_shortcode').html("[pdf id='"+pdfName+"']"); 70 | } 71 | 72 | function idrws_show_convert(pdfName){ 73 | j('#idrws-preview').hide(); 74 | j('#idrws_selected_shortcode').hide(); 75 | } 76 | 77 | function idrws_toggle_login(isTrial){ 78 | j('#username').attr('readonly', isTrial); 79 | j('#password').attr('readonly', isTrial); 80 | 81 | } -------------------------------------------------------------------------------- /idrws-convert.php: -------------------------------------------------------------------------------- 1 | $details['email'], 24 | "password" =>$details['password'], 25 | "fileName"=>$filename, 26 | "dataByteArray"=>$file, 27 | "conversionType"=>"html5", 28 | "conversionParams"=>$style_params, 29 | "xmlParamsByteArray"=>null, 30 | "isDebugMode"=>false); 31 | 32 | try{ 33 | $output = (array)($client->convert($conversion_params)); 34 | } catch (Exception $e){ 35 | echo $e->getMessage() . "
"; 36 | return; 37 | } 38 | 39 | idrws_extract_files($outputdir, $filename, $output); 40 | } 41 | 42 | function idrws_fetch_user_details(){ 43 | // if(isset($_POST["idrws-email"]) && $_POST["idrws-password"]){ 44 | // $username=filter_var($_POST["idrws-email"], FILTER_SANITIZE_EMAIL); 45 | // $password=$_POST["idrws-password"]; 46 | // }else{ 47 | $username="wordpress"; 48 | $password="wordpress"; 49 | // } 50 | 51 | return array("email"=>$username,"password"=>$password); 52 | } 53 | 54 | function idrws_setup_params(){ 55 | $params = array(); 56 | 57 | $params[0] = "org.jpedal.pdf2html.viewMode"; 58 | $params[1] = $_POST["viewMode"]; 59 | 60 | return $params; 61 | 62 | } 63 | 64 | function idrws_extract_files($outputdir, $filename, $output){ 65 | WP_Filesystem(); 66 | 67 | if(is_dir($outputdir.$filename)){ 68 | idrws_recursive_delete($outputdir.$filename); 69 | } 70 | 71 | file_put_contents($outputdir.$filename.".zip", $output); 72 | $result=unzip_file($outputdir.$filename.".zip", $outputdir); 73 | } 74 | 75 | function idrws_recursive_delete($root_dir){ 76 | $root_dir.=DIRECTORY_SEPARATOR; 77 | $dir = scandir($root_dir); 78 | foreach ($dir as $entry) { 79 | // Ignore current and parent dirs 80 | if ($entry != "." && $entry != "..") { 81 | $entry = $root_dir.$entry; 82 | if(is_dir($entry)){ 83 | idrws_recursive_delete($entry); 84 | rmdir($root_dir); 85 | }else if (is_file($entry)){ 86 | unlink($entry); 87 | } 88 | } 89 | } 90 | } 91 | 92 | ?> -------------------------------------------------------------------------------- /idrws-webservice.php: -------------------------------------------------------------------------------- 1 | 'application/pdf' 56 | ,'post_type'=>'attachment' 57 | ); 58 | 59 | $posts_array = get_posts($args); 60 | return $posts_array; 61 | } 62 | 63 | function idrws_get_pdf_file($id){ 64 | $posts_array = get_post($id); 65 | return $posts_array; 66 | } 67 | 68 | function idrws_handle_post_data(){ 69 | // Check a pdf was passed via post, otherwise checks for file upload 70 | if(isset($_POST['idrws_selected_pdf'])){ 71 | $idrws_is_converting=true; 72 | $filename = idrws_start_conversion(); 73 | }else if(isset($_FILES['idrws_upload_pdf'])){ 74 | $id = idrws_handle_upload(); 75 | $filename = idrws_get_pdf_file($id)->post_title; 76 | } 77 | return $filename; 78 | } 79 | 80 | function idrws_start_conversion(){ 81 | $file_id = $_POST["idrws_selected_pdf"]; 82 | $filename = idrws_get_pdf_file($file_id)->post_title; 83 | 84 | idrws_convert_file($file_id, $filename, $is_content); 85 | 86 | return $filename; 87 | } 88 | 89 | function idrws_handle_upload(){ 90 | $pdf = $_FILES['idrws_upload_pdf']; 91 | echo "uploading " . $pdf; 92 | $uploaded=media_handle_upload('idrws_upload_pdf', 0); 93 | if(is_wp_error($uploaded)){ 94 | echo $uploaded->get_error_message(); 95 | } 96 | } 97 | 98 | /* 99 | * Write out variables used by javascript 100 | */ 101 | function idrws_write_vars(){ 102 | ?> 103 | 107 | -------------------------------------------------------------------------------- /idrws-menu-page.php: -------------------------------------------------------------------------------- 1 | 9 |
10 |
11 |

PDF to HTML5

12 |

Powered by JPDF2HTML5

13 |
14 |
15 | 16 |

Step 1: Upload a File

17 |
18 | 19 |
20 |

Upload a new File

21 |
22 | 23 | 24 |
25 |
26 | 27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | 35 |

Step 2: Convert

36 | 37 |
38 |
39 |

View Mode

40 |
41 |
42 |
43 |
44 | 45 |
46 |
47 | 48 |
49 |
50 |

Account details

51 |

Trial account available only

52 | 53 | 54 | 55 | 60 |
61 |
62 |
63 |
64 |
65 |
66 |

Step 3: Preview

67 |
68 | 69 |
70 |
71 |

About PDF to HTML5

72 |
73 | 74 |
Created by IDR Solutions
75 | Click here to see our other products 76 |
77 |
78 |
79 |
80 |
81 | 82 | "; 89 | foreach ($posts_array as $value) { 90 | echo "