Flatten PDF and Executing embedded javascript

Flatten PDF and Executing embedded javascript

Forum member · Aug 9, 2021
Hello good afternoon, a couple of questions. -Is there a way to remove the javascript code from pdf documents with this library? -I am doing a test by flattening a pdf document by setting the Output property to "flatten", but I want the javascript that is executed when the document is opened to be executed by the library before being flattened, since it sets some dynamic values in the form's controls. Is there a way to do this with this library? Regards.

Re: Flatten PDF and Executing embedded javascript

Support · Aug 10, 2021
Hi, Yes, you can remove JavaScript from a document by setting DocumentJavaScript Boolean property of MergeOptions class to false. You can then set this MergeOptions while merging or appending the PDF: MergeOptions options = new MergeOptions(); options.DocumentJavaScript = false; //Load input PDF. PdfDocument pdf = new PdfDocument(@"Input PDF file path"); MergeDocument document = new MergeDocument(pdf, options); document.Draw(@"output PDF file path"); There is no option to trigger JavaScript dynamically while filling and flattening the document. Thanks, ceTe Software Support Team