1

Hoping for an Open Source or reasonable commercially licensed product that can be used from a Java Servlet running on JBoss AS5 from a Redhat 5.x Linux environment to convert PDF's from 1.5 to 1.4 version.

Or any tricks I can use to modify the PDF 1.5 content to move back to a 1.4 compatible format. anything really.

I have a PDF that I'm about to return as a response to the servlet. But it's in 1.5 format and this won't display in some of our client's adobe5 ancient version. But it does display in 1.4, so I need a way to convert it if it's even possible.

Any other work-arounds? Ideas? i'm all ears!

Let me know if you can help me out!

Nicholas DiPiazza
  • 10,029
  • 11
  • 83
  • 152
  • Which 1.5-ish features do your PDFs use? If Adobe Reader 5 doesn't open the files at all, that sounds like your files are making use of cross reference streams (instead of tables) and maybe even object streams. In that case the PDFs will have to be internally reworked in which case some constructs like integrated signatures break. Or is the problem merely the version tag or something similar? In that case the change might be executed in a less invasive manner. – mkl Mar 20 '13 at 08:03
  • I tried the version tag, didn't work. so yep we are using the 1.5-ish features... however adobe live cycle creates the pdf so i'm not sure what makes it up – Nicholas DiPiazza Mar 20 '13 at 08:05
  • 1
    Please provide a sample PDF from your work flow. If a newer Adobe LC version creates the PDFs, it is very likely that cross reference and object streams are used. – mkl Mar 20 '13 at 08:12
  • they are i just confirmed that. does that mean there may be a solution that can help me? or does that mean there won't be one? – Nicholas DiPiazza Mar 20 '13 at 08:13
  • flattened PDF read only files are all we need. – Nicholas DiPiazza Mar 20 '13 at 16:59

2 Answers2

2

If the problem actually is not (merely) the version number claimed by the document but instead the fundamentally changed document file structure allowed since PDF 1.5 (and, therefore, since Adobe Reader 6) --- i.e. cross reference streams (instead of cross reference tables) and object streams --- the following code using the iText library might help you:

PdfReader reader = new PdfReader(SOURCE);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(TARGET), '4');
stamper.close();

This actually parses the original PDF file and creates a new PDF file from the parsed PDF objects. By default, though, iText does not use cross reference or object streams. Therefore, the new PDF file does contain neither.

The '4' instructs iText to proclaim the version 1.4 in the header of the target file.

Depending on PDF size and available resources you might want to use a different PdfReader constructor not reading all of the source PDF into memory at once but instead only when needed.

PS: I use the current iText 5.4.x version. iText is available either for free subject to the conditions of the AGPL or commercially.

PPS: If you want instead to force iText to use cross reference and object streams, you have to call stamper.setFullCompression() after constructing stamper.

mkl
  • 90,588
  • 15
  • 125
  • 265
  • Does that mean we can use the iText commercially without paying anyone? – Nicholas DiPiazza Mar 20 '13 at 16:50
  • looks commercial license. i've asked them for a quote. we'll see. – Nicholas DiPiazza Mar 20 '13 at 17:00
  • 2
    I just recognized that the answer referred to by @jimueller's answer to your question does look quite like my answer... I merely cannot find the method `stamper.setPdfVersion` used there in `PdfStamper` anymore, only in `PdfWriter` and internal iText classes derived from `PdfWriter`... – mkl Mar 20 '13 at 17:02
  • You can use iText commercially for free as long as you do it according to the AGPL. If you separate the service uncompressing the PDFs appropriately, that is feasible, isn't it? – mkl Mar 20 '13 at 17:10
  • Hmm... AGPL is not a license i'm too familiar with. what are the restrictions if you don't mind me asking? I know i can google it but it'd be better to get it from someone with some experience with it. – Nicholas DiPiazza Mar 20 '13 at 17:21
  • @mkl I am not a lawyer, but AFAIK a web service is considered "dynamic linking" hence it should also be published as AGPL with all its clients. See here: http://stackoverflow.com/questions/3701011/web-services-and-open-source-libraries-licensing – yms Mar 20 '13 at 17:28
  • If in doubt, ask the iText people themselves. just like @yms i have to admit that i am not a lawyer, let alone one specialized on licensing matters. – mkl Mar 20 '13 at 19:31
  • 1
    @yms they can offer that conversion as a Webapplication to their clients with ancient adobe readers for manual conversion, no need to make it a Web service. – mkl Mar 20 '13 at 19:42
  • @NicholasDiPiazza Have you had the opportunity to test whether a PDF transformed with the code above is viewable be those clients' PDF viewers? – mkl Mar 21 '13 at 10:28
  • No I haven't yet. i inquired about the iText commercial license... i got some HUGE email back from dude at itext that makes it sound like "yeah right." I'm going to write off iText as a "no go" unfortunately. looks like i'm going to try to use ghostscript ps2pdf14 – Nicholas DiPiazza Mar 21 '13 at 17:02
  • It's in the actual environment now and yep - definitely works. No problems. thanks so much!!! – Nicholas DiPiazza Mar 29 '13 at 15:33
  • @NicholasDiPiazza Grats! ;) (But maybe your company should try and persuade those clients to update their PDF readers... they are soooooo far behind current state-of-the-art...) – mkl Mar 29 '13 at 16:07
  • This conversion is being done for the 2 months while we move adobe5 to adobe11 globally. so this is only a temporary solution which makes it make senes! – Nicholas DiPiazza Apr 01 '13 at 16:30
1

Modifying the header pdf version won't do as you can also find overriding version info in the Document catalog

quoted from pdf file format specs

The header in the first line of a PDF file specifies a PDF version (see 7.5.2, "File Header"). Starting with PDF 1.4, a PDF version can also be specified in the Version entry of the document catalogue, essentially updating the version associated with the file by overriding the one specified in the file header (see 7.7.2, "Document Catalog"). As described in the following paragraphs, the conforming product’s behaviour upon opening or saving a document depends on comparing the PDF file's version with the PDF version that the conforming product supports.

user18428
  • 1,216
  • 11
  • 17