Table of Contents

Method SavePageAsJpegAsync

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

SavePageAsJpegAsync(string, int, string, PdfRenderOptions, int, CancellationToken)

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

public static Task SavePageAsJpegAsync(string inputPath, int pageIndex, string outputPath, PdfRenderOptions options = null, int quality = 90, 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

JPEG quality, 1 (worst) to 100 (best). Default 90.

cancellationToken CancellationToken

Cancels the operation.

Returns

Task

Examples

using LMKit.Document.Pdf;

// Quick high-quality preview
PdfRenderer.SavePageAsJpeg("report.pdf", pageIndex: 0, "preview.jpg", quality: 92);

// Compact thumbnail at lower zoom and quality
PdfRenderOptions options = new() { Zoom = 1.0 };
PdfRenderer.SavePageAsJpeg("report.pdf", 0, "thumb.jpg", options, quality: 65);

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

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

public static Task SavePageAsJpegAsync(string inputPath, int pageIndex, Stream outputStream, PdfRenderOptions options = null, int quality = 90, 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

JPEG quality, 1-100. Default 90.

cancellationToken CancellationToken

Cancels the operation.

Returns

Task

Examples

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

using FileStream output = File.Create("preview.jpg");
PdfRenderer.SavePageAsJpeg("report.pdf", pageIndex: 0, output, quality: 85);
Share