wiziwig
Showing
19 changed files
with
105 additions
and
9 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
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment