Method SavePagesAsPngsAsync
SavePagesAsPngsAsync(string, string, PdfRenderOptions, int, string, IProgress<PdfRenderProgressEventArgs>, CancellationToken)
Renders the selected pages and writes one PNG per page.
public static Task<IReadOnlyList<string>> SavePagesAsPngsAsync(string inputPath, string outputDirectory, PdfRenderOptions options = null, int compressionLevel = 6, string fileNamePrefix = "page", IProgress<PdfRenderProgressEventArgs> progress = null, CancellationToken cancellationToken = default)
Parameters
inputPathstringPath to the source PDF.
outputDirectorystringFolder to write the per-page output files into. Created if missing.
optionsPdfRenderOptionsRender options including PageRange.
compressionLevelintPNG compression level
0-9. Default6.fileNamePrefixstringPrefix for each output filename. Files are named
{prefix}-{1-based page}.png.progressIProgress<PdfRenderProgressEventArgs>Optional progress callback fired after each saved page.
cancellationTokenCancellationTokenCancels the operation between pages.
Returns
Examples
using System;
using LMKit.Document.Pdf;
PdfRenderOptions options = new() { Zoom = 2.0, PageRange = "1-10" };
Progress<PdfRenderProgressEventArgs> progress = new(e =>
Console.WriteLine($"Saved page {e.PageIndex + 1} / {e.TotalPages} -> {e.OutputPath}"));
IReadOnlyList<string> files = PdfRenderer.SavePagesAsPngs(
"report.pdf", outputDirectory: "thumbs", options,
compressionLevel: 6, fileNamePrefix: "thumb", progress);