Method RenderPageAsPngBytes
RenderPageAsPngBytes(string, int, PdfRenderOptions, int, CancellationToken)
Renders one page and returns it as a PNG-encoded byte array.
public static byte[] RenderPageAsPngBytes(string inputPath, int pageIndex, PdfRenderOptions options = null, int compressionLevel = 6, CancellationToken cancellationToken = default)
Parameters
inputPathstringPath to the source PDF.
pageIndexintZero-based index of the page to render.
optionsPdfRenderOptionsRender options.
compressionLevelintPNG compression level
0-9. Default6.cancellationTokenCancellationTokenCancels the operation.
Returns
- byte[]
Examples
using LMKit.Document.Pdf;
// Render and ship via HTTP, message bus, or cache without touching disk.
byte[] png = PdfRenderer.RenderPageAsPngBytes("report.pdf", pageIndex: 0);
// e.g. return File(png, "image/png");