---
title: "Add image to PDF: Insert image or create new page | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/editor/add-image-to-pdf/"
md_url: "https://www.nutrient.io/guides/dotnet/editor/add-image-to-pdf.md"
last_updated: "2026-05-15T19:10:04.984Z"
description: "Learn how to add images to PDFs and other images using C#. Follow our step-by-step guide for efficient C# image editing techniques."
---

# Add an image to a PDF using C#

### PDF

[PDF](https://www.nutrient.io/guides/dotnet/editor/add-image-to-pdf.md)

### Image

[Image](https://www.nutrient.io/guides/dotnet/editor/add-image-to-image.md)

An image can be added to a PDF file in two ways:

- By [drawing](#drawing-an-image-to-a-pdf-page) an image to a specified PDF page.

- By [adding](#adding-an-image-as-a-separate-pdf-page) an image as a separate PDF page.

## Drawing an image to a PDF page

To draw an image as a part of a PDF page, follow the steps outlined below.

1. Load the PDF file.

2. Add the specified image as a resource by using one of the following methods:

- [`AddJpegImageFromFile`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~AddJpegImageFromFile.html), which is where you specify the path to the image.

- [`AddJpegImageFromStream`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~AddJpegImageFromStream.html), with which you specify the stream containing an image.

3. Set the origin of the coordinate system with the [`SetOrigin`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SetOrigin.html) method. This method requires the `PdfOrigin` enumeration, which accepts the following values:
   - `PdfOriginTopLeft`
   - `PdfOriginTopRight`
   - `PdfOriginBottomRight`
   - `PdfOriginBottomLeft`

4. Set the dimension units with the [`SetMeasurementUnit`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SetMeasurementUnit.html) method, which uses the `PdfMeasurementUnit` enumeration as an argument. It allows the following values:
   - `PdfMeasurementUnitCentimeter`
   - `PdfMeasurementUnitMillimeter`
   - `PdfMeasurementUnitInch`
   - `PdfMeasurementUnitPoint`
   - `PdfMeasurementUnitUndefined`

5. Select the PDF page you want to add the image to with the [`SelectPage`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SelectPage.html) method.

6. Draw the image to the PDF page with the [`DrawImage`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~DrawImage.html) method. This method requires the following parameters:

- `ImageResName` — Image resource name.

- `DstX` — Horizontal distance of the bottom-left corner of the PDF file, where the image is drawn.

- `DstY` — Vertical distance of the bottom-left corner of the PDF file, where the image is drawn.

- `Width` — Width of the drawn image resource.

- `Height` — Height of the drawn image resource.

To add an image to the first and the last PDF page, use the following code:

### C#

```csharp

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");
// Add an image as a resource.
string image = gdpicturePDF.AddJpegImageFromFile(@"C:\temp\source.jpg");
// Set the origin of the coordinate system to the top-left corner.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
// Set the measurement units to millimeters.
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
var width = gdpicturePDF.GetPageWidth();
// Select the first page of the PDF file.
gdpicturePDF.SelectPage(1);
// Draw the image to the top-center of the PDF page.
gdpicturePDF.DrawImage(image, (width - 10) / 2, 15, 10, 10);
// Select the last page of the PDF file.
gdpicturePDF.SelectPage(gdpicturePDF.GetPageCount());
// Change the origin of the coordinate system to the bottom-left corner.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft);
// Draw the image to the bottom-center of the PDF page.
gdpicturePDF.DrawImage(image, (width - 10) / 2, 5, 10, 10);
gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");

```

### VB.NET

```vb

Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    gdpicturePDF.LoadFromFile("C:\temp\source.pdf")
    ' Add an image as a resource.
    Dim image As String = gdpicturePDF.AddJpegImageFromFile("C:\temp\source.jpg")
    ' Set the origin of the coordinate system to the top-left corner.
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    ' Set the measurement units to millimeters.
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
    Dim width = gdpicturePDF.GetPageWidth()
    ' Select the first page of the PDF file.
    gdpicturePDF.SelectPage(1)
    ' Draw the image to the top-center of the PDF page.
    gdpicturePDF.DrawImage(image, (width - 10) / 2, 15, 10, 10)
    ' Select the last page of the PDF file.
    gdpicturePDF.SelectPage(gdpicturePDF.GetPageCount())
    ' Change the origin of the coordinate system to the bottom-left corner.
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)
    ' Draw the image to the bottom-center of the PDF page.
    gdpicturePDF.DrawImage(image, (width - 10) / 2, 5, 10, 10)
    gdpicturePDF.SaveToFile("C:\temp\output.pdf")
End Using

```

#### Used methods

- [`AddImageFromGdPictureImage`]

- [`DrawImage`]

- [`GetPageWidth`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~GetPageWidth.html)

- [`LoadFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~LoadFromFile.html)

- [`SaveToFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SaveToFile.html)

- [`SelectPage`]

- [`SetMeasurementUnit`]

- [`SetOrigin`]

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## Adding an image as a separate PDF page

To add an image as a separate PDF page at the end of a file, follow the steps outlined below.

1. Load the PDF file.

2. Create a GdPicture image from the specified file using the [`CreateGdPictureImageFromFile`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html) method.

3. Insert the image as a separate page at the end of the file with one of the following methods:

- [`AddImageFromGdPictureImage`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~AddImageFromGdPictureImage.html)

- [`AddImageFromBitmap`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~AddImageFromBitmap.html)

Both methods, [`AddImageFromGdPictureImage`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~AddImageFromGdPictureImage.html) and [`AddImageFromBitmap`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~AddImageFromBitmap.html), require the following parameters:

- Either `imageID` or `bitmap`.

- `ImageMask` — Indicates whether the inserted image is treated as an image mask (or stencil mask). The recommended default value is `false`. Applicable only for 1 bit per pixel images.

- `DrawImage` — Set this parameter to `true`, which adds a new page, and the image is drawn on its whole surface.

To add an image as a separate page, use the following code:

### C#

```csharp

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");
// Add an image as a resource.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");
// Add the image to a new page.
gdpicturePDF.AddImageFromGdPictureImage(imageID, false, true);
gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");
gdpictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    gdpicturePDF.LoadFromFile("C:\temp\source.pdf")
    ' Add an image as a resource.
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg")
    ' Add the image to a new page.
    gdpicturePDF.AddImageFromGdPictureImage(imageID, False, True)
    gdpicturePDF.SaveToFile("C:\temp\output.pdf")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using
End Using

```

#### Used methods

- [`AddImageFromGdPictureImage`]

- [`CreateGdPictureImageFromFile`]

- [`LoadFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~LoadFromFile.html)

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`SaveToFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPicturePDF~SaveToFile.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)
---

## Related pages

- [Add an image to another image using C#](/guides/dotnet/editor/add-image-to-image.md)
- [Add a page to a PDF or a TIFF image in C# .NET](/guides/dotnet/editor/add-page.md)
- [Add text to an image using C#](/guides/dotnet/editor/add-text-to-image.md)
- [Modify EXIF metadata using C#](/guides/dotnet/editor/metadata-exif.md)
- [PDF and image editor in C#.NET](/guides/dotnet/editor.md)
- [Attach a file to a PDF in C#](/guides/dotnet/editor/attach-a-file.md)
- [Add text to PDFs in C#](/guides/dotnet/editor/add-text-to-pdf.md)
- [Merge PDFs in C#](/guides/dotnet/editor/merge-or-combine.md)
- [Edit IPTC metadata using C#](/guides/dotnet/editor/metadata-iptc.md)
- [Read and edit PDF XMP metadata using C#](/guides/dotnet/editor/metadata-xmp.md)
- [Read and edit PDF page label metadata using C#](/guides/dotnet/editor/metadata-pdf-page-label.md)
- [Split PDF pages into multiple pages in C#](/guides/dotnet/editor/split.md)
- [Add watermarks to PDFs and images in C#](/guides/dotnet/editor/watermark.md)

