Method RenderPage
- Namespace
- LMKit.Document.Conversion
- Assembly
- LM-Kit.NET.dll
RenderPage(Attachment, int, double)
Renders a single page from a PDF attachment as an image.
public static ImageBuffer RenderPage(Attachment source, int pageIndex, double zoom = 2)
Parameters
sourceAttachmentThe source PDF attachment.
pageIndexintZero-based page index to render.
zoomdoubleZoom factor for rendering. Default is 2.0. Higher values produce larger, higher-resolution images.
Returns
- ImageBuffer
An ImageBuffer containing the rendered page.
Examples
using LMKit.Data;
using LMKit.Document.Pdf;
var source = new Attachment("report.pdf");
using var image = PdfToImage.RenderPage(source, 0, zoom: 3.0);
image.SaveAsPng("page1_hires.png");
Exceptions
- ArgumentNullException
Thrown when
sourceisnull.- ArgumentException
Thrown when the source attachment is not a PDF.
- ArgumentOutOfRangeException
Thrown when
pageIndexis out of range.
RenderPage(string, int, double)
Renders a single page from a PDF file as an image.
public static ImageBuffer RenderPage(string inputPath, int pageIndex, double zoom = 2)
Parameters
inputPathstringPath to the source PDF file.
pageIndexintZero-based page index to render.
zoomdoubleZoom factor for rendering. Default is 2.0. Higher values produce larger, higher-resolution images.
Returns
- ImageBuffer
An ImageBuffer containing the rendered page.
Examples
using LMKit.Document.Pdf;
using var image = PdfToImage.RenderPage("report.pdf", 0, zoom: 3.0);
image.SaveAsJpeg("page1.jpg", quality: 95);
Exceptions
- ArgumentNullException
Thrown when
inputPathisnull.- FileNotFoundException
Thrown when
inputPathdoes not exist.- ArgumentOutOfRangeException
Thrown when
pageIndexis out of range.