Method ApplyToFile
ApplyToFile(Attachment, Watermark, string, PdfWatermarkOptions, CancellationToken)
Lays watermark over the pages of the PDF in source
and writes the result to outputPath.
public static PdfWatermarkResult ApplyToFile(Attachment source, Watermark watermark, string outputPath, PdfWatermarkOptions options = null, CancellationToken cancellationToken = default)
Parameters
sourceAttachmentThe PDF document.
watermarkWatermarkWhat to draw and where.
outputPathstringoptionsPdfWatermarkOptionsWhich pages, replacement, signature consent and password; defaults when
null.cancellationTokenCancellationTokenCancels the operation between pages.
Returns
- PdfWatermarkResult
The marked document and how many pages carry the mark.
Exceptions
- ArgumentNullException
sourceorwatermarkisnull.- ArgumentException
The watermark has neither text nor logo, its text is too long, or its font is not a font.
- ArgumentOutOfRangeException
A page index is outside the document.
- NotSupportedException
The document declares PDF/A-1.
- WatermarkCharactersException
The text holds characters no available font can draw.
- PdfSignatureInvalidationException
The document is signed and the options do not consent to invalidating it.
- PdfDocumentException
The source is not a readable PDF, the password is wrong, or a page could not be written.