PdfParser issue in PHP - 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

Related

Read old excel xls using php

I try to read excel file format slx by php code i use SimpleXLS class but i get error :
Fatal error: Uncaught Error: Class 'SimpleXLS' not found in C:\laragon\www\xls\examples\01-basic_usage.php:5
Stack trace:
#0 {main}
thrown in C:\laragon\www\xls\examples\01-basic_usage.php on line 5
Here is the page code, which is the original code for the page :
<?php /** #noinspection ForgottenDebugOutputInspection */
require_once __DIR__ . '/SimpleXLS.php';
echo '<h1>Parse books.xsl</h1><pre>';
if ( $xls = SimpleXLS::parse('books.xls') ) {
print_r( $xls->rows() );
} else {
echo SimpleXLS::parseError();
}
echo '<pre>';
when i use SimpleXLSX class with file xlsx it's work but xls not work
https://github.com/shuchkin/simplexls
any help?

I can't solve this Fatal error problem with pdfMerger

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.

Is it possible to extract RDFa from html page using EasyRdf?

I'm trying to extract RDFa data from an html page using EasyRDF. But it doesn't seem to work. E.g., I've tried:
$work = new EasyRdf_Graph("http://example.com/");
$work->load();
echo $work;
$title = $work->primaryTopic();
echo "Title: ".$title->get('dc:title')."\n";
This is the error I get:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'EasyRdf_Http_Client only supports the 'http' and 'https' schemes.'

Uncaught SoapFault

I am getting the following error when trying to create a new SoapClient.
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://api.mindbodyonline.com/0_5/ClassService.asmx?wsdl' : failed to load external entity "https://api.mindbodyonline.com/0_5/ClassService.asmx?wsdl" in C:\xampp\htdocs\Work\Ice\default\soaptest.php:8 Stack trace: #0 C:\xampp\htdocs\Work\Ice\default\soaptest.php(8): SoapClient->SoapClient('https://api.min...') #1 {main} thrown in C:\xampp\htdocs\Work\Ice\default\soaptest.php on line 8
what would cause the WSDL to not load?
Enable openssl in your php.ini you load the WSDL over https this is only working when the openssl module is enabled.
Not sure if this might be the case with you but if you are using the PHP classes provided on the Minbody API on Github, note that they have recently updated them. I had the same problem with classService.php. If you are using classService.php, update the constructor function to the following (same will apply to other services):
function __construct($debug = false)
{
$endpointUrl = "https://" . GetApiHostname() . "/0_5/ClassService.asmx";
$wsdlUrl = $endpointUrl . "?wsdl";
$this->debug = $debug;
$option = array();
if ($debug)
{
$option = array('trace'=>1);
}
$this->client = new soapclient($wsdlUrl, $option);
$this->client->__setLocation($endpointUrl);
}

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.

Categories