500 error writing to PDF using Zend - php

I have Zend working properly, and it will open a PDF, and save it, but when I try to actually use drawText to write some text over the PDF, I get this:
PHP Fatal error: Call to undefined method Zend_Pdf::drawText() in /home/whatever/test.php
I don't understand why it won't work, thoughts?

Related

Merge PDF files with PHP into single file

If i have some PDF files, each has one page and i would like to merge all files into on single file using PHP
I have read dozens of questions here about same but most of all are out of date or no longer working since for PHP version >= 7.0
One of the solutions was to use PDFMerger and here is my code
require_once ('PDFMerger.php');
use PDFMerger\PDFMerger;
$pdf = new PDFMerger;
$pdf->addPDF('books/1.pdf');
$pdf->addPDF('books/2.pdf');
$pdf->merge('download','books/merged.pdf');
but if simply gives blank page and no file is created and same to this library PDFMerger
UPDATE1! wihtout namespace use PDFMerger\PDFMerger; iam getting this error
Fatal error: Uncaught Error: Class "PDFMerger" not found in mypath\sample.php:4 Stack trace: #0 {main} thrown in mypath\sample.php on line 4
so is there any way that is still working to merger PDF files without have to care how such file are created.
NOTE! I can not use shell_exec since files are on shared hosting
After trying a lot of time , i decide to shift back to a lower PHP version 7.1 rather than 8.0 and everything goes fine though

Fatal error: Uncaught Error: Call to undefined function PDFNet_Initialize

I am trying to run PDFTron for php following the instructions.
However, when called: PDFNet::Initialize(); i'm getting an error
Fatal error: Uncaught Error: Call to undefined function PDFNet_Initialize() in .../PDFNetPHP_core.php
I assume that PDFNet_Initialize is part of extension because i can't see declaration in PDFNetPHP_core.php file
I setup exenstion PDFNetPHP.so and enable_dl = on in php.ini. Also when i run test in PDFNetWrappers/Samples/AddImageTest/PHP then it's looks ok:
PDFNet is running in demo mode.
Permission: write
Done. Result saved in addimage.pdf...<br />
when i run php -m module PDFNetPHP is on list
what am I doing wrong?
If the sample code is working on your end, it's likely that your project is unable to find the libPDFNetC.soshared library. The RunTest.sh in the AddImageTest sample sets the following environment variable:
export LD_LIBRARY_PATH=../../../PDFNetC/Lib
You might need to add the .so explicitly, or at least put the .so in a folder that PHP will load .so files from. See your PHP documentation. Please also see the following post:
https://stackoverflow.com/a/35442777/3761687

Uncaught ImagickException: UnableToOpenBlob `application/pdf': No such file or directory

I want to convert the PDF to JPG by using imagick, but after I press submit it keeps showing a fatal error: uncaught imagick error. Do you guys know if this is code problem or an imagick extension problem?
Your $_FILES['fileToUpload']['type'] stores the MIME type and you are assigning it to the variable $pdf_file and you are trying to read this with imagick. This can't work. You could var_dump($_FILES) and see if you can find the actual file in there.

Error on PHP Excel 1.8 Call to undefined function getNameFromNumber()

i just wanted to import with PHP Excel 1.8 class and then i got this error Fatal error: Call to undefined function getNameFromNumber() in includes/PHPExcel-1.8/Classes/PHPExcel/Writer/HTML.php on line 1617.
Can someone image what here the problem or better what i can do?
Thanks.
Olaf
I'd download a fresh source from https://github.com/PHPOffice/PHPExcel/releases/tag/1.8.1
or the latest files from github # https://github.com/PHPOffice/PHPExcel
as neither of those include that line/function you reference.

Opcache causes PHP Fatal error: Class '\xa0L\xdaor\x7f' not found

Every now and then an image resizing script on our site will fail with the following error:
PHP Fatal error: Class '\xa0L\xdaor\x7f' not found ... on line 4
The actual line 4 of the script in question is:
$photo = new Photo($photo_id);
I have no idea where the hex code \xa0L\xdaor\x7f in the Error log comes from. The script will run fine and it runs relatively frequently for a day or two, then it starts failing every time, with that error.
If I run opcache_reset(), the errors stop.
Anyone have any idea what might be causing this issue?
UPDATE: I got no response - so I've simply excluded this file from the opcode cache using opcache.blacklist_filename.
Sometimes my whole PHP response was a bunch of hex codes like this.
I had that when opcache.fast_shutdown="1" was set.

Categories