Table of Contents

Method GetRenderedPageSize

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

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

inputPath string

Path to the source PDF.

pageIndex int

Zero-based page index.

options PdfRenderOptions

Render options (only Zoom, Orientation, and Password affect the result).

Returns

(int Width, int Height)

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

input Stream

Readable stream containing the PDF.

pageIndex int

Zero-based page index.

options PdfRenderOptions

Render options (only Zoom, Orientation, and Password affect the result).

leaveOpen bool

When true (default), the caller keeps ownership of the stream.

Returns

(int Width, int Height)

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

data byte[]

PDF file content as a byte array.

pageIndex int

Zero-based page index.

options PdfRenderOptions

Render options (only Zoom, Orientation, and Password affect the result).

Returns

(int Width, int Height)

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.");
Share