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.
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, andpdfPrintBackground. A newpdfKeepLinksoption could be added to control whether links are retained.For example, as TOC metadata:
The default value should be
trueto preserve the current behavior.Docfx's PDF merge functionality uses PdfPig. PdfPig already exposes the
PdfDocumentBuilder.AddPageOptions.KeepAnnotationsoptions: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: