Pdf Version 1.4
How can I convert pdf files from version 1.1 to 1.4 (or higher)?
Actually I need some sort of command line tool for batch converting or some API to be able to convert dynamically severall documents.
Depending on the exact feature subset of PDF-1.7 used in your files, even (Free) Ghostscript may be able to do a good quality transformation to PDF-1.2, PDF-1.3 or PDF-1.4 file format version. This is the Ghostscript command line to create a PDF-1.4.
user285677user285677- PDF 1.4 = Acrobat 5.0 – Actually, introduced with Illustrator 9, The main difference to concern Scribus users is PDF 1.4, has both transparency and alpha transparency capabilites, which make a major difference in where a PDF with these features can be printed.
- Manual Version 1.4 June 2011. NOTE: Depending on the version of the STA-800D/STA-1000D amplifier, the LCD display may or may not light when power is first applied. Even if the LCD display does not light when power is applied, if the.
2 Answers
Pdf 1.1 is forward compatible with pdf 1.4. Everything in pdf 1.1 will work with pdf 1.4 - it's guaranteed by the spec. Let's assume that you've got some justifiable reason why this is not good enough for you (let's assume, for example, that you have a non-spec compliant tool that consumes PDF and explodes on any file version less that 1.4).
We can focus on the main syntactic differences between versions.
All PDF files have a header somewhere in the first 1024 bytes. In most cases, it's the very first line, but that's not guaranteed (I'm looking at you GhostScript!). The header looks like this in PDF 1.1:
in PDF 1.4, it looks like this:
So in theory, all you need is a tool that will look in the first 1024 bytes for a file for '%PDF-1.1' and change it to '%PDF-1.4'. You could use sed, perl, etc to do something like that for you. You could write it in C and you would be tempted to do something like this:
which will work in most sane cases. It will not work if the file starts, for example, with 0 bytes, which would serve as null terminators in the block of data.
A better choice (really) would be to cobble up a simple state machine to find %PDF-1. by reading 1 byte at a time until it either finds it or passes 1017 (1024 less the header length), then reads the next byte, if it's a '1', it seeks back a byte and writes a '4'.
The only other thing you would need to worry about is that PDF 1.4 suggests that the document catalog should contain a Version key with the file version. Since this is defined as optional in the spec, you are safe to ignore it.
So this will solve your problem. I do not, however, believe that you should need to do this. Really.
You should take some time to read part of the PDF spec, specifically section I.2 about version numbers and compatibility.