Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

php - FPDF error: This document (testcopy.pdf) probably uses a compression technique which is not supported by the free parser shipped with FPDI

I am running the following code and giving me this error : FPDF error: This document (testcopy.pdf) probably uses a compression technique which is not supported by the free parser shipped with FPDI. I used another pdf named test.pdf and that works fine but it is giving me error in testcopy.pdf.

I think this is parser problem. Anyone know any other parser that can be used with fpdf to avoid this error?

My code:

require('fpdf17/fpdf.php'); 
require('fpdf17/fpdi.php'); 
// initiate FPDI 
$pdf = new FPDI(); 
while (ob_get_level())
ob_end_clean();
header("Content-Encoding: None", true);
// set the sourcefile 
$pagecount = $pdf->setSourceFile('testcopy.pdf');

I want to split pdf in two pdfs and want to attach both pdfs in file attachments field.How to save pdf to server. Can it be possible with fpdf?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes, Exactly the FPDF library supports only PDF version 1.4 & lesser. So to over come from this issue use GhostScript. This script helps to change the PDF versions dynamically.

(1) Download the Ghostscript here.

(2) Install the Ghostscript and define the environment variable PATH.

(3) Then, use the below php code to change the PDF version.

shell_exec( "gswin32 -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=".$new_pdf." ".$old_pdf.""); 

(4) Now we get PDF with version 1.4 as output, then continue with FPDF.

Enjoy!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...