How to Add an Image to an Existing PDF with PDF.co API
In this tutorial, you will learn how to add an image to an existing PDF using PDF.co. This is useful when you want to place a logo, signature, badge, stamp, or watermark on a PDF. To do this, we will use the POST /v1/pdf/edit/add endpoint.
PDF.co also provides other helpful editing endpoints for different use cases. For example, you can delete text from a PDF, search and replace text in a PDF, or search and replace text with an image. Together, these endpoints make it easy to handle a wide range of PDF editing tasks.

What you will learn
In this tutorial, you will learn how to:
- add an image to an existing PDF
- position the image using X/Y coordinates
- control image width and height
- choose which pages to modify
- send the request and download the updated PDF
Endpoint used
Use the following API endpoint:
POST /v1/pdf/edit/add
This endpoint is used to update an existing PDF by adding content such as text, images, forms, links, and other PDF elements. Signatures can be added by saving the signature as an image and inserting it through the images attribute.
Before you start
You will need:
- a PDF.co API key
- a source PDF file URL
- an image URL, file token, or Data URI
- your preferred programming language or API client
PDF.co supports a source PDF via the url parameter, and the image itself can be supplied in the images[].url field as an HTTP link, file token, or datauri: value.
How image placement works
Each image object is added through the images array. For each image, you can specify:
url– the image sourcex– horizontal positiony– vertical positionwidth– output widthheight– output heightpages– target pageskeepAspectRatio– whether to preserve the image proportions
PDF.co measures coordinates from the top-left corner of the page. The first page index is 0, and "0-" means all pages. By default, keepAspectRatio is true. If you set it to false, PDF.co uses the exact width and height values you provide.
Step 1: Prepare your input PDF and image
Start with:
- the URL of the PDF you want to edit
- the URL of the image you want to place on the PDF
If your PDF is password-protected, include the password field in the request. If you want the API to return a downloadable file URL, keep inline as false or omit it. If you want the output directly in the response, set inline to true. PDF.co also supports async: true for longer-running jobs.
Step 2: Build the request body
Here is a simple request body that adds one image to the first page of a PDF:
{
"name": "output-with-logo",
"url": "https://example.com/source.pdf",
"images": [
{
"url": "https://example.com/logo.png",
"x": 270,
"y": 150,
"width": 159,
"height": 43,
"pages": "0"
}
]
}This structure follows the current PDF.co schema for adding images to an existing PDF. The images array is the recommended way to add image objects.
Step 3: Choose the right placement and size
The most important design settings are:
X and Y coordinates
These control where the image appears on the page.
Width and height
These control the displayed size of the image.
Pages
Use a page string such as:
"0"for the first page"1,2,3"for selected pages"0-"for all pages"!0"for the last page
We recommend using the PDF Inspector tool to measure coordinates more easily.
Step 4: Send the API request
Here is a basic Node.js example using fetch:
const apiKey = "YOUR_PDFCO_API_KEY";
const requestBody = {
name: "output-with-logo",
url: "https://example.com/source.pdf",
images: [
{
url: "https://example.com/logo.png",
x: 270,
y: 150,
width: 159,
height: 43,
pages: "0",
keepAspectRatio: true
}
]
};
async function addImageToPdf() {
const response = await fetch("https://api.pdf.co/v1/pdf/edit/add", {
method: "POST",
headers: {
"x-api-key": apiKey,
"Content-Type": "application/json"
},
body: JSON.stringify(requestBody)
});
const data = await response.json();
console.log(data);
}
addImageToPdf();Requests should be sent as JSON for POST /v1/pdf/edit/add, and async and inline can be used depending on how you want to receive the result.
Step 5: Download and verify the output
If the request succeeds, PDF.co returns a successful response and either:
- a downloadable output URL, or
- inline output data when
inlineis enabled
{
"url": "https://pdf-temp-files.s3.amazonaws.com/03c5c55183c74f8d94a4ec952e4e32ad/f1040-form-filled.pdf",
"pageCount": 3,
"error": false,
"status": 200,
"name": "Output",
"remainingCredits": 60822
}By default, output links are temporary and expire after a configurable period. The docs list the default expiration as 60 minutes unless changed with the expiration parameter.
Open the generated PDF and confirm that:
- the image appears on the expected page
- the size looks correct
- the placement matches your coordinates
- the image is not stretched unless intended
Common use cases
This API endpoint is useful for:
- adding a company logo to invoices
- inserting a signature into contracts
- placing approval stamps on reports
- applying badges or watermarks to PDFs
- branding generated documents automatically
Since the same endpoint can also add text, fill forms, and insert links, it works well for more advanced PDF customization workflows too.
Tips for better results
- Use PNG if you need transparency in the image itself.
- Start with one page while testing placement.
- Keep
keepAspectRatio: trueunless you intentionally want to stretch the image. - Use
"0-"only when you really want the image on every page. - If the PDF is protected, pass the
passwordfield. - For reusable assets such as logos or templates, PDF.co recommends built-in file storage instead of relying only on temporary storage links.
Troubleshooting
Image appears in the wrong place
Adjust the x and y values. Remember that the coordinate origin is the top-left corner of the page.
Image looks distorted
Make sure keepAspectRatio is enabled, or use matching width/height values that reflect the original proportions.
Nothing appears on the PDF
Check that:
- the PDF URL is accessible
- the image URL is valid
- the selected page index is correct
- the coordinates are inside the visible page area
Large job or slow response
Use async: true and check the job status with PDF.co’s Background Job Check endpoint.
Conclusion
Adding an image to an existing PDF with PDF.co is straightforward. Send your source PDF URL to POST /v1/pdf/edit/add, define the image inside the images array, set its coordinates and size, and PDF.co will generate an updated PDF for you. This makes it easy to automate logos, signatures, stamps, and branded document workflows in just one API call.
Related Tutorials



