I can't solve this Fatal error problem with pdfMerger - php

I'm trying to merge some pdf's, but I have a problem that I can't understand and I don't know what's happening, Can someone help me?
Attached code in PHP
This is the method for pdfMerger
public static function pdfMerger($archivos, $destino){
$pdf = new PDFMerger(); // or use $pdf = new \PDFMerger; for Laravel
if($archivos != null){
for($i=0; $i < count($archivos); $i++){
$pdf->addPDF($archivos[$i], 'all');
}
}
$pdf->merge('file', $destino);
}
And here is where I'm calling the method:
//This is a test
$control = new FilesController();
$dir = "/Jomar/induccion/documents/";
$files = glob($_SERVER['DOCUMENT_ROOT']."{$dir}politicas empresa/*.pdf");
$url = $_SERVER['DOCUMENT_ROOT']."{$dir}politicas empresa/prueba.pdf";
print_r($files);
$control->pdfMerger($files, $url);
This is the error I'm currently receiving:
Fatal error: Uncaught Exception: TCPDF_PARSER ERROR: decodeFilterFlateDecode: invalid code in C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\include\tcpdf_filters.php:474 Stack trace: #0 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\include\tcpdf_filters.php(359): TCPDF_FILTERS::Error('decodeFilterFla...') #1 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\include\tcpdf_filters.php(94): TCPDF_FILTERS::decodeFilterFlateDecode('\xEA\x91\xB9mj/\xAB\x8E;iN\xA3\x143\xAF...') #2 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\tcpdi_parser.php(1310): TCPDF_FILTERS::decodeFilter('FlateDecode', '\xEA\x91\xB9mj/\xAB\x8E;iN\xA3\x143\xAF...') #3 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\tcpdi_parser.php(1249): tcpdi_parser->_rebuildContentStream(Array) #4 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\tcpdi.php(192): tcpdi_parser->getContent() #5 C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\PDFMerger.php(104): TCPDI->importPage(1) in C:\xampp\htdocs\Jomar\induccion\config\PDFMerger-master\tcpdf\include\tcpdf_filters.php on line 474
(Sorry for my english)

The problem was of the permissions of the pdf, therefore, is necessary to check that in the pdf document doesn't have any type of restrictions. thanks for your help.

Related

issues running php as it unable to find the file

I am using the following to run the php file under xampp htdocs with foldername as kraken but i am getting an error
<?php
require_once 'KrakenAPIClient.php';
$key = 'dfdfdfdf';
$secret = 'dfdfdfdf';
// set which platform to use (currently only beta is operational, live available soon)
$beta = false;
$url = $beta ? 'https://api.beta.kraken.com' : 'https://api.kraken.com';
$sslverify = $beta ? false : true;
$version = 0;
$kraken = new KrakenAPI($key, $secret, $url, $version, $sslverify);
error i am getting is:
Fatal error: Uncaught Error: Class 'KrakenAPI' not found in C:\xampp\htdocs\kraken\example.php:21 Stack trace: #0 {main} thrown in C:\xampp\htdocs\kraken\example.php on line 21
You'd need to alias the class with use, before being able to skip it's name-space:
use \Payward\KrakenAPI;
Also see the PHP manual which I've linked for a more detailed explanation.

PdfParser issue in PHP

Thank you in advance
I am using the PdfParser library to extract text from PDF
My current code for that is as below
$parser = new \Smalot\PdfParser\Parser();
$pdfsource = $parser->parseFile($dest_path);
$pages = $pdfsource->getPages();
foreach ($pages as $page) {
$final_text.=strtolower(str_replace(' ', '', $page->getText()));
}
It is working well but for some PDF getting below Exception
Fatal error: Uncaught Exception: Object list not found. Possible secured file. in /var/www/html/pdfparser-master/vendor/smalot/pdfparser/src/Smalot/PdfParser/Parser.php:102 Stack trace: #0

phantomJs permission denied

Have a question and I have the feeling it should not be to hard to solve but I'm not really familiar with Phantom Js.
$this->phantomProcess($path)->setTimeout(10)->mustRun();
This line results in the following error:
protected function captureImage($view)
{
$path = $this->writeFile($view);
$this->phantomProcess($path)->setTimeout(10)->mustRun();
return $path;
}
protected function writeFile($view)
{
file_put_contents($path = 'storage/' . md5(uniqid()) . '.pdf' , $view);
return $path;
}
protected function phantomProcess($path)
{
return new Process('bin/phantomjs capture.js ' . $path);
}
I'm running the following line:
Fatal error: Uncaught exception 'Symfony\Component\Process\Exception\ProcessFailedException' with message 'The command "bin/phantomjs capture.js storage/7c5b791a0c1f131aac5c5ca272a1c891.pdf" failed. Exit Code: 126(Invoked command cannot execute) Working directory: /Applications/XAMPP/xamppfiles/htdocs/pdf Output: ================ Error Output: ================ sh: bin/phantomjs: cannot execute binary file ' in /Applications/XAMPP/xamppfiles/htdocs/pdf/vendor/symfony/process/Process.php:239 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/pdf/app/Codecourse/Capture/Capture.php(45): Symfony\Component\Process\Process->mustRun() #1 /Applications/XAMPP/xamppfiles/htdocs/pdf/app/Codecourse/Capture/Capture.php(24): Codecourse\Capture\Capture->captureImage('<!DOCTYPE html>...') #2 /Applications/XAMPP/xamppfiles/htdocs/pdf/index.php(17): Codecourse\Capture\Capture->load('invoice.php', Array) #3 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/pdf/vendor/symfony/process/Process.php on line 239
Anybody who can help me out?
Really appreciated,

Fatal Error in convert PPT to PNG in PHP

I want to convert PPT to PNG with PHP. I wrote the following piece of code to solve the problem:
$powerpnt = new COM("PowerPoint.Application") or die('could not create the powerpoint instance');
$powerpnt->Visible = True;
$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"])));
$FileName = "MyPP";
$powerpnt->Presentations->Open("D:\\MySlide.ppt"); /* This is line #16 */
$powerpnt->ActivePresentation->SaveAs($strPath."/".$FileName,17);
$powerpnt->Quit;
$powerpnt = null;
But I got the following Fatal error:
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Office PowerPoint 2007<br/><b>Description:</b> PowerPoint could not open the file.' in C:\wamp\www\ppt2jpg\ppt2jpg.php:16 Stack trace: #0 C:\wamp\www\ppt2jpg\ppt2jpg.php(16): variant->Open('D:\MySlide.ppt') #1 {main} thrown in C:\wamp\www\ppt2jpg\ppt2jpg.php on line 16
How can I solve this problem?
Thanks in advance.

How to fix error returned by __soapCall?

$param['websiteConfigID'] = 729872;
$param['numberOfRecords'] = 10;
$param['numberOfRecords'] = 10;
$client = new SoapClient(WSDL);
$result = $client->__soapCall('GetTicketsStringInputs', array('parameters' => $param));
$result holding this error message....
Fatal error: Uncaught SoapFault exception:
[Client] Function ("GetTicketsStringInputs") is not a valid method for this service in /home/fmticket/public_html/inc/genericLib.php:279
Stack trace:
#0 /home/fmticket/public_html/inc/genericLib.php(279): SoapClient->__soapCall('GetTicketsStrin...', Array)
#1 /home/fmticket/public_html/resultsTicket.php(12): getTickets(Array)
#2 {main} thrown in /home/fmticket/public_html/inc/genericLib.php on line 279
how to resolve it?? plz help.
Your code is calling the remote GetTicketsStringInputs function :
$client->__soapCall('GetTicketsStringInputs', ...
The Fatal error you get indicates :
Function ("GetTicketsStringInputs") is not a valid method for this service
It seems pretty clear : the method you're trying to call doesn't exist, it is not provided by the remote web-service.
So, to fix that Fatal Error, you have to stop calling that function ;-)
You should check the WSDL of your webservice : does it really export such a method ?

Categories