0
votes

Using the iText PDF libraries (v7), does anyone have any advice on how to remove 'Document-level' JavaScripts from PDFs? I have figured out how to remove Page-Level JavaScripts, but cannot seem to figure out how to remove those at the document-level. Thank you.

1
Please show us the code of what you have tried so far. - mbuechmann

1 Answers

3
votes

I got this resolved and below is the snippet of code (C#) in case anyone else needs it:

        PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE), new PdfWriter(TARGET));
        PdfCatalog pdfCat = pdfDoc.GetCatalog();
        PdfDictionary names = pdfCat.GetPdfObject().GetAsDictionary(PdfName.Names);

        names.Remove(PdfName.JavaScript);

        pdfDoc.Close();