> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/conversion/conversion/convert-image-to-pdf.md).

# Convert Image to PDF on Server/Desktop

Convert various image types to PDF Documents using PDF.Convert.ToPDF method. Learn about supported formats and Advanced Imaging Module for HEIC and PSD. Integrate the module into your project with sam

Many image types can be converted to PDF Documents using [`PDF.Convert.ToPDF`](https://sdk.apryse.com/api/PDFTronSDK/cpp/classpdftron_1_1_p_d_f_1_1_convert.html#a44fadf1d0956e49c588bf66a37e1f518) method. For a complete list of formats supported, please refer to [Desktop/Server image formats](/core/learn-more/file-format-support/format-desktop.md#image) or [Web image formats](/core/learn-more/file-format-support/format-web.md#image). Some of the formats such as HEIC and PSD formats require an additional plugin called the Advanced Imaging Module. More information about the module and download links can be found in the [advanced imaging module guide](/core/learn-more/modules.md#advanced-imaging-module).

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();

// perform the conversion with no optional parameters
Convert.ToPdf(doc, filename);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
// Start with a PDFDoc (the conversion destination)
PDFDoc doc;

// perform the conversion with no optional parameters
Convert::ToPdf(doc, filename);
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();

// perform the conversion with no optional parameters
Convert.toPdf(doc, filename);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const doc = await PDFNet.PDFDoc.create();

// perform the conversion with no optional parameters
await PDFNet.Convert.toPdf(doc, filename);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
# Start with a PDFDoc (the conversion destination)
doc = PDFDoc()

# perform the conversion with no optional parameters
Convert.ToPdf(doc, filename)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
' Start with a PDFDoc (the conversion destination)
Dim doc As PDFDoc = New PDFDoc

' perform the conversion with no optional parameters
Convert.ToPdf(doc, filename)
```

{% endcode %}
{% endtab %}
{% endtabs %}

For the image formats that are exclusively supported by Advanced Imaging module, the path containing the module should be added using `PDFNet.AddResourceSearchPath` prior to invoking the `PDF.Convert.ToPDF` method. The following snippets demonstrate how this can be done.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Use a try-catch block here to catch PDFNetException
PDFNet.AddResourceSearchPath('relative/path/to/Lib/');
using (PDFDoc pdfdoc = new PDFDoc())
{
    pdftron.PDF.Convert.ToPdf(pdfdoc, input_path + input_file);
	pdfdoc.Save(output_path + output_file_name, SDFDoc.SaveOptions.e_remove_unused);
}
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
// Use a try-catch block here to catch PDFNetException
PDFNet::AddResourceSearchPath('relative/path/to/Lib/');
PDFDoc pdfdoc;
Convert::ToPdf(pdfdoc, input_path + input_file);
pdfdoc.Save(outputPath + outputFile, SDF::SDFDoc::e_linearized, NULL);
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// Use a try-catch block here to catch PDFNetException
PDFNet.addResourceSearchPath('relative/path/to/Lib/');
PDFDoc doc = new PDFDoc();
Convert.toPdf(doc, input_path + input_file);
doc.save(outputFile, SDFDoc.SaveMode.LINEARIZED, null);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const main = async () => {
	// Use a try-catch block here to catch PDFNetException
	await PDFNet.addResourceSearchPath('relative/path/to/Lib/');
	const doc = await PDFNet.PDFDoc.create();
    await PDFNet.Convert.toPdf(doc, inputPath + input_file);
	await doc.save(outputPath + output_file_name, PDFNet.SDFDoc.SaveOptions.e_linearized);
};
PDFNet.runWithCleanup(main).then(function(){ PDFNet.shutdown(); });
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
PDFNet.AddResourceSearchPath('relative/path/to/Lib/')

# Start with a PDFDoc (the conversion destination)
doc = PDFDoc()

# perform the conversion with no optional parameters
Convert.ToPdf(doc, inputFileName)
doc.Save(ouputPath + outputFileName, 0)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
// Use a try-catch block here to catch PDFNetException
PDFNet.AddResourceSearchPath('relative/path/to/Lib/')

Using pdfdoc As PDFDoc = New PDFDoc()
    pdftron.PDF.Convert.ToPdf(pdfdoc, input_path & input_file)
	pdfdoc.Save(output_path & output_file_name, SDFDoc.SaveOptions.e_remove_unused)
End Using
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Sample

For a complete working sample that uses the Advanced Imaging Module and `pdftron.PDF.Convert.ToPdf` to convert formats such as HEIC and PSD to PDF, see the [AdvancedImagingTest sample ](/core/get-started/samples.md#advancedimaging). This same code can be used to integrate the module into your application or project.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/core/conversion/conversion/convert-image-to-pdf.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
