Encryption
Version 6.1.0
In this article
This article describes the particularities of how to generate encrypted PDF files with MigraDoc. For general information about writing encrypted PDF files, see PDFsharp encryption page.
Dealing with encryption in MigraDoc
Encryption is handled in PDFsharp’s PdfDocument. Therefore, you have to render the final Document before configuring encryption on the resulting PdfDocument:
// Render the document.
var pdfRenderer = new PdfDocumentRenderer { Document = document };
pdfRenderer.RenderDocument();
var pdfDocument = pdfRenderer.PdfDocument;
To configure encryption for pdfDocument now, see PDFsharp encryption page.
// Save the PdfDocument:
pdfRenderer.Save(filename);