Table of Contents

Method ApplyToFile

Namespace
LMKit.Document.Pdf
Assembly
LM-Kit.NET.dll

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

source Attachment

The PDF document.

watermark Watermark

What to draw and where.

outputPath string
options PdfWatermarkOptions

Which pages, replacement, signature consent and password; defaults when null.

cancellationToken CancellationToken

Cancels the operation between pages.

Returns

PdfWatermarkResult

The marked document and how many pages carry the mark.

Exceptions

ArgumentNullException

source or watermark is null.

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.

Share