From d773d3f54d9fe14b9f7572737b280508049270a0 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Fri, 10 Feb 2023 16:11:19 +0530 Subject: [PATCH] PDF merger again Implemented : ps --- api/application/composer.json | 5 +- api/application/composer.lock | 181 +++++++++++++++++- api/application/controllers/PD_Controller.php | 46 ++--- .../Request_DataDump_Controller.php | 8 +- 4 files changed, 204 insertions(+), 36 deletions(-) diff --git a/api/application/composer.json b/api/application/composer.json index 6c19bdef..727f3c29 100644 --- a/api/application/composer.json +++ b/api/application/composer.json @@ -19,14 +19,15 @@ "aws/aws-sdk-php": "^3.64", "amphp/amp": "^1.2", "dompdf/dompdf" : "0.8.3", - "tecnickcom/tcpdf": "^6.2", + "tecnickcom/tcpdf": "^6.6", "phpmailer/phpmailer": "^6.0", "php-curl-class/php-curl-class": "^8.5", "guzzlehttp/guzzle": "^6.3", "twilio/sdk": "^6.10", "phpoffice/phpspreadsheet": "^1.27", "johnathanmiller/secure-env-php": "^2.0", - "google/apiclient": "^2.0" + "google/apiclient": "^2.0", + "jurosh/pdf-merge": "^2.1" }, "suggest": { diff --git a/api/application/composer.lock b/api/application/composer.lock index 5ce490cd..7387764e 100644 --- a/api/application/composer.lock +++ b/api/application/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2af2e3eae81cacaec3b5daa4300379c3", + "content-hash": "37132a2e89b7f0d6ca3f66aef20cecca", "packages": [ { "name": "amphp/amp", @@ -938,6 +938,55 @@ }, "time": "2019-01-07T06:56:58+00:00" }, + { + "name": "jurosh/pdf-merge", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/jurosh/php-pdf-merge.git", + "reference": "89ba3446c9f38c573e3b8bf577d2f22993494130" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jurosh/php-pdf-merge/zipball/89ba3446c9f38c573e3b8bf577d2f22993494130", + "reference": "89ba3446c9f38c573e3b8bf577d2f22993494130", + "shasum": "" + }, + "require": { + "php": ">=5.6.20", + "setasign/fpdf": "^1.8", + "setasign/fpdi": "^2.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/Jurosh/PDFMerge/PDFMerger.php", + "src/Jurosh/PDFMerge/PDFObject.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Juraj Husar", + "email": "jurosh@jurosh.com", + "homepage": "http://jurosh.com" + } + ], + "description": "PHP PDF Merger", + "homepage": "https://github.com/jurosh/php-pdf-merge", + "keywords": [ + "merge", + "pdf" + ], + "support": { + "issues": "https://github.com/jurosh/php-pdf-merge/issues", + "source": "https://github.com/jurosh/php-pdf-merge/tree/remove" + }, + "time": "2021-03-28T19:57:14+00:00" + }, { "name": "maennchen/zipstream-php", "version": "2.1.0", @@ -2299,6 +2348,124 @@ }, "time": "2021-12-11T13:40:54+00:00" }, + { + "name": "setasign/fpdf", + "version": "1.8.5", + "source": { + "type": "git", + "url": "https://github.com/Setasign/FPDF.git", + "reference": "f4104a04c9a3f95c4c26a0a0531abebcc980987a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Setasign/FPDF/zipball/f4104a04c9a3f95c4c26a0a0531abebcc980987a", + "reference": "f4104a04c9a3f95c4c26a0a0531abebcc980987a", + "shasum": "" + }, + "require": { + "ext-gd": "*", + "ext-zlib": "*" + }, + "type": "library", + "autoload": { + "classmap": [ + "fpdf.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Olivier Plathey", + "email": "oliver@fpdf.org", + "homepage": "http://fpdf.org/" + } + ], + "description": "FPDF is a PHP class which allows to generate PDF files with pure PHP. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.", + "homepage": "http://www.fpdf.org", + "keywords": [ + "fpdf", + "pdf" + ], + "support": { + "source": "https://github.com/Setasign/FPDF/tree/1.8.5" + }, + "time": "2022-11-18T07:02:00+00:00" + }, + { + "name": "setasign/fpdi", + "version": "v2.3.7", + "source": { + "type": "git", + "url": "https://github.com/Setasign/FPDI.git", + "reference": "bccc892d5fa1f48c43f8ba7db5ed4ba6f30c8c05" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Setasign/FPDI/zipball/bccc892d5fa1f48c43f8ba7db5ed4ba6f30c8c05", + "reference": "bccc892d5fa1f48c43f8ba7db5ed4ba6f30c8c05", + "shasum": "" + }, + "require": { + "ext-zlib": "*", + "php": "^5.6 || ^7.0 || ^8.0" + }, + "conflict": { + "setasign/tfpdf": "<1.31" + }, + "require-dev": { + "phpunit/phpunit": "~5.7", + "setasign/fpdf": "~1.8", + "setasign/tfpdf": "1.31", + "squizlabs/php_codesniffer": "^3.5", + "tecnickcom/tcpdf": "~6.2" + }, + "suggest": { + "setasign/fpdf": "FPDI will extend this class but as it is also possible to use TCPDF or tFPDF as an alternative. There's no fixed dependency configured." + }, + "type": "library", + "autoload": { + "psr-4": { + "setasign\\Fpdi\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Slabon", + "email": "jan.slabon@setasign.com", + "homepage": "https://www.setasign.com" + }, + { + "name": "Maximilian Kresse", + "email": "maximilian.kresse@setasign.com", + "homepage": "https://www.setasign.com" + } + ], + "description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.", + "homepage": "https://www.setasign.com/fpdi", + "keywords": [ + "fpdf", + "fpdi", + "pdf" + ], + "support": { + "issues": "https://github.com/Setasign/FPDI/issues", + "source": "https://github.com/Setasign/FPDI/tree/v2.3.7" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/setasign/fpdi", + "type": "tidelift" + } + ], + "time": "2023-02-09T10:38:43+00:00" + }, { "name": "smalot/pdfparser", "version": "v0.13.3", @@ -2830,16 +2997,16 @@ }, { "name": "tecnickcom/tcpdf", - "version": "6.4.4", + "version": "6.6.2", "source": { "type": "git", "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "42cd0f9786af7e5db4fcedaa66f717b0d0032320" + "reference": "e3cffc9bcbc76e89e167e9eb0bbda0cab7518459" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/42cd0f9786af7e5db4fcedaa66f717b0d0032320", - "reference": "42cd0f9786af7e5db4fcedaa66f717b0d0032320", + "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/e3cffc9bcbc76e89e167e9eb0bbda0cab7518459", + "reference": "e3cffc9bcbc76e89e167e9eb0bbda0cab7518459", "shasum": "" }, "require": { @@ -2890,7 +3057,7 @@ ], "support": { "issues": "https://github.com/tecnickcom/TCPDF/issues", - "source": "https://github.com/tecnickcom/TCPDF/tree/6.4.4" + "source": "https://github.com/tecnickcom/TCPDF/tree/6.6.2" }, "funding": [ { @@ -2898,7 +3065,7 @@ "type": "custom" } ], - "time": "2021-12-31T08:39:24+00:00" + "time": "2022-12-17T10:28:59+00:00" }, { "name": "thiagoalessio/tesseract_ocr", diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index daee6171..2fd4cbdb 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -4513,19 +4513,19 @@ class PD_Controller extends REST_Controller // die(); //PDF Gen using DOM PDF $pdf_doc = $this->pdfgenerator->generate($temp, $filename = 'version', $stream = false, $paper = 'A4', $orientation = "portrait"); - // $details = $this->PD_Model->getDocsDetails($pdid); - // if(!empty($details)){ - // for($i=0;$iaws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $dockey, '+30 minutes'); - // $src_local_file = XLPATH.'/tmp/'.$details[$i]['pd_document_name']; - // $ifp = fopen( $src_local_file, 'wb' ); - // fwrite( $ifp, $doc_singed_uri ); - // fclose( $ifp ); - // chmod($src_local_file, 0777); - // $docsdetails[] = $details[$i]['pd_document_name']; - // } - // } + $details = $this->PD_Model->getDocsDetails($pdid); + if(!empty($details)){ + for($i=0;$iaws_s3->getSingleObjectInaBucketAsSignedURI($bucketname, $dockey, '+30 minutes'); + $src_local_file = XLPATH.'/tmp/'.$details[$i]['pd_document_name']; + $ifp = fopen( $src_local_file, 'wb' ); + fwrite( $ifp, $doc_singed_uri ); + fclose( $ifp ); + chmod($src_local_file, 0777); + $docsdetails[] = $details[$i]['pd_document_name']; + } + } // ALTER TABLE `sineedgedemo`.`t_pd_documents` // ADD COLUMN `docs_merge` TINYINT(4) NULL DEFAULT '0' AFTER `content_type`; //End of PDF Gen using DOM PDF @@ -4534,16 +4534,16 @@ class PD_Controller extends REST_Controller // echo $output_file2; // die(); if (file_put_contents($output_file2, $pdf_doc)) { - // if(!empty($docsdetails)){ - // $pdf = new \Jurosh\PDFMerge\PDFMerger; - // // $pdf = new PDFMerger; - // $pdf->addPDF($output_file2, 'all'); - // foreach($docsdetails as $doc) - // { - // $pdf->addPDF(XLPATH.'/tmp/'.$doc, 'all'); - // } - // $pdf->merge('file', $output_file2); - // } + if(!empty($docsdetails)){ + $pdf = new \Jurosh\PDFMerge\PDFMerger; + // $pdf = new PDFMerger; + $pdf->addPDF($output_file2, 'all'); + foreach($docsdetails as $doc) + { + $pdf->addPDF(XLPATH.'/tmp/'.$doc, 'all'); + } + $pdf->merge('file', $output_file2); + } $sourcefile = $output_file2; // print_r($sourcefile);die(); $bucket_data = array('bucket_name' => $bucketname, 'key' => $newkey, 'sourcefile' => $sourcefile); diff --git a/api/application/controllers/Request_DataDump_Controller.php b/api/application/controllers/Request_DataDump_Controller.php index 2fb75dd9..8a7f8f2a 100755 --- a/api/application/controllers/Request_DataDump_Controller.php +++ b/api/application/controllers/Request_DataDump_Controller.php @@ -44,7 +44,7 @@ class Request_DataDump_Controller extends REST_Controller { $records = $this->post(); if(!empty($records)){ $id = $this->Data_Dump_Model->saveRecords($records, DATADUMPREQUEST); - // $id = 17; + // $id = 4; log_message('ERROR','## 1) saveDatadumpRequest Fns RequestID - '.$id); if ($id) { $data['dataStatus'] = true; @@ -371,7 +371,7 @@ class Request_DataDump_Controller extends REST_Controller { if($B==0){$B=3;} $spreadsheet->setActiveSheetIndex(4)->setCellValue('A'.$B,$processedJson['pdid'])->setCellValue('W'.$B,!empty($processedJson['banking_form_remark'])?$processedJson['banking_form_remark']:"-"); $spreadsheet->setActiveSheetIndex(4)->setCellValue('B'.$B,$processedJson['bank_info_available']?'Yes':'No'); - $spreadsheet->setActiveSheetIndex(4)->setCellValue('M'.$B,$processedJson['bank_info_available']?'Yes':'No'); + $spreadsheet->setActiveSheetIndex(4)->setCellValue('M'.$B,$processedJson['bank_info_available_business']?'Yes':'No'); $a = $B; $b = $B; $Individualbankdtls = $processedJson['banking_details']; @@ -1950,8 +1950,8 @@ class Request_DataDump_Controller extends REST_Controller { // Save .xlsx file to the current directory $filename = "DRID".$id."_".date('Ymd_hmi').".xlsx"; $writer->save(XLPATH.'/dump/'.$filename); - $result = $this->uploadXltoAWS($id,$filename); - // $result = true; + // $result = $this->uploadXltoAWS($id,$filename); + $result = true; return $result; } else