Skip to main content
Version: Version 1.7

Convert an image to a PDF document

Convert one or more TIFF, JPEG, BMP, GIF, PNG, JBIG2, or JPEG2000 images into an output PDF document. Content for long-term archiving and document accessibility can be added during the conversion process. The formatting and conformance level of the output PDF document can be adjusted to suit the requirements of the document workflow.

Quick start

Download the full sample now in C# and Java.

Interested in C or other language samples? Let us know on the contact page and we'll add it to our samples backlog.

Steps to convert a document

  1. Reading the input image
  2. Selecting a conversion profile
  3. Adjusting the conversion profile
  4. Converting the image to a PDF document
  5. Full example

Before you begin

Reading the input image

First you need to read the image you want to convert. To do this, load the input image from the file system into a read-only image Document. This Document can then later be passed to the Converter.

// Open image document
using var inStr = File.OpenRead(inPath);
using var inDoc = Document.Open(inStr);

Selecting a conversion profile

You start the image conversion process by creating a conversion Profile object to determine the conversion profile. The Profile object defines the parameters that are applied to the conversion process.

tip

For more information about image to PDF conversion profiles, see Conversion profiles.

This example uses the Default profile, which is designed for document workflows that need to convert images to PDF documents, but do not have long-term archiving or accessibility requirements.

// Create the profile that defines the conversion parameters.
// The Default profile converts images to PDF documents.

var profile = new Profiles.Default();

Adjusting the conversion profile

If the images must be added to the PDF document in a specific way (for example, if the image size should be preserved or a specific page orientation should be used), this can be achieved by changing the properties of the conversion profile. The PDF conformance level may also be adjusted in this way.

For more information about image to PDF conversion profiles, see Conversion profiles.

Converting the image to a PDF document

After creating the Profile object and adjusting for any workflow-specific properties, the final step is to instantiate a Converter object and call its Convert method. The output PDF document is created at the specified path.

// Create output stream
using var outStr = File.Create(outPath);

// Convert the image to a PDF document
using var outDoc = new Converter().Convert(inDoc, outStr, profile);

Full example

// Open image document
using var inStr = File.OpenRead(inPath);
using var inDoc = Document.Open(inStr);

// Create the profile that defines the conversion parameters.
// The Default profile converts images to PDF documents.
var profile = new Profiles.Default();

// Optionally, the profile's parameters can be changed according to the
// requirements of your conversion process.

// Create output stream
using var outStr = File.Create(outPath);

// Convert the image to a PDF document
using var outDoc = new Converter().Convert(inDoc, outStr, profile);