Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert PDF ver 1.7 to ver 1.6 by using php only

I am working on API which gives me PDF(ver 1.7) in response and my project is using zend pdf library which doesn't support parsing of PDF version 1.7 .

So i have decided to convert PDF version to make compatible with Zend Pdf.

Is there any way to convert pdf version to older version using php?

Thanks

like image 470
Gulshan Maurya Avatar asked Mar 11 '16 10:03

Gulshan Maurya


1 Answers

You can do this in Ghostscript. I have been looking for a solution for the similar problem and after trying so many different scripts the most reliable one is ghost script.

  $command = "gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.6  -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=pdf_out.pfg pdf_in.pdf";
  $p_result =  exec($command); 

these are the options for your out pdf;

-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images)

-dPDFSETTINGS=/ebook (low quality, 150 dpi images)

-dPDFSETTINGS=/printer (high quality, 300 dpi images)

-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)

-dPDFSETTINGS=/default (almost identical to /screen)

The problem is this : You have got a steak and you want it to convert another type of steak, so the other scripts are taking your steak, turning in to minced meat and than making steak again. So the outcome will never be exactly same. For example if your pdf has got a text says "click here" and takes you to www.example.com , after converting the version of pdf, the "click here" link is being removed.

like image 66
Display name Avatar answered Nov 10 '22 03:11

Display name