macros and embedded content in pdf-to-pdf conversion

62 views
Skip to first unread message

Pavi De Alwis

unread,
Oct 7, 2014, 8:48:44 AM10/7/14
to pdfne...@googlegroups.com
If using the SDK as below to convert from pdf-to-pdf would the original document's embedded macros/files (eg. javascript) be copied to the resulting pdf too ?


pdfdoc = PDFDoc.new()
Convert.ToPdf(pdfdoc, input_file_path)
pdfdoc.Save(output_file_path, SDFDoc::E_compatibility)

Ryan

unread,
Oct 7, 2014, 2:09:55 PM10/7/14
to pdfne...@googlegroups.com
Yes, PDFNet should not be removing those sorts of entries, and they will be in the output. Compatibility mainly restricts file compression.

Pavi De Alwis

unread,
Oct 9, 2014, 2:20:30 AM10/9/14
to pdfne...@googlegroups.com
Is it possible to exclude these entries from the output? In particular the JS code ?

Support

unread,
Oct 9, 2014, 2:07:40 PM10/9/14
to pdfne...@googlegroups.com


You could run PDF/A Converter (pdftron.PDF. PDFA.PDFACompliance – as shown in PDF/A sample https://www.pdftron.com/pdfnet/samplecode.html#PDFA). PDF/A conversion will automatically remove JavaScript and embedded files (for pdf/a 1 & 2 compliance).

 

Alternatively you would need to write code that would strip away JavaScript, Embedded Files etc.

 

Obj names = doc.GetRoot().FindObj("Names")

if (names != null)

{

   names->Erase("EmbeddedFiles");

   names->Erase("JavaScript");

}

 

You would also need to traverse all actions in the doc (e.g. associated with Annotations) removing any JavaScript actions etc.

 

Depending on full list of requirements this may or may not be simple. Since PDF/A is designed to take care of these things, PDFACompliance would be the simplest to use.

Support

unread,
Oct 9, 2014, 2:11:32 PM10/9/14
to pdfne...@googlegroups.com

Btw. some of our clients who do not consider PDF/A 'secure enough' or 'good enough' for archiving  used the following approach to convert generic PDF to raster PDF (i.e. PDF images):


It is also possible to make rasterized PDF searchable by using TextExtractor and adding hidden text on top of images.
Reply all
Reply to author
Forward
0 new messages