Method SavePageAsJpegAsync
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
inputPathstringPath to the source PDF.
pageIndexintZero-based index of the page to render.
outputPathstringDestination file path.
optionsPdfRenderOptionsRender options.
qualityintJPEG quality,
1(worst) to100(best). Default90.cancellationTokenCancellationTokenCancels the operation.
Returns
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
inputPathstringPath to the source PDF.
pageIndexintZero-based index of the page to render.
outputStreamStreamWritable destination stream.
optionsPdfRenderOptionsRender options.
qualityintJPEG quality,
1-100. Default90.cancellationTokenCancellationTokenCancels the operation.
Returns
Examples
using System.IO;
using LMKit.Document.Pdf;
using FileStream output = File.Create("preview.jpg");
PdfRenderer.SavePageAsJpeg("report.pdf", pageIndex: 0, output, quality: 85);