wiziwig
Showing
19 changed files
with
412 additions
and
206 deletions
| ... | @@ -34,6 +34,9 @@ class PdfController extends Controller | ... | @@ -34,6 +34,9 @@ class PdfController extends Controller |
| 34 | $pdffile = $searchpath.'/'.$rows[0]->file; | 34 | $pdffile = $searchpath.'/'.$rows[0]->file; |
| 35 | //$outfile=""; | 35 | //$outfile=""; |
| 36 | $title = "Test Pages"; | 36 | $title = "Test Pages"; |
| 37 | $pageHeight = $rows[0]->pheight; | ||
| 38 | $pageWidth = $rows[0]->pwidth; | ||
| 39 | |||
| 37 | $storagePath = Storage::disk('public')->getDriver()->getAdapter()->getPathPrefix(); | 40 | $storagePath = Storage::disk('public')->getDriver()->getAdapter()->getPathPrefix(); |
| 38 | $outfile = $storagePath.$searchpath."/new_".$rows[0]->file; | 41 | $outfile = $storagePath.$searchpath."/new_".$rows[0]->file; |
| 39 | $download = 'http://localhost:8888/pdf-customizer/public/fileentry/getPDF/'.$searchpath."/new_".$rows[0]->file; | 42 | $download = 'http://localhost:8888/pdf-customizer/public/fileentry/getPDF/'.$searchpath."/new_".$rows[0]->file; |
| ... | @@ -81,8 +84,9 @@ try { | ... | @@ -81,8 +84,9 @@ try { |
| 81 | die("Error: " . $p->get_errmsg()); | 84 | die("Error: " . $p->get_errmsg()); |
| 82 | 85 | ||
| 83 | /* Dummy page size; will be adjusted later */ | 86 | /* Dummy page size; will be adjusted later */ |
| 84 | $p->begin_page_ext(10, 10, ""); | 87 | $p->begin_page_ext($pageWidth, $pageHeight , ""); |
| 85 | 88 | ||
| 89 | |||
| 86 | /* Place the imported page on the output page, and | 90 | /* Place the imported page on the output page, and |
| 87 | * adjust the page size */ | 91 | * adjust the page size */ |
| 88 | 92 | ||
| ... | @@ -93,11 +97,19 @@ try { | ... | @@ -93,11 +97,19 @@ try { |
| 93 | $pageNumber = $row->pages; | 97 | $pageNumber = $row->pages; |
| 94 | if($pageNumber == $pageno ) { | 98 | if($pageNumber == $pageno ) { |
| 95 | 99 | ||
| 96 | if ($row->change_type == 'text') { | 100 | if ($row->change_type == 'textflow') { |
| 97 | 101 | ||
| 98 | //Get font var from row | 102 | //Get font var from row |
| 99 | 103 | ||
| 100 | $textline = $row->content; | 104 | $textline = $row->content; |
| 105 | $textline = str_replace('<p>','<nextparagraph leading=100%>', $textline); | ||
| 106 | $textline = str_replace('</p>','', $textline); | ||
| 107 | $textline = str_replace('<br />','<nextline leading=80%>', $textline); | ||
| 108 | $textline = str_replace('<strong>','<fakebold=true>', $textline); | ||
| 109 | $textline = str_replace('</strong>','<fakebold=false>', $textline); | ||
| 110 | $textline = str_replace('<em>','<italicangle=-12>', $textline); | ||
| 111 | $textline = str_replace('</em>','<italicangle=0>', $textline); | ||
| 112 | $textline = str_replace('&','&', $textline); | ||
| 101 | $textLUp = $row->locationUp; | 113 | $textLUp = $row->locationUp; |
| 102 | $textwidth = $row->width; | 114 | $textwidth = $row->width; |
| 103 | $textheight = $row->height; | 115 | $textheight = $row->height; |
| ... | @@ -107,6 +119,7 @@ try { | ... | @@ -107,6 +119,7 @@ try { |
| 107 | $fontAlignment = $fontStyles["alignment"]; | 119 | $fontAlignment = $fontStyles["alignment"]; |
| 108 | $fontFamily = $fontStyles["font-family"]; | 120 | $fontFamily = $fontStyles["font-family"]; |
| 109 | $fontSize = $fontStyles["font-size"]; | 121 | $fontSize = $fontStyles["font-size"]; |
| 122 | |||
| 110 | if(isset($fontStyles["font-color"])) { | 123 | if(isset($fontStyles["font-color"])) { |
| 111 | $fontColor = $fontStyles["font-color"]; | 124 | $fontColor = $fontStyles["font-color"]; |
| 112 | }else{ | 125 | }else{ |
| ... | @@ -122,16 +135,55 @@ try { | ... | @@ -122,16 +135,55 @@ try { |
| 122 | die("Error: " . $p->get_errmsg()); | 135 | die("Error: " . $p->get_errmsg()); |
| 123 | } | 136 | } |
| 124 | $p->setfont($font, $fontSize); | 137 | $p->setfont($font, $fontSize); |
| 125 | $num_optlist = "fontname=".$fontFamily." fontsize=".$fontSize." encoding=unicode alignment=".$fontAlignment." fillcolor={".$fontColor." }"; | 138 | $num_optlist = "fontname=".$fontFamily." fontsize=".$fontSize." encoding=unicode alignment=".$fontAlignment." fillcolor={".$fontColor." } "; |
| 126 | 139 | ||
| 127 | 140 | ||
| 128 | $textline = $p->create_textflow($textline , $num_optlist); | 141 | $textline = $p->create_textflow($textline , $num_optlist); |
| 129 | $fit_optlist = "firstlinedist=capheight"; | 142 | $fit_optlist = "firstlinedist=capheight "; |
| 130 | 143 | ||
| 131 | 144 | ||
| 132 | $result = $p->fit_textflow($textline, $textLRight, $textLUp, $textwidth ,$textheight ,$fit_optlist); | 145 | $result = $p->fit_textflow($textline, $textLRight, $textLUp, ($textwidth + $textLRight) ,($textheight + $textLUp) ,$fit_optlist); |
| 133 | 146 | ||
| 134 | } else if ($row->change_type == 'img') { | 147 | } else if ($row->change_type == 'text') { |
| 148 | $yoff = 50; | ||
| 149 | //Get font var from row | ||
| 150 | |||
| 151 | $textline = $row->content; | ||
| 152 | $textLUp = $row->locationUp; | ||
| 153 | $textwidth = $row->width; | ||
| 154 | $textheight = $row->height; | ||
| 155 | $textLRight = $row->locationRight; | ||
| 156 | $fontStyles = unserialize($row->style); | ||
| 157 | $fitmethod = $fontStyles["fitmethod"]; | ||
| 158 | |||
| 159 | $fontAlignment = $fontStyles["alignment"]; | ||
| 160 | $fontFamily = $fontStyles["font-family"]; | ||
| 161 | $fontSize = $fontStyles["font-size"]; | ||
| 162 | if(isset($fontStyles["font-color"])) { | ||
| 163 | $fontColor = $fontStyles["font-color"]; | ||
| 164 | }else{ | ||
| 165 | $fontColor = 'cmyk 0.75 0.68 0.67 0.90'; | ||
| 166 | |||
| 167 | } | ||
| 168 | /// Load and insert text and font | ||
| 169 | |||
| 170 | $p->set_option("FontOutline={" . $fontFamily . "=" . $storagePath . $folder . "/" . $fontFamily . ".otf}"); | ||
| 171 | /* For PDFlib Lite: change "unicode" to "winansi" */ | ||
| 172 | $font = $p->load_font($fontFamily, "unicode", "embedding"); | ||
| 173 | if ($font == 0) { | ||
| 174 | die("Error: " . $p->get_errmsg()); | ||
| 175 | } | ||
| 176 | $p->setfont($font, $fontSize); | ||
| 177 | //$num_optlist = "fontname=".$fontFamily." fontsize=".$fontSize." encoding=unicode alignment=".$fontAlignment." fillcolor={".$fontColor." }"; | ||
| 178 | if($fitmethod == ''){$fitm =""; | ||
| 179 | }else{ $fitm = "fitmethod=".$fitmethod;} | ||
| 180 | |||
| 181 | $num_optlist = "fillcolor={".$fontColor." } position={".$fontAlignment."} boxsize={" . $textwidth." ".$textheight . "} fontsize=".$fontSize." ".$fitm. "showborder "; | ||
| 182 | |||
| 183 | $p->fit_textline($textline, $textLRight, $textLUp, $num_optlist); | ||
| 184 | } | ||
| 185 | |||
| 186 | else if ($row->change_type == 'img') { | ||
| 135 | 187 | ||
| 136 | //Get image var from row | 188 | //Get image var from row |
| 137 | 189 | ||
| ... | @@ -140,9 +192,15 @@ try { | ... | @@ -140,9 +192,15 @@ try { |
| 140 | $imgLRight = $row->locationRight; | 192 | $imgLRight = $row->locationRight; |
| 141 | $bw = $row->width; | 193 | $bw = $row->width; |
| 142 | $bh = $row->height; | 194 | $bh = $row->height; |
| 195 | $ImageStyles = unserialize($row->style); | ||
| 196 | //var_dump($ImageStyles); | ||
| 197 | $ImagePosition = $ImageStyles["position"]; | ||
| 198 | $ImageFitmethod = $ImageStyles["fitmethod"]; | ||
| 199 | $ImageScale = $ImageStyles["scale"]; | ||
| 200 | $ImagesOrientate = $ImageStyles["orientate"]; | ||
| 143 | 201 | ||
| 144 | //Load and insert the images | 202 | //Load and insert the images |
| 145 | $buf = "boxsize={" . $bw . " " . $bh . "} position={center} fitmethod=meet"; | 203 | $buf = "boxsize={" . $bw . " " . $bh . "} position={".$ImagePosition."} scale=".$ImageScale." orientate=".$ImagesOrientate." fitmethod=".$ImageFitmethod." "; |
| 146 | $image = $p->load_image("auto", $storagePath . $imagefile, ""); | 204 | $image = $p->load_image("auto", $storagePath . $imagefile, ""); |
| 147 | if ($image == 0) { | 205 | if ($image == 0) { |
| 148 | die("Error: " . $p->get_errmsg()); | 206 | die("Error: " . $p->get_errmsg()); |
| ... | @@ -150,7 +208,45 @@ try { | ... | @@ -150,7 +208,45 @@ try { |
| 150 | $p->fit_image($image, $imgLRight, $imgLUp, $buf); | 208 | $p->fit_image($image, $imgLRight, $imgLUp, $buf); |
| 151 | 209 | ||
| 152 | 210 | ||
| 153 | } | 211 | }else if ($row->change_type == 'texthidden') { |
| 212 | $yoff = 50; | ||
| 213 | //Get font var from row | ||
| 214 | |||
| 215 | $textline = $row->content; | ||
| 216 | $textLUp = $row->locationUp; | ||
| 217 | $textwidth = $row->width; | ||
| 218 | $textheight = $row->height; | ||
| 219 | $textLRight = $row->locationRight; | ||
| 220 | $fontStyles = unserialize($row->style); | ||
| 221 | |||
| 222 | $fontAlignment = $fontStyles["alignment"]; | ||
| 223 | $fontFamily = $fontStyles["font-family"]; | ||
| 224 | $fontSize = $fontStyles["font-size"]; | ||
| 225 | $fitmethod = $fontStyles["fitmethod"]; | ||
| 226 | if(isset($fontStyles["font-color"])) { | ||
| 227 | $fontColor = $fontStyles["font-color"]; | ||
| 228 | }else{ | ||
| 229 | $fontColor = 'cmyk 0.75 0.68 0.67 0.90'; | ||
| 230 | |||
| 231 | } | ||
| 232 | /// Load and insert text and font | ||
| 233 | |||
| 234 | $p->set_option("FontOutline={" . $fontFamily . "=" . $storagePath . $folder . "/" . $fontFamily . ".otf}"); | ||
| 235 | /* For PDFlib Lite: change "unicode" to "winansi" */ | ||
| 236 | $font = $p->load_font($fontFamily, "unicode", "embedding"); | ||
| 237 | if ($font == 0) { | ||
| 238 | die("Error: " . $p->get_errmsg()); | ||
| 239 | } | ||
| 240 | $p->setfont($font, $fontSize); | ||
| 241 | //$num_optlist = "fontname=".$fontFamily." fontsize=".$fontSize." encoding=unicode alignment=".$fontAlignment." fillcolor={".$fontColor." }"; | ||
| 242 | if($fitmethod == ''){$fitm =""; | ||
| 243 | }else{ $fitm = "fitmethod=".$fitmethod;} | ||
| 244 | |||
| 245 | $num_optlist = "fillcolor={".$fontColor." } position={".$fontAlignment."} fitmethod=".$fitmethod." boxsize={" . $textwidth." ".$textheight . "} fontsize=".$fontSize.""; | ||
| 246 | $p->setfont($font, $fontSize); | ||
| 247 | $p->fit_textline($textline, $textLRight, $textLUp, $num_optlist); | ||
| 248 | } | ||
| 249 | |||
| 154 | } | 250 | } |
| 155 | 251 | ||
| 156 | 252 | ... | ... |
| ... | @@ -119,7 +119,7 @@ class pdfModel extends Model | ... | @@ -119,7 +119,7 @@ class pdfModel extends Model |
| 119 | $fileName = explode('.', $fileName); | 119 | $fileName = explode('.', $fileName); |
| 120 | 120 | ||
| 121 | $pdfId = DB::table('PDF')->insertGetId( | 121 | $pdfId = DB::table('PDF')->insertGetId( |
| 122 | array('name' => $json->pdf[0]->name, 'folder' => $folder, 'file' => end($file), 'apiCallId' => $apiCallId, 'image'=> $fileName[0].'.jpg') | 122 | array('name' => $json->pdf[0]->name, 'folder' => $folder, 'file' => end($file), 'apiCallId' => $apiCallId, 'image'=> $fileName[0].'.jpg','pheight' => $json->pdf[0]->pageHeight, 'pwidth' => $json->pdf[0]->pageWidth) |
| 123 | ); | 123 | ); |
| 124 | 124 | ||
| 125 | foreach($json->changes as $change) { | 125 | foreach($json->changes as $change) { | ... | ... |
121 KB
387 KB
No preview for this file type
151 KB
124 KB
130 KB
120 KB
No preview for this file type
No preview for this file type
No preview for this file type
260 KB
296 KB
No preview for this file type
592 KB
599 KB
| 1 | 1 | var pluginUrl = "http://localhost:8888/Forms"; | |
| 2 | var pdf_customizer = "http://localhost:8888/pdf-customizer/public"; | ||
| 2 | 3 | ||
| 3 | // var pluginUrl = "http://localhost:8888/Forms"; | 4 | // var pluginUrl = "http://contact.gotenzing.com"; |
| 4 | // var pdf_customizer = "http://localhost:8888/pdf-customizer/public"; | 5 | // var pdf_customizer = "http://pdf-customizer.synapsus.co"; |
| 5 | 6 | ||
| 6 | var pluginUrl = "http://contact.gotenzing.com"; | 7 | function getAuth() { |
| 7 | var pdf_customizer = "http://pdf-customizer.synapsus.co"; | ||
| 8 | 8 | ||
| 9 | function getAuth() { | 9 | jQuery(document).ready(function($) { |
| 10 | 10 | ||
| 11 | jQuery(document).ready(function($) { | ||
| 12 | 11 | ||
| 12 | |||
| 13 | 13 | ||
| 14 | var settings = { | ||
| 15 | "async": true, | ||
| 16 | "crossDomain": true, | ||
| 17 | "url": "" + pdf_customizer + "/api/authenticate", | ||
| 18 | "method": "POST", | ||
| 14 | 19 | ||
| 20 | "processData": false, | ||
| 21 | "contentType": false, | ||
| 22 | "mimeType": "multipart/form-data", | ||
| 23 | "data": form, | ||
| 24 | "success": function(data) { | ||
| 25 | getJson(user_id); | ||
| 26 | }, | ||
| 27 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response | ||
| 28 | //alert(xhr.status); | ||
| 29 | document.getElementById('contentArea').innerHTML = xhr.responseText; | ||
| 30 | } | ||
| 15 | 31 | ||
| 16 | var settings = { | 32 | } |
| 17 | "async": true, | ||
| 18 | "crossDomain": true, | ||
| 19 | "url": "" + pdf_customizer + "/api/authenticate", | ||
| 20 | "method": "POST", | ||
| 21 | 33 | ||
| 22 | "processData": false, | 34 | $.ajax(settings).done(function(response) { |
| 23 | "contentType": false, | 35 | console.log(response); |
| 24 | "mimeType": "multipart/form-data", | 36 | token = response; |
| 25 | "data": form, | ||
| 26 | "success": function(data) { | ||
| 27 | getJson(user_id); | ||
| 28 | }, | ||
| 29 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response | ||
| 30 | //alert(xhr.status); | ||
| 31 | document.getElementById('contentArea').innerHTML = xhr.responseText; | ||
| 32 | } | ||
| 33 | 37 | ||
| 34 | } | ||
| 35 | 38 | ||
| 36 | $.ajax(settings).done(function(response) { | 39 | }); |
| 37 | console.log(response); | ||
| 38 | token = response; | ||
| 39 | 40 | ||
| 40 | 41 | ||
| 41 | }); | ||
| 42 | 42 | ||
| 43 | }); | ||
| 43 | 44 | ||
| 45 | } | ||
| 44 | 46 | ||
| 45 | }); | ||
| 46 | 47 | ||
| 47 | } | ||
| 48 | |||
| 49 | |||
| 50 | 48 | ||
| 51 | 49 | ||
| 50 | function offFocus(id) { | ||
| 51 | |||
| 52 | |||
| 53 | jQuery(document).ready(function($) { | ||
| 54 | |||
| 55 | |||
| 56 | $("#select" + id + "").removeClass("focus"); | ||
| 57 | $(".entry_block").mouseleave(function() { | ||
| 58 | $("#select" + id + "").addClass("focus"); | ||
| 59 | }); | ||
| 60 | |||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | }); | ||
| 65 | } | ||
| 66 | |||
| 67 | function ShowBox(pheight, pwidth,up, right, height, width, example) { | ||
| 68 | |||
| 69 | |||
| 70 | jQuery(document).ready(function($) { | ||
| 71 | $('#Canvas').css("background-image", "url(" + pdf_customizer + '/fileentry/getImage/' +example+")"); | ||
| 52 | 72 | ||
| 53 | function offFocus(id) { | 73 | var Qc = document.getElementById("Canvas"); |
| 74 | var Qctx = Qc.getContext("2d"); | ||
| 75 | Qctx.clearRect(0, 0, Qc.width, Qc.height); | ||
| 76 | Qctx.restore(); | ||
| 77 | |||
| 54 | 78 | ||
| 55 | |||
| 56 | jQuery(document).ready(function($) { | ||
| 57 | |||
| 58 | |||
| 59 | $("#select"+id+"").removeClass("focus"); | ||
| 60 | $(".entry_block").mouseleave(function() { | ||
| 61 | $("#select"+id+"").addClass("focus"); | ||
| 62 | }); | ||
| 63 | 79 | ||
| 80 | var down = pheight - (up + height); | ||
| 81 | var scaleH = $("Canvas").height() / pheight ; | ||
| 82 | var scaleW = $("Canvas").width() / pwidth ; | ||
| 83 | var scaleDown = down / scaleH; | ||
| 84 | var scaleRight = right/ scaleW; | ||
| 85 | var scalewidth = width / scaleW; | ||
| 86 | var scaleheight = height / scaleH; | ||
| 87 | |||
| 88 | var c = document.getElementById("Canvas"); | ||
| 89 | var ctx = c.getContext("2d"); | ||
| 90 | ctx.save(); | ||
| 91 | ctx.rect(scaleRight, scaleDown , scalewidth, scaleheight); | ||
| 92 | ctx.stroke(); | ||
| 93 | //console.log(pheight, pwidth,up, right, height, width); | ||
| 94 | // console.log(myrect ) | ||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | }); | ||
| 99 | |||
| 100 | } | ||
| 101 | |||
| 102 | |||
| 103 | function HideBox() { | ||
| 104 | |||
| 105 | |||
| 106 | jQuery(document).ready(function($) { | ||
| 107 | var cnv = document.getElementById("Canvas"); | ||
| 108 | var ctx = cnv.getContext('2d'); // gets reference to canvas context | ||
| 109 | ctx.beginPath(); // clear existing drawing paths | ||
| 110 | ctx.save(); // store the current transformation matrix | ||
| 64 | 111 | ||
| 65 | 112 | ||
| 66 | 113 | ||
| 67 | }); | 114 | //console.log(0, 0, $("Canvas").width(), $("Canvas").height()); |
| 68 | } | ||
| 69 | 115 | ||
| 116 | |||
| 70 | 117 | ||
| 71 | 118 | ||
| 119 | }); | ||
| 120 | |||
| 121 | } | ||
| 72 | 122 | ||
| 73 | function getJson(user_id) { | ||
| 74 | 123 | ||
| 75 | jQuery(document).ready(function($) { | ||
| 76 | 124 | ||
| 77 | $.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) { | 125 | function getJson(user_id) { |
| 78 | // Get the element with id summary and set the inner text to the result. | ||
| 79 | var json = JSON.stringify(data); | ||
| 80 | pickPdfFromList(json); | ||
| 81 | 126 | ||
| 82 | }); | 127 | jQuery(document).ready(function($) { |
| 83 | 128 | ||
| 129 | $.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) { | ||
| 130 | // Get the element with id summary and set the inner text to the result. | ||
| 131 | var json = JSON.stringify(data); | ||
| 132 | pickPdfFromList(json); | ||
| 84 | 133 | ||
| 134 | }); | ||
| 85 | 135 | ||
| 86 | }); | ||
| 87 | } | ||
| 88 | 136 | ||
| 89 | function getOneJson(id) { | ||
| 90 | 137 | ||
| 91 | jQuery(document).ready(function($) { | 138 | }); |
| 139 | } | ||
| 92 | 140 | ||
| 93 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf-google/" + id, function(data) { | 141 | function getOneJson(id) { |
| 94 | // Get the element with id summary and set the inner text to the result. | ||
| 95 | var json = JSON.stringify(data); | ||
| 96 | 142 | ||
| 97 | changePdfOptions(json); | 143 | jQuery(document).ready(function($) { |
| 98 | 144 | ||
| 99 | }); | 145 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf-google/" + id, function(data) { |
| 146 | // Get the element with id summary and set the inner text to the result. | ||
| 147 | var json = JSON.stringify(data); | ||
| 100 | 148 | ||
| 149 | changePdfOptions(json); | ||
| 101 | 150 | ||
| 151 | }); | ||
| 102 | 152 | ||
| 103 | }); | ||
| 104 | } | ||
| 105 | 153 | ||
| 106 | function pickPdfFromList(json) { | ||
| 107 | json = JSON.parse(json); | ||
| 108 | 154 | ||
| 155 | }); | ||
| 156 | } | ||
| 109 | 157 | ||
| 158 | function pickPdfFromList(json) { | ||
| 159 | json = JSON.parse(json); | ||
| 110 | 160 | ||
| 111 | 161 | ||
| 112 | var strVar = ""; | ||
| 113 | 162 | ||
| 114 | 163 | ||
| 115 | var i; | 164 | var strVar = ""; |
| 116 | var pdflist = ""; | ||
| 117 | for (i = 0; i < json.length; ++i) { | ||
| 118 | pdflist += "<div class=\"column\">"; | ||
| 119 | pdflist += '<a href=\"#\" onclick=\"getOneJson(' + json[i].idPDF + ');\"> <img class=\"thumbnail\" src="' + pdf_customizer + '/fileentry/getImage/' + json[i].folder + '/' + json[i].image + '" height=\"270px\"></a>'; | ||
| 120 | pdflist += " <h5>" + json[i].name + "<\/h5>"; | ||
| 121 | pdflist += "<\/div>"; | ||
| 122 | } | ||
| 123 | 165 | ||
| 124 | 166 | ||
| 125 | strVar += " <div class=\"callout primary\"><div class=\"row column\"> <h1>Welcome to Synapsus Online PDF Editor<\/h1>"; | 167 | var i; |
| 126 | strVar += " <p class=\"lead\">Please pick a PDF<\/p> <\/div><\/div> <div class=\"row small-up-2 medium-up-3 large-up-4\">"; | 168 | var pdflist = ""; |
| 127 | strVar += " <\/div>"; | 169 | for (i = 0; i < json.length; ++i) { |
| 170 | pdflist += '<div class="column">'; | ||
| 171 | pdflist += '<a href="#" onclick="getOneJson(' + json[i].idPDF + ');"> <img class="thumbnail" src="' + pdf_customizer + '/fileentry/getImage/' + json[i].folder + '/' + json[i].image + '" height="270px"></a>'; | ||
| 172 | pdflist += " <h5>" + json[i].name + "</h5>"; | ||
| 173 | pdflist += "</div>"; | ||
| 174 | } | ||
| 128 | 175 | ||
| 129 | 176 | ||
| 177 | strVar += ' <div class="callout primary"><div class="row column"> <h1>Welcome to Synapsus Online PDF Editor</h1>'; | ||
| 178 | strVar += ' <p class="lead">Please pick a PDF</p> </div></div> <div class="row small-up-2 medium-up-3 large-up-4/>'; | ||
| 179 | strVar += ' </div>'; | ||
| 130 | 180 | ||
| 131 | 181 | ||
| 132 | document.getElementById('contentArea').innerHTML = strVar; | ||
| 133 | 182 | ||
| 134 | 183 | ||
| 184 | document.getElementById('contentArea').innerHTML = strVar; | ||
| 135 | 185 | ||
| 136 | 186 | ||
| 137 | } | ||
| 138 | 187 | ||
| 139 | 188 | ||
| 140 | function changePdfOptions(json) { | 189 | } |
| 141 | json = JSON.parse(json); | ||
| 142 | 190 | ||
| 143 | var strVar2 = ""; | ||
| 144 | 191 | ||
| 192 | function changePdfOptions(json) { | ||
| 193 | json = JSON.parse(json); | ||
| 194 | |||
| 145 | 195 | ||
| 146 | var pdflist = ""; | 196 | |
| 147 | var pdfChange = ""; | 197 | var strVar2 = ""; |
| 148 | pdflist += "<div class=\"column\">"; | 198 | |
| 149 | pdflist += ' <img src=\"' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].image + '\" width=\"300px\">'; | 199 | |
| 150 | pdflist += "<\/div><br>"; | 200 | var pdflist = ""; |
| 151 | pdfChange += "<form id=\"changes\" name=\"changes\" enctype=\"multipart/form-data\" action=\"#\" METHOD=\"POST\"><h4>" + json[0].name + "</h4>"; | 201 | var pdfChange = ""; |
| 152 | pdfChange += " <input type=\"hidden\" id=\"id\" name=\"id\" value=\"" + json[0].idPDF + "\">"; | 202 | var f = 0; |
| 153 | for (i = 0; i < json.length; ++i) { | 203 | pdflist += '<div class="column" style="position: static; width: 212px; height: 10px; display: block; vertical-align: baseline; float: left;">'; |
| 154 | if (json[i].change_type == "text") { | 204 | // pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">'; |
| 155 | pdfChange += " Text: <input id=\"content\" type=\"text\" name=\"content\" value=\"" + json[i].content + "\">"; | 205 | pdflist += '<canvas id="Canvas" width="252px" height="504px" style=" margin-top:60px; border-style: solid; background-image: url(' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '); background-size:252px 504px;"></div>'; |
| 156 | } | 206 | pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="#" METHOD="POST"><h4>' + json[0].name + '</h4>'; |
| 157 | if (json[i].change_type == "img") { | 207 | pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">'; |
| 158 | pdfChange += "Image: <input class=\"fileupload\" id=\"content\" style=\"display: block; box-sizing: border-box; width: 100%; height: 2.4375rem; padding: .5rem; border: 1px solid #cacaca; margin: 0 0 1rem; font-family: inherit; font-size: 1rem; color: #8a8a8a; background-color: #fefefe; box-shadow: inset 0 1px 2px rgba(10,10,10,.1); border-radius: 0; transition: box-shadow .5s,border-color .25s ease-in-out; -webkit-appearance: none; -moz-appearance: none;\" type=\"file\" name=\"content\" >"; | 208 | for (i = 0; i < json.length; ++i) { |
| 159 | } | 209 | var example = json[0].folder + '/' +json[i].example |
| 210 | |||
| 211 | if (json[i].change_type == "textflow") { | ||
| 212 | pdfChange += json[i].names + ': <textarea onfocus="ShowBox('+json[0].pheight+','+json[0].pwidth+','+ json[i].locationUp+','+json[i].locationRight+','+json[i].height+','+json[i].width + ',\''+ example + '\')" title="' + json[i].names + '" id="changescontent'+[f]+'" class="textarea" value="' + json[i].content + '" name="content">' + json[i].content + '</textarea>'; | ||
| 213 | ++f | ||
| 214 | } | ||
| 215 | if (json[i].change_type == "text") { | ||
| 216 | pdfChange += json[i].names + ': <input onfocusout="HideBox()" onfocus="ShowBox('+json[0].pheight+','+json[0].pwidth+','+ json[i].locationUp+','+json[i].locationRight+','+json[i].height+','+json[i].width +',\''+ example + '\')" title="' + json[i].names + '" id="changescontent" type="text" name="content" value="' + json[i].content + '"">'; | ||
| 217 | } | ||
| 218 | if (json[i].change_type == "img") { | ||
| 219 | pdfChange += json[i].names + ': <input onfocusout="HideBox()" onfocus="ShowBox('+json[0].pheight+','+json[0].pwidth+','+ json[i].locationUp+','+json[i].locationRight+','+json[i].height+','+json[i].width + ',\''+ example + '\')" title="' + json[i].names + '" class="fileupload" id="changescontent" style="display: block; box-sizing: border-box; width: 100%; height: 2.4375rem; padding: .5rem; border: 1px solid #cacaca; margin: 0 0 1rem; font-family: inherit; font-size: 1rem; color: #8a8a8a; background-color: #fefefe; box-shadow: inset 0 1px 2px rgba(10,10,10,.1); border-radius: 0; transition: box-shadow .5s,border-color .25s ease-in-out; -webkit-appearance: none; -moz-appearance: none;" type="file" name="content" >'; | ||
| 220 | } | ||
| 221 | } | ||
| 222 | pdfChange += '<input type="submit" value="Submit">'; | ||
| 223 | pdfChange += '</form>'; | ||
| 224 | |||
| 225 | strVar2 += ' <div class="callout primary"><div class="row column"><h1>Welcome to Synapsus Online PDF Editor</h1>'; | ||
| 226 | strVar2 += '<p class="lead">Please make your changes or return <a href="#" onclick="location.reload();">back to the list</a></p>'; | ||
| 227 | strVar2 += ' </div></div><div class="row small-up-2 medium-up-3 large-up-3">'; | ||
| 228 | strVar2 += pdflist + '<div class="column" style="margin-left:300px; width:300px;">' + pdfChange + '</div></div><div style="height: 200px; margin-top: 50px;padding: 10px;position: relative;"></div>'; | ||
| 229 | |||
| 230 | |||
| 231 | |||
| 232 | document.getElementById('contentArea').innerHTML = strVar2; | ||
| 233 | document.getElementById('google_drive').innerHTML = " "; | ||
| 234 | |||
| 235 | jQuery(function($) { | ||
| 236 | |||
| 237 | |||
| 238 | |||
| 239 | $("#Canvas").stick_in_parent(); | ||
| 240 | |||
| 241 | |||
| 242 | |||
| 243 | |||
| 244 | |||
| 245 | |||
| 246 | |||
| 247 | tinymce.init({ | ||
| 248 | selector: '.textarea', | ||
| 249 | entity_encoding: "raw", | ||
| 250 | menubar: false, | ||
| 251 | toolbar: ' bold italic', | ||
| 252 | remove_linebreaks: false, | ||
| 253 | remove_trailing_brs: false, | ||
| 254 | setup: function(editor) { | ||
| 255 | editor.on('focus', function(e) { | ||
| 256 | console.log(editor.id); | ||
| 257 | $('#' + editor.id).trigger("onfocus"); | ||
| 258 | }); | ||
| 259 | editor.on('focusout', function(e) { | ||
| 260 | console.log('out'+editor.id); | ||
| 261 | HideBox(); | ||
| 262 | }); | ||
| 160 | } | 263 | } |
| 161 | pdfChange += " <input type=\"submit\" value=\"Submit\">"; | 264 | |
| 162 | pdfChange += "<\/form>"; | 265 | |
| 163 | 266 | ||
| 164 | strVar2 += " <div class=\"callout primary\"><div class=\"row column\"><h1>Welcome to Synapsus Online PDF Editor<\/h1>"; | 267 | }); |
| 165 | strVar2 += "<p class=\"lead\">Please make your changes or return <a href=\"#\" onclick=\"location.reload();\">back to the list</a><\/p>"; | ||
| 166 | strVar2 += " <\/div><\/div><div class=\"row small-up-2 medium-up-3 large-up-3\">"; | ||
| 167 | strVar2 += pdflist + "<div class=\"column\">" + pdfChange + "<\/div><\/div>"; | ||
| 168 | 268 | ||
| 269 | var files; | ||
| 270 | var imagefiles = [];; | ||
| 169 | 271 | ||
| 170 | 272 | ||
| 171 | document.getElementById('contentArea').innerHTML = strVar2; | 273 | $(".fileupload").change(function(e) { |
| 172 | document.getElementById('google_drive').innerHTML = " "; | 274 | files = e.target.files; |
| 275 | for (var i = 0, file; file = files[i]; i++) { | ||
| 276 | console.log(file); | ||
| 277 | imagefiles.push(file); | ||
| 278 | console.log(imagefiles); | ||
| 279 | } | ||
| 280 | }); | ||
| 173 | 281 | ||
| 174 | jQuery(function($) { | ||
| 175 | var files; | ||
| 176 | 282 | ||
| 177 | // Add events | 283 | $("#changes").submit(function(e) { |
| 178 | $(".fileupload").change(function() { | 284 | $(tinymce.get()).each(function(i, el) { |
| 179 | files = event.target.files; | ||
| 180 | console.log(files); | ||
| 181 | }); | ||
| 182 | 285 | ||
| 286 | if (el.id) | ||
| 287 | document.getElementById(el.id).value = el.getContent(); | ||
| 288 | console.log(el.id); | ||
| 289 | tinymce.get(el.id).remove(); | ||
| 183 | 290 | ||
| 184 | $("#changes").submit(function(e) { | ||
| 185 | e.preventDefault(); | ||
| 186 | 291 | ||
| 187 | var form = $("#changes"); | 292 | }); |
| 188 | // var values = {}; | ||
| 189 | //form.each(function() { | ||
| 190 | // values[this.name] = $(this).val(); | ||
| 191 | //}); | ||
| 192 | console.log(form); | ||
| 193 | 293 | ||
| 194 | returnfileOptions(files, form); | ||
| 195 | return false; | ||
| 196 | }); | ||
| 197 | 294 | ||
| 295 | e.preventDefault(); | ||
| 198 | 296 | ||
| 297 | var form = $("#changes"); | ||
| 199 | 298 | ||
| 200 | }); | ||
| 201 | 299 | ||
| 202 | } | ||
| 203 | 300 | ||
| 204 | function returnfileOptions(files, form) { | 301 | returnfileOptions(imagefiles, form); |
| 205 | jQuery(function($) { | 302 | return false; |
| 303 | }); | ||
| 206 | 304 | ||
| 207 | var data = new FormData(); | ||
| 208 | $.each(files, function(key, value) { | ||
| 209 | data.append(key, value); | ||
| 210 | }); | ||
| 211 | 305 | ||
| 212 | $.ajax({ | ||
| 213 | url: '' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files', | ||
| 214 | type: 'POST', | ||
| 215 | data: data, | ||
| 216 | cache: false, | ||
| 217 | dataType: 'json', | ||
| 218 | processData: false, // Don't process the files | ||
| 219 | contentType: false, // Set content type to false as jQuery will tell the server its a query string request | ||
| 220 | success: function(data, textStatus, jqXHR) { | ||
| 221 | if (typeof data.error === 'undefined') { | ||
| 222 | returnOptions(form); | ||
| 223 | } else { | ||
| 224 | // Handle errors here | ||
| 225 | 306 | ||
| 226 | console.log('ERRORS: ' + data.error); | 307 | }); |
| 227 | } | ||
| 228 | }, | ||
| 229 | error: function(jqXHR, textStatus, errorThrown) { | ||
| 230 | // Handle errors here | ||
| 231 | console.log('ERRORS: ' + textStatus); | ||
| 232 | // STOP LOADING SPINNER | ||
| 233 | } | ||
| 234 | }); | ||
| 235 | 308 | ||
| 236 | }); | 309 | } |
| 237 | } | 310 | |
| 238 | 311 | ||
| 312 | function returnfileOptions(files, form) { | ||
| 313 | jQuery(function($) { | ||
| 239 | 314 | ||
| 240 | function returnOptions(form) { | 315 | var data = new FormData(); |
| 316 | $.each(files, function(key, value) { | ||
| 317 | data.append(key, value); | ||
| 241 | 318 | ||
| 319 | }); | ||
| 242 | 320 | ||
| 243 | // console.log(form[0][1].value); | 321 | $.ajax({ |
| 322 | url: '' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files', | ||
| 323 | type: 'POST', | ||
| 324 | data: data, | ||
| 325 | cache: false, | ||
| 326 | dataType: 'json', | ||
| 327 | processData: false, // Don't process the files | ||
| 328 | contentType: false, // Set content type to false as jQuery will tell the server its a query string request | ||
| 329 | success: function(data, textStatus, jqXHR) { | ||
| 330 | if (typeof data.error === 'undefined') { | ||
| 331 | returnOptions(form); | ||
| 332 | } else { | ||
| 333 | // Handle errors here | ||
| 244 | 334 | ||
| 335 | console.log('ERRORS: ' + data.error); | ||
| 336 | } | ||
| 337 | }, | ||
| 338 | error: function(jqXHR, textStatus, errorThrown) { | ||
| 339 | // Handle errors here | ||
| 340 | console.log('ERRORS: ' + textStatus); | ||
| 341 | // STOP LOADING SPINNER | ||
| 342 | } | ||
| 343 | }); | ||
| 245 | 344 | ||
| 345 | }); | ||
| 346 | } | ||
| 347 | |||
| 348 | |||
| 349 | function returnOptions(form) { | ||
| 350 | |||
| 351 | |||
| 352 | |||
| 353 | |||
| 246 | 354 | ||
| 247 | 355 | ||
| 248 | jQuery(function($) { | 356 | jQuery(function($) { |
| 249 | 357 | ||
| 250 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) { | 358 | $.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) { |
| 251 | // Get the element with id summary and set the inner text to the result. | 359 | // Get the element with id summary and set the inner text to the result. |
| 252 | var json = dataReturnd; | 360 | var json = dataReturnd; |
| 253 | //console.log(json); | 361 | //console.log(json); |
| 254 | 362 | ||
| 255 | 363 | ||
| 256 | var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '"}],"changes":[' | 364 | var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '","pageWidth":"' + json[0].pageWidth + '","pageHeight":"' + json[0].pageHeight + '"}],"changes":[' |
| 257 | var e = 1; | 365 | var e = 1; |
| 258 | for (i = 0; i < json.length; ++i) { | 366 | for (i = 0; i < json.length; ++i) { |
| 259 | 367 | ||
| 260 | 368 | ||
| 261 | 369 | ||
| 262 | var style = JSON.stringify(json[i].style); | 370 | var style = JSON.stringify(json[i].style); |
| 263 | var content = JSON.stringify(form[0][e].value); | 371 | var content = JSON.stringify(form[0][e].value); |
| 372 | console.log(form[0][e].value); | ||
| 264 | 373 | ||
| 265 | 374 | ||
| 266 | 375 | ||
| 267 | jsonReturn += '{"label":"' + json[i].label + '", "locationUp":"' + json[i].locationUp + '", "locationRight":"' + json[i].locationRight + '","width":"' + json[i].width + '","height":"' + json[i].height + '", "pages":"' + json[i].pages + '", "content":' + content + ', "z-index":null, "idstylesPDF":"' + json[i].idstylesPDF + '", "style":' + style + ', "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/images"}'; | 376 | jsonReturn += '{"label":"' + json[i].label + '", "locationUp":"' + json[i].locationUp + '", "locationRight":"' + json[i].locationRight + '","width":"' + json[i].width + '","height":"' + json[i].height + '", "pages":"' + json[i].pages + '", "content":' + content + ', "z-index":null, "idstylesPDF":"' + json[i].idstylesPDF + '", "style":' + style + ', "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/images"}'; |
| 268 | 377 | ||
| 269 | 378 | ||
| 270 | if (i < json.length - 1) { | 379 | if (i < json.length - 1) { |
| 271 | jsonReturn += ','; | 380 | jsonReturn += ','; |
| 272 | } | 381 | } |
| 273 | ++e | 382 | ++e |
| 274 | } | 383 | } |
| 275 | jsonReturn += ' ]}'; | 384 | jsonReturn += ' ]}'; |
| 276 | // console.log(jsonReturn); | 385 | // console.log(jsonReturn); |
| 277 | 386 | ||
| 278 | 387 | ||
| 279 | 388 | ||
| 280 | 389 | ||
| 281 | $.ajax({ | 390 | $.ajax({ |
| 282 | url: "" + pdf_customizer + "/api/update", | 391 | url: "" + pdf_customizer + "/api/update", |
| 283 | type: "POST", | 392 | type: "POST", |
| 284 | dataType: 'json', | 393 | dataType: 'json', |
| 285 | data: jsonReturn, | 394 | data: jsonReturn, |
| 286 | processData: false, | 395 | processData: false, |
| 287 | 396 | ||
| 288 | contentType: "application/json", | 397 | contentType: "application/json", |
| 289 | CrossDomain: true, | 398 | CrossDomain: true, |
| 290 | 399 | ||
| 291 | 400 | ||
| 292 | 401 | ||
| 293 | 402 | ||
| 294 | async: true, | 403 | async: true, |
| 295 | success: function(data) { | 404 | success: function(data) { |
| 296 | var strVar2 ="" | 405 | var strVar2 = "" |
| 297 | strVar2 += " <div class=\"callout primary\"><div class=\"row column\"><h1>Welcome to Synapsus Online PDF Editor<\/h1>"; | 406 | strVar2 += " <div class=\"callout primary\"><div class=\"row column\"><h1>Welcome to Synapsus Online PDF Editor<\/h1>"; |
| 298 | strVar2 += "<p class=\"lead\">Please download your file below or return <a href=\"#\" onclick=\"location.reload();\">back to the list</a><\/p>"; | 407 | strVar2 += "<p class=\"lead\">Please download your file below or return <a href=\"#\" onclick=\"location.reload();\">back to the list</a><\/p>"; |
| 299 | strVar2 += " <\/div><\/div><div class=\"row small-up-2 medium-up-3 large-up-3\">"; | 408 | strVar2 += " <\/div><\/div><div class=\"row small-up-2 medium-up-3 large-up-3\">"; |
| 300 | strVar2 += "<div class=\"column\">" + '<a href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" ><i class="fa fa-cloud-download fa-5x"></i></br>Download Here</a>'; | 409 | strVar2 += "<div class=\"column\">" + '<a href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" ><i class="fa fa-cloud-download fa-5x"></i></br>Download Here</a>'; + |
| 301 | + "<\/div><\/div>"; | 410 | "<\/div><\/div>"; |
| 302 | 411 | ||
| 303 | document.getElementById('contentArea').innerHTML = strVar2 }, | 412 | document.getElementById('contentArea').innerHTML = strVar2 |
| 304 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response | 413 | }, |
| 305 | alert(xhr.status); | 414 | error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response |
| 306 | document.getElementById('contentArea').innerHTML = xhr.responseText; | 415 | alert(xhr.status); |
| 307 | } | 416 | document.getElementById('contentArea').innerHTML = xhr.responseText; |
| 417 | } | ||
| 308 | 418 | ||
| 309 | }); | 419 | }); |
| 310 | 420 | ||
| 311 | 421 | ||
| 312 | 422 | ||
| 313 | 423 | ||
| 314 | }); | 424 | }); |
| 315 | 425 | ||
| 316 | 426 | ||
| 317 | }); | 427 | }); |
| 318 | 428 | ||
| 319 | 429 | ||
| 320 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 430 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment