Method ApplyAsync
ApplyAsync(Attachment, Watermark, PdfWatermarkOptions, CancellationToken)
Lays watermark over the pages of the PDF in source.
public static Task<PdfWatermarkResult> ApplyAsync(Attachment source, Watermark watermark, PdfWatermarkOptions options = null, CancellationToken cancellationToken = default)
Parameters
sourceAttachmentThe PDF document.
watermarkWatermarkWhat to draw and where.
optionsPdfWatermarkOptionsWhich pages, replacement, signature consent and password; defaults when
null.cancellationTokenCancellationTokenCancels the operation between pages.
Returns
- Task<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.