Method SavePageAsWebpAsync
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
inputPathstringPath to the source PDF.
pageIndexintZero-based index of the page to render.
outputPathstringDestination file path.
optionsPdfRenderOptionsRender options.
qualityintWebP quality,
1to100. Default80.cancellationTokenCancellationTokenCancels the operation.
Returns
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
inputPathstringPath to the source PDF.
pageIndexintZero-based index of the page to render.
outputStreamStreamWritable destination stream.
optionsPdfRenderOptionsRender options.
qualityintWebP quality,
1-100. Default80.cancellationTokenCancellationTokenCancels the operation.
Returns
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