0

Do you know a good PDF-file sanitizer?

Free would be nice but is not a must-have.

The sanitizer should either be a .NET-Core library or a program that can be executed in Windows CMD.

It should remove Actions and JS-Code without sacrificing usability.

1 Answer 1

1

You can use Docotic.Pdf library to find and remove potentially insecure content:

For example:

  1. Remove all scripts in PdfDocument.SharedScripts collection.
  2. Check PdfDocument.GetWidgets() collection to detect form fields and annotations. You can remove or flatten them if necessary. Sample: https://github.com/BitMiracle/Docotic.Pdf.Samples/tree/master/Samples/Forms%20and%20Annotations/FlattenFormFields
  3. Check and remove interactive actions in certain objects:
    • PdfDocument.OnOpenDocument property
    • PdfDocument.OutlineRoot and its child objects. Use PdfOutlineItem.Action property.
    • Actions in controls (PdfControl.On* properties)
    • Action area (widgets of PdfActionArea type)
  4. Check and remove file attachments in PdfDocument.SharedAttachments collection and in file attachment annotations (widgets of PdfFileAttachmentAnnotation).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.