Table of Contents

Method RenderToFiles

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

RenderToFiles(string, string, string, double, string, string)

Renders multiple pages from a PDF file and saves them as image files.

public static List<string> RenderToFiles(string inputPath, string outputDirectory, string pageRange = null, double zoom = 2, string format = "png", string fileNamePrefix = null)

Parameters

inputPath string

Path to the source PDF file.

outputDirectory string

Directory where rendered images will be saved. Created if it does not exist.

pageRange string

A 1-based page range string (e.g., "1-5, 7"). Null, empty, or "*" renders all pages.

zoom double

Zoom factor for rendering. Default is 2.0.

format string

Output image format: "png", "jpg", or "bmp". Default is "png".

fileNamePrefix string

Optional prefix for output file names. Defaults to the input file name without extension. Files are named {prefix}_page{N}.{format} where N is the 1-based page number.

Returns

List<string>

A list of full paths to the created image files.

Examples

using LMKit.Document.Pdf;

var files = PdfToImage.RenderToFiles(
    "presentation.pdf",
    "output/slides",
    pageRange: "1-10",
    zoom: 2.0,
    format: "jpg");

foreach (string path in files)
{
    Console.WriteLine($"Created: {path}");
}

Exceptions

ArgumentNullException

Thrown when inputPath or outputDirectory is null.

FileNotFoundException

Thrown when inputPath does not exist.

RenderToFiles(Attachment, string, string, double, string, string)

Renders multiple pages from a PDF attachment and saves them as image files.

public static List<string> RenderToFiles(Attachment source, string outputDirectory, string pageRange = null, double zoom = 2, string format = "png", string fileNamePrefix = null)

Parameters

source Attachment

The source PDF attachment.

outputDirectory string

Directory where rendered images will be saved. Created if it does not exist.

pageRange string

A 1-based page range string. Null, empty, or "*" renders all pages.

zoom double

Zoom factor for rendering. Default is 2.0.

format string

Output image format: "png", "jpg", or "bmp". Default is "png".

fileNamePrefix string

Optional prefix for output file names. Defaults to the source file name without extension.

Returns

List<string>

A list of full paths to the created image files.

Examples

using LMKit.Data;
using LMKit.Document.Conversion;

var source = new Attachment("slides.pdf");
var files = PdfToImage.RenderToFiles(
    source,
    "output/slides",
    pageRange: "1-3",
    format: "png",
    fileNamePrefix: "deck");

Console.WriteLine($"Rendered {files.Count} pages.");

Exceptions

ArgumentNullException

Thrown when source or outputDirectory is null.

ArgumentException

Thrown when the source attachment is not a PDF.