Skip to content

[Feature Request] Add an option to omit link annotations from generated PDF files #11130

Description

@guuskuiper

PDFs generated by Docfx contain link annotations. Some digital-signing tools fail to sign the resulting PDF correctly. In our case, applying a second signature can also invalidate the first signature.

Removing all link annotations before signing allows the same PDF to be signed successfully. Removing bookmarks alone does not resolve the problem.

It would be useful if Docfx supported an option to omit link annotations from generated PDF output. This would provide a workaround for signing tools that cannot process the annotations emitted during PDF generation and merging.

The current PDF documentation provides options such as pdfFileName, pdfTocPage, pdfCoverPage, and pdfPrintBackground. A new pdfKeepLinks option could be added to control whether links are retained.

For example, as TOC metadata:

pdf: true
pdfKeepLinks: false

The default value should be true to preserve the current behavior.

Docfx's PDF merge functionality uses PdfPig. PdfPig already exposes the PdfDocumentBuilder.AddPageOptions.KeepAnnotations options:

var options = new PdfDocumentBuilder.AddPageOptions
{
    KeepAnnotations = pdfKeepLinks
};

builder.AddPage(document, pageNumber, options);

Docfx could pass the proposed pdfKeepLinks value to this existing PdfPig option, avoiding the need for a separate PDF post-processing step.

This is a workaround. A proper solution to this problem would require either:

  • A fix in the PdfPig package. The latest version does currently not solve this problem.
  • Switch to a different PDF merging package. I did test PDFSharp and that did succeed in merging and signing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions