FPDF error: Unable to find "startxref" keyword - php

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.

Related

Laravel - edit pdf with FPDF with a soruce file from s3

Im working on a Laravel backend and I need to edit a PDF file allocated in a s3 bucket. When I try opening the PDF with $pdf->setSourceFile($url) I get an error saying Given stream is not seekable!
I can get the file contents using Storage::disk(ENV('FILESYSTEM'))->url($url);, and return it to the front end and that works fine, so I know the path and the permissions are correct. I would like to the content to the setSourceFile($contents) method, intead of the url. is there any way to do this?
By the way, Im using the Laravel filesystem
Edit: I have tried copying the file from s3 to the server and then open it with PDF. I couldn't reach it, but I don't think that's a good way to do it.
First of all: You cannot edit a PDF document with FPDI
As the error message says, the source stream needs to be seekable which seems not be the case with the stream wrapper you're currently using.
You should download the file and create a reader instance of it:
$pdf->setSourceFile(StreamReader::createByString($pdfString));

Why does outputting a .rtf file with PHP result in a css file error?

I have the same problem to here, but still not found an answer
Php export rtf include css files
and
http://www.zhgzw.com/524809/codep1/php-export-rtf-include-css-files.
I have PHP code that file_get_contents on an existing RTF file, does some str_replace on known phrases in the RTF document and replaces them with PHP variables. I then output it back out for the user to download the file.
I find that the problem is intermittent, but when it does happen, the error message has to be clicked multiple times. All the users on this system use Internet Explorer
The error I get is:
Problem During Load
Problems came up in the following areas during load:
Missing file: ..Windows\Temporary Internet Files\Content.IE5UXO0RLDK\style.css
Missing file: ..Windows\Temporary Internet Files\Content.IE5UXO0RLDK\css/pikaday.css

DOMPDF not formatting PDF output on live server

I have a script that generates a pdf file using DOMPDF. Locally it generates fine the way I want it to be but online, the formatting is scattered. These are the two samples
I am using PHP 5.3.x locally and online. I don't know what the problem is. Please could someone help
I also gone through the same problem. Dompdf is perfectly working on localhost but not on live server. Actually my localhost is having php-version-5 and the server is running on php7.
So here's the solution:
just use dompdf-0.8.6 on server .
This worked for me.
you can download it from here : https://github.com/dompdf/dompdf/archive/v0.8.6.zip
My fix was to use asset to access my css file on live server, for example {{asset('css/style.css')}} and that fixed my issue, while on local server, what worked was using the public_path to access the css file, example {{public_path('css/style.css')}}
I just had the same issue... the problem is using custom fonts.
Don't just try normal #fontface css embedding, use DomPDF's font loader and 'install' the font.
See link for usage for load_font.php : https://github.com/dompdf/dompdf/wiki/UnicodeHowTo#use-the-load_fontphp-script-included-with-dompdf
In my case (v 0.7.0), the problem was that I was missing some required libraries in the "lib" folder, namely:
php-font-lib
php-svg-lib
Both can be downloaded from Github, and then add 2 folders with the above names into the lib folder, where you should dump all the downloaded files.
Or, better yet, just use Composer next time! (this is a note to self)
I've same problem and solved by deleting just a single file. The file which is under 'dompdf/lib/fonts/dompdf_font_family_cache.php'
You may get this answer better

php check before pdf2swf failed copying

i have a problem. I use the pdf2swf tool to convert a pdf so that i can display it on a website.
Most of the PDF`s will be converted.
But today i found a PDF on the site that can`t be displayed because the converting failed.
it throws this message
FATAL PDF disallows copying
i know that it is because of the security settings in the pdf.
But i want to know if it is possible to check in php if the pdf has such an restriction.
So that i can show a message if the pdf can`t be converted.
thanks
EDIT: i found the solution for the problem.. the pdf`s was protected from copying so that pdf2swf didn't have the permissions to copy or manipulate the pdf.. just as information if someone else have the same problem

generating PDF using TCPDF - cannot extract embedded font

I'm using TCPDF for generating dynamic PDFs. It works fine but since I move my generator to a new server I have a problem.
I'm getting a error when I open the pdf:
Cannot extract the embedded font 'AAAAAC+FreeSerif'. Some characters may not display or print correctly.
It displays symbols instead of text. On the old server the files are successfully generated but on the new server all I see are symbols. Anyone has any idea why this would happen? (the files on both servers are the same!).
Figured it out... the problem was that the servers php.ini had:
set_magic_quotes_runtime on
Which corrupted the binary data. Turning it off solved the problem.

Categories