FPDF issue while generating pdf with images - php

require('fpdf/fpdf.php');
$pdf->AddPage("P", "A4");
$pdf->SetDisplayMode(150,'default');
$pdf->Image($imagepath,60,30,90,0,'JPG');
b_end_clean();
$pdf->Output();
('FPDF error: Not a JPEG file: https://myurl.com')

Use the image from local folder that is always best.
For this kind of error only one suggestion even though it have the extension of jpeg clearly they are not jpeg image.Me also face the same problem. Just download one jpg image from google and try this code sure it work.

Try loading it in your image editor and saving it again.
I had the same issue and happened because I only renamed the file.

Related

Codeigniter mpdf is not displaying images in live server

I have used mpdf for my codeigniter Project to print ticket with header image and it is working in my local machine while I moved source to test server, the images are not displaying in generated PDF.
Is the Permission issue? Is the invalid SSL issue?
I faced the issue once. You may use the image extension .jpg. It seems mpdf in some live server only accepts .jpeg images. Check with .jpeg images
Note: Don't just manually change the extension. The mime type should be of jpeg image(image/jpeg).

FPDF error: Unable to find "startxref" keyword

I have an app that renders PDFs with FPDF.
It was working fine and for some reasons I had to change the PDF files and now I get this error:
Unable to find "startxref" keyword
If I restore the original files, the same error happens.
How do I fix this error?
You simply have to pass a local path instead of an URI to setSourceFile().
The problems lies (sometimes) in the pdf compression.
If you are using linux you can use this to uncompress the pdf:
podofouncompress compressed.pdf decompressed.pdf
I faced this problem recently. I'm using TCPDF to merge uploaded pdf files.
Curiousilly something went wrong when importing some pdf files. Some cases, following error was printed:
Unable to find "startxref" keyword. in pdf_parser->_findXref()
So I tried to solve by reopen these pdfs files in Google Chrome and save it as PDF again. For my surprise, TCPDF worked! I still dont know how it can be but now I got a temporary solution.

dompdf image not found on live server

After several hours of searching, I am still unable to resolve this issue. I am having a problem with displaying images in a PDF file generated by dompdf library.
I have an editor tinyMCE where a user can upload images, edit his page, and see a preview in PDF format with a Button press.
One important thing here: I am using 'convert_urls : true' in tinyMCE's configuration which converts the image src = "https://mysite.com/public/images/image_name.png", necessary for the PDF library to display them.
I set the required dompdf configurations:
def("DOMPDF_ENABLE_REMOTE", true);
Here I found that it will appear after changing the attached CSS with a dompdf like:
img { display:block }
All still in vain.
Note: Everything is working fine on localhost. But on the staging server, I get a message box having a cross inside it saying "image not found" and displaying the image path. When I click on that path, the image is already there on my server. I wonder why dompdf is giving me this message?
I already faced same kind of issue. solution is very simple when Dompdf does not accept url with http format. Try with full document root.
Instead of using https://example.com/public/images/image_name.png try with /var/www/mysite/public/images/image_name.png
Use a absolute path for external css and images than live path! its worked for me also

PHP Smart Image Resizer returns broken image

I'm using the Smart Image Resizer plugin to resize images. I've been testing on a local server for a while, and now when I uploaded to the server, the image doesn't pull up.
There's really no code to post-has anyone ever had this problem, and if so, is there a solution?
Thanks!
Found the error-I had changed the code to go into a specific directory for the images. The script was removing the slashes from the image variable, so it was looking for imagesIMG_1234.JPG instead of images/IMG_1234.JPG.
Thanks!

Problem with imagecreatefrompng (PHP)

in one of my PHP projects, imagecreatefrompng complains, that the image "is not a valid PNG file".
Warning: imagecreatefrompng() [function.imagecreatefrompng]:
'/.../...png' is not a valid PNG file in /.../...php on line ...
I'm pretty sure, the file is valid, because I can open it in any program. So I was wondering what else could cause this warning.
Does anybody know the details behind imagecreatefrompng or has had a similar problem before?
Thanks for your help,
Timo
Is it a PNG image? Run file against it, or try the fileinfo functions.
Check this mime type of file you are going to upload by using below function:
mime_content_type($_FILES['product_img']['tmp_name'])
Image editors can often recognize file type by its contents, php might just try to use the file based on its mime-type. If it don't match then there's an error.

Categories