Image to PDF in .NET

This page describes how to convert images to PDF in .NET using the cloud-based Pdfcrowd API. The API is easy to use and it takes only a few of lines of code to integrate it to your application.

Sample Output

Installation

The .NET API client library provides easy access to the Pdfcrowd API. No third-party libraries are required.

Download pdfcrowd-5.10.0-dotnet.zip, unzip it and add a reference to pdfcrowd.dll to your project.

We also offer other installation options such as NuGet or GitHub.

Authentication

The credentials to access the API are your Pdfcrowd username and the API key.

API Method Reference

Refer to the Image to PDF .NET Reference for a description of all API methods.

Code Examples

Here are a few .NET examples to get you started quickly with the API. See more examples.

using System;
using System.IO;

public class ApiTest
{
    public static void Main()
    {
        try
        {
            // create the API client instance
            pdfcrowd.ImageToPdfClient client =
                new pdfcrowd.ImageToPdfClient("your_username", "your_apikey");

            // run the conversion and write the result to a file
            client.convertFileToFile("/path/to/logo.png", "logo.pdf");
        }
        catch(pdfcrowd.Error why)
        {
            // report the error
            System.Console.Error.WriteLine("Pdfcrowd Error: " + why);

            // rethrow or handle the exception
            throw;
        }
    }
}
using System;
using System.IO;

public class ApiTest
{
    public static void Main()
    {
        try
        {
            // create the API client instance
            pdfcrowd.ImageToPdfClient client =
                new pdfcrowd.ImageToPdfClient("your_username", "your_apikey");

            // run the conversion and write the result to a file
            client.convertUrlToFile("https://pdfcrowd.com/static/images/logo.png", "logo.pdf");
        }
        catch(pdfcrowd.Error why)
        {
            // report the error
            System.Console.Error.WriteLine("Pdfcrowd Error: " + why);

            // rethrow or handle the exception
            throw;
        }
    }
}
using System;
using System.IO;

public class ApiTest
{
    public static void Main()
    {
        try
        {
            // create the API client instance
            pdfcrowd.ImageToPdfClient client =
                new pdfcrowd.ImageToPdfClient("your_username", "your_apikey");

            // run the conversion and write the result to a file
            client.convertRawDataToFile(File.ReadAllBytes("/path/to/logo.png"), "logo.pdf");
        }
        catch(pdfcrowd.Error why)
        {
            // report the error
            System.Console.Error.WriteLine("Pdfcrowd Error: " + why);

            // rethrow or handle the exception
            throw;
        }
    }
}

Troubleshooting