Anyone know how to save a PDF as a lower PDF version programmatically using iTextSharp so that you can use certain iTextSharp features that require the PDF to be version 5 or lower?
I'm trying to merge two PDF version 7 documents together and it insists that they be version 5 or lower.
How odd. PDF versions are mostly a suggestion. PDFs must start with something like:
Where the X is 0,1,2,...
This is just a clue to the app reading the PDF. The only clue. Most "I need version X" requests I see from various customers are bogus. My fellow iText coders know this, so it strikes me as odd that iText is requesting a different version.
You're sure its iText requesting v5?
At any rate, to answer your question:
Yes, iText can change the version number of a PDF. Sadly, it can only be done when writing out a PDF, not when reading it in. You'll have to open the PDF, change its version, and save it again.
You could probably cheat. Read the PDFs into byte arrays and
pdfBytes[7] = 4;
, then pass those bytes on to aPdfReader
.Version 1 of the PDF spec is 1.0 Version 2 is 1.1 ...
So if you want pdf version 5, you need to write out "1.4", not "1.5".
If you're not comfortable poking a byte like that, you can parse the whole PDF, change the version, then write it all out again:
You'd then read it in again, and combine it as you have been.
Use this: writer.PdfVersion = PdfWriter.VERSION_1_3;
This worked for me
Looks like this is no longer valid, well, at least for me it didn't work. However, I found this and it worked for me: http://itext-general.2136553.n4.nabble.com/iTextSharp-PDF-version-td3477631.html.