macros and embedded content in pdf-to-pdf conversion

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 =
      Convert.ToPdf(pdfdoc, input_file_path)
      pdfdoc.Save(output_file_path, SDFDoc::E_compatibility)

Yes, PDFNet should not be removing those sorts of entries, and they will be in the output. Compatibility mainly restricts file compression.

Is it possible to exclude these entries from the output? In particular the JS code ?

You could run PDF/A Converter (pdftron.PDF. PDFA.PDFACompliance – as shown in PDF/A sample 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)





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.

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.