Table of Contents

Method SavePageAsWebpAsync

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

SavePageAsWebpAsync(string, int, string, PdfRenderOptions, int, CancellationToken)

Renders one page and writes it as WebP to a file.

public static Task SavePageAsWebpAsync(string inputPath, int pageIndex, string outputPath, PdfRenderOptions options = null, int quality = 80, CancellationToken cancellationToken = default)

Parameters

inputPath string

Path to the source PDF.

pageIndex int

Zero-based index of the page to render.

outputPath string

Destination file path.

options PdfRenderOptions

Render options.

quality int

WebP quality, 1 to 100. Default 80.

cancellationToken CancellationToken

Cancels the operation.

Returns

Task

Examples

using LMKit.Document.Pdf;

// Modern web preview, ~30% smaller than JPEG at equivalent quality
PdfRenderer.SavePageAsWebp("report.pdf", pageIndex: 0, "preview.webp", quality: 80);

SavePageAsWebpAsync(string, int, Stream, PdfRenderOptions, int, CancellationToken)

Renders one page and writes it as WebP to a writable stream.

public static Task SavePageAsWebpAsync(string inputPath, int pageIndex, Stream outputStream, PdfRenderOptions options = null, int quality = 80, CancellationToken cancellationToken = default)

Parameters

inputPath string

Path to the source PDF.

pageIndex int

Zero-based index of the page to render.

outputStream Stream

Writable destination stream.

options PdfRenderOptions

Render options.

quality int

WebP quality, 1-100. Default 80.

cancellationToken CancellationToken

Cancels the operation.

Returns

Task

Examples

using System.IO;
using LMKit.Document.Pdf;

using MemoryStream output = new();
PdfRenderer.SavePageAsWebp("report.pdf", pageIndex: 0, output, quality: 80);
// output.ToArray() is now a WebP-encoded byte payload
Share