Method GetRenderedPageSize
GetRenderedPageSize(string, int, PdfRenderOptions)
Returns the pixel dimensions the renderer would produce for the given page and options, without actually rendering.
public static (int Width, int Height) GetRenderedPageSize(string inputPath, int pageIndex, PdfRenderOptions options = null)
Parameters
inputPathstringPath to the source PDF.
pageIndexintZero-based page index.
optionsPdfRenderOptionsRender options (only Zoom, Orientation, and Password affect the result).
Returns
Examples
using LMKit.Document.Pdf;
PdfRenderOptions options = new() { Zoom = 2.0 };
(int w, int h) = PdfRenderer.GetRenderedPageSize("report.pdf", pageIndex: 0, options);
Console.WriteLine($"Page 1 would render to {w}x{h} pixels at {options.Zoom}x zoom.");
GetRenderedPageSize(Stream, int, PdfRenderOptions, bool)
Returns the pixel dimensions the renderer would produce for the given page and options, without actually rendering.
public static (int Width, int Height) GetRenderedPageSize(Stream input, int pageIndex, PdfRenderOptions options = null, bool leaveOpen = true)
Parameters
inputStreamReadable stream containing the PDF.
pageIndexintZero-based page index.
optionsPdfRenderOptionsRender options (only Zoom, Orientation, and Password affect the result).
leaveOpenboolWhen true (default), the caller keeps ownership of the stream.
Returns
Examples
using System.IO;
using LMKit.Document.Pdf;
using FileStream fs = File.OpenRead("report.pdf");
(int w, int h) = PdfRenderer.GetRenderedPageSize(fs, pageIndex: 0);
Console.WriteLine($"Page 1 renders to {w}x{h} pixels at default zoom.");
GetRenderedPageSize(byte[], int, PdfRenderOptions)
Returns the pixel dimensions the renderer would produce for the given page and options, without actually rendering.
public static (int Width, int Height) GetRenderedPageSize(byte[] data, int pageIndex, PdfRenderOptions options = null)
Parameters
databyte[]PDF file content as a byte array.
pageIndexintZero-based page index.
optionsPdfRenderOptionsRender options (only Zoom, Orientation, and Password affect the result).
Returns
Examples
using System.IO;
using LMKit.Document.Pdf;
byte[] bytes = File.ReadAllBytes("report.pdf");
(int w, int h) = PdfRenderer.GetRenderedPageSize(bytes, pageIndex: 0);
Console.WriteLine($"Page 1 renders to {w}x{h} pixels.");