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
Related
I checked some similar questions here, but i didn't got an answer, solving my problem.
I use TCPDF to generate a PDF with PHP.
When I use the $pdf->Output($file_total, 'I');
it's all good and the file is shown in Browser.
If I use the save to localhost option $pdf->Output($file_total, 'F'); I get this error:
"failed to open stream: Permission denied in /opt/lampp/htdocs/project/tcpdf_min/include/tcpdf_static.php on line 1821"
"TCPDF ERROR: Unable to create output file"
The Path I set for saving the PDF file is: "/opt/lampp/htdocs/project/files/2021"
What am I doing wrong? is my path wrong?
The forced saving $pdf->Output($file_total, 'D'); works just fine, so i must doing something wrong with the path on mac...
please help!
Thanks
In comments we both went through possible reasons such as finding an absolute rather than relative location and checking out folder permissions for non admin process as that was also suspected. Thus between us the conclusion was:-
use address as
"localhost:8080/projects..."
and ensure target folder was set to permissions
"read/write" for all users
For production use the write access needs to be trimmed back to the process and admin, not all users.
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));
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.
I'm using yii with html2pdf version 4.03 for downloading pdf documents in my project. The pdf documents consist of tables with many rows because they are reports. In my localhost, the download is fine. But when I do that in remote server, it can't be downloaded.
I used Firefox to download it. When I downloaded it, it prompted an alert message saying that I can't download because the source file cannot be read. When I force to download it (by pressing refresh button in firefox's download list), the pdf file is there. When I tried to open it, it says that the file is corrupted.
If I delete a few rows, it can be downloaded just fine. Strangely, even if I didn't delete the rows, they are still in one page. So the problem shouldn't be about "table row that doesn't fit in one page", should it?
What could be the problem? Could anyone help me with this please?
UPDATES
when I print it in browser instead of downloading, firefox prompts an error like below:
Content Encoding Error
The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.
Please contact the website owners to inform them of this problem.
Still don't know how to solve this though...
Save the generated pdf, open it in text editor, and see what error message is there.
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.