80fc1b5b by Jeff Balicki

added pdf

1 parent ddcd7cb7
This file is too large to display.
No preview for this file type
This diff could not be displayed because it is too large.
1 // var pluginUrl = "http://localhost:8888/Forms"; 1 // var pluginUrl = "http://localhost:8888/Forms";
2 // var pdf_customizer = "http://localhost:8888/pdf-customizer/public"; 2 // var pdf_customizer = "http://localhost:8888/pdf-customizer/public";
3 3
4 var pluginUrl = "http://contact.gotenzing.com"; 4 var pluginUrl = "http://contact.gotenzing.com";
5 var pdf_customizer = "http://pdf-customizer.synapsus.co"; 5 var pdf_customizer = "http://pdf-customizer.synapsus.co";
...@@ -82,15 +82,17 @@ ...@@ -82,15 +82,17 @@
82 var down = pheight - (up + height); 82 var down = pheight - (up + height);
83 var scaleH = $("Canvas").height() / pheight ; 83 var scaleH = $("Canvas").height() / pheight ;
84 var scaleW = $("Canvas").width() / pwidth ; 84 var scaleW = $("Canvas").width() / pwidth ;
85 var scaleDown = down / scaleH; 85 var scaleDown = down * scaleH;
86 var scaleRight = right/ scaleW; 86 var scaleRight = right* scaleW;
87 var scalewidth = width / scaleW; 87 var scalewidth = width * scaleW;
88 var scaleheight = height / scaleH; 88 var scaleheight = height * scaleH;
89 89
90 var c = document.getElementById("Canvas"); 90 var c = document.getElementById("Canvas");
91 var ctx = c.getContext("2d"); 91 var ctx = c.getContext("2d");
92 ctx.save(); 92 ctx.save();
93 ctx.rect(scaleRight, scaleDown , scalewidth, scaleheight); 93 ctx.rect(scaleRight, scaleDown , scalewidth, scaleheight);
94 console.log(scaleRight, scaleDown , scalewidth, scaleheight);
95 console.log($("Canvas").height(), $("Canvas").width(), scaleW, scaleH);
94 ctx.stroke(); 96 ctx.stroke();
95 //console.log(pheight, pwidth,up, right, height, width); 97 //console.log(pheight, pwidth,up, right, height, width);
96 // console.log(myrect ) 98 // console.log(myrect )
...@@ -202,9 +204,20 @@ ...@@ -202,9 +204,20 @@
202 var pdflist = ""; 204 var pdflist = "";
203 var pdfChange = ""; 205 var pdfChange = "";
204 var f = 0; 206 var f = 0;
207 if(json[0].pwidth > '300'){
208 var scaleImage = 300 / json[0].pwidth;
209 var imageHeight = json[0].pheight * scaleImage;
210 var imageWidth = '300';
211 console.log(json[0].pheight , scaleImage, imageHeight);
212 }else{
213 var imageWidth = json[0].pwidth;
214 var imageHeight = json[0].pheight;
215 console.log(json[0].pheight , scaleImage);
216
217 }
205 pdflist += '<div id="pdfPreview" class="column">'; 218 pdflist += '<div id="pdfPreview" class="column">';
206 // pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">'; 219 // pdflist += '<img id="pdfimage" src="' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '" width="300px">';
207 pdflist += '<canvas id="Canvas" width="252px" height="504px" style=" margin-top:60px; border-style: solid; border-width:1px; background-image: url(' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '); background-size:252px 504px;"></div>'; 220 pdflist += '<canvas id="Canvas" width="'+imageWidth+'" height="'+imageHeight+'" style=" margin-top:60px; border-style: solid; border-width:1px; background-image: url(' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].example + '); background-size:'+imageWidth+'px '+imageHeight+'px"></div>';
208 pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"><h4>' + json[0].name + '</h4>'; 221 pdfChange += '<form id="changes" name="changes" enctype="multipart/form-data" action="" METHOD="POST"><h4>' + json[0].name + '</h4>';
209 pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">'; 222 pdfChange += '<input type="hidden" id="id" name="id" value="' + json[0].idPDF + '">';
210 for (i = 0; i < json.length; ++i) { 223 for (i = 0; i < json.length; ++i) {
......