Image Converter
The Sheetize Image Converter for .NET allows developers to convert documents to and from various image formats, making it ideal for applications involving document viewing, image archiving, and generating image-based content.
Key Features
PDF to Image Conversion
Convert PDF documents to image formats (e.g., PNG, JPEG), perfect for generating previews or for image-based document processing.
Image to PDF Conversion
Transform image files into PDF documents, suitable for combining images into a single file or creating PDF reports from image-based data.
Detailed Guide
Converting PDF to Image
To convert a PDF document to an image format:
- Initialize the Converter: Create an instance of
ImageConverter
. - Set Conversion Options: Use
PdfToImageOptions
to specify the desired image format, resolution, and output quality. - Define Input and Output Paths: Set paths for the input PDF and output image files.
- Execute the Conversion: Call the
Process
method to complete the conversion.
Example: Convert PDF to PNG Image
// Step 1: Initialize the Image Converter
var converter = new ImageConverter();
// Step 2: Configure options for PDF to Image conversion
var options = new PdfToImageOptions(ImageType.Png);
options.Resolution = 300; // Set resolution to 300 DPI
options.Quality = 90; // Set image quality to 90%
// Step 3: Set file paths
options.AddInput(new FileDataSource("input.pdf"));
options.AddOutput(new FileDataSource("output.png"));
// Step 4: Run the conversion
converter.Process(options);
Available Options for PDF to Image Conversion
- ImageType: Specify the desired image format (
Png
,Jpeg
,Bmp
, etc.). - Resolution: Set the resolution (DPI) for the output image.
- Quality: Define the quality level (for JPEG output).
Converting Image to PDF
To convert an image to a PDF:
- Initialize the Converter: Create an instance of
ImageConverter
. - Set Conversion Options: Use
ImageToPdfOptions
to customize the layout and appearance of the resulting PDF. - Specify Paths: Set input image and output PDF file paths.
- Execute the Conversion: Call the
Process
method to generate the PDF.
Example: Convert PNG Image to PDF
// Step 1: Initialize the Image Converter
var converter = new ImageConverter();
// Step 2: Configure options for Image to PDF conversion
var options = new ImageToPdfOptions();
options.PageLayoutOption = PageLayoutOption.Centered;
options.ImageScalingOption = ImageScalingOption.FitToPage;
// Step 3: Set file paths
options.AddInput(new FileDataSource("input.png"));
options.AddOutput(new FileDataSource("output.pdf"));
// Step 4: Execute the conversion
converter.Process(options);
Additional Options for Image to PDF Conversion
- PageLayoutOption: Define how the image is placed on the PDF page (e.g.,
Centered
,TopLeft
). - ImageScalingOption: Control how the image fits within the PDF page (e.g.,
FitToPage
,Stretch
).
This converter is versatile for developers needing to work with image-based document content, whether generating high-quality document previews or bundling multiple images into PDFs for easy distribution.