How to save with e_remove_unused but preserve the PDF version number already in the file?

14 views
Skip to first unread message

Ryan

unread,
Apr 25, 2017, 12:57:40 PM4/25/17
to pdfne...@googlegroups.com
Question:

I am trying to save a PDF-File with version 1.5 by calling PDFDoc.Save(SaveOptions) with SDFDoc.SaveOptions.e_remove_unused as parameter.


I realized that the version of the PDF-File has changed to 1.7 but I need it in 1.5.


Saving the PDF-File without any SaveOptions doesn’t change the version of the PDF, but I need PDFNet to remove unused objects.


PDFDoc doc = new PDFDoc(inputFilePath);
byte[] docAsByteArray = doc.Save(SDFDoc.SaveOptions.e_remove_unused);
File.WriteAllBytes(outputFilePath,docAsByteArray);


Answer:


You can drop down a level in the API, and use SDFDoc.Save, which allows you to enter your own version number. A PDFDoc ISA SDFDoc so this is fine.


byte[] docAsByteArray = doc.GetSDFDoc().Save(SDFDoc.SaveOptions.e_remove_unused, "%PDF-1.5");

Please see these posts for more info.

https://groups.google.com/d/msg/pdfnet-sdk/IawXWQLZH_I/jZA3CIOsD04J

https://groups.google.com/d/msg/pdfnet-sdk/h_zoSC-2HOo/D1kFzcHhDQAJ

Reply all
Reply to author
Forward
0 new messages