Convert PDF ver 1.7 to ver 1.6 by using php only
Asked Answered
C

2

6

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

Callie answered 11/3, 2016 at 10:36 Comment(8)
Are you sure zend pdf supports 1.6? The major break was between 1.4 and 1.5, everything since then were details.Slippy
I am currently using "ghostscript server software" right now to convert to version 1.6. And that works as i need but that is not preferred way.Callie
Are you sure that the 1.6 is important? Or might be relevant whether cross reference tables or cross reference streams and object streams are used?Slippy
cross reference is used in PDF which is causing problem to Zend_PDF. Not sure about 1.6 but 1.4 is working.Callie
If the problem are the cross reference streams and object streams, they are allowed since 1.5 but are not required. Thus, you should probably ask for a tool transforming those streams to cross reference tables and normal objects.Slippy
so is there any php tool for this?Callie
I don't know. I'm not into PHP, merely into PDF, so I argued along that knowledge. If I knew such a tool, I'd have answered accordingly. If on the other hand you could use a Java application, I could point you to one.Slippy
@Slippy Thank you for your time. I have non php solution but purpose of posting this question here is to get some php tool or way to do this.Callie
B
1

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.

Battles answered 8/9, 2016 at 19:45 Comment(7)
Thanks for your answer but i am already using Ghostscript. I want PHP solution not third party software dependent solution.Callie
hi gulshan, I have been doing PDF operations online for last 4 years, used every single piece of code and software and php is not enough to edit pdf. you will have to use a third party library. so your question was "Is there any way to convert pdf version to older version using php?" , so the answer is NO.Battles
Ok, is there any library available to parse PDF 1.7 and perform operations like merge pdf pages?Callie
yes there are few options, one is free and the other one is commercial (200 euros). So i assume you will go with the free option. it is called PDFtk. the script is on shell command example is "pdftk file1.pdf file2.pdf file3.pdf cat output newfile.pdf"Battles
Is it PHP based? if it is PHP based i can use commercial.Callie
it is a linux software where you run a shell script to run the commands. as i said earlier php it self is not enough for pdf documents.Battles
my bad :( but i will be looking forward in future. Many thanks for your valuable time. I am giving you bounty as you have given much attention.Callie
F
0

You shouldn't rely on ZendPdf. It is an abandoned and unmaintained project and the ZendPdf homepage suggests, that you should use TCPDF instead.

Freida answered 18/7, 2017 at 7:51 Comment(1)
Is there any example of TCPDF that uses merge pdf functionality for PDF 1.7?Callie

© 2022 - 2024 — McMap. All rights reserved.