Insert Images in PDF
Purpose
This API allows you to insert images into an existing PDF.
Quick Reference
| Property | Value |
|---|---|
| Method | POST |
| Request URL | https://{zohoapis_domain}/pdfeditor/api/v1/pdf/addimages |
Body Parameters
| Parameter | Value | Mandatory/Optional | Description |
|---|---|---|---|
| file | File or String | Mandatory | Upload the PDF file from your local drive or desktop. If the PDF is available via a publicly accessible web URL, you can provide the URL using the same parameter. |
| image_files | File | Mandatory | Upload the images to be inserted into the PDF. |
| output_settings | { "name": "<document_name>" } | Mandatory | Specify the name for the output PDF document. |
| input_options | [ [ { "image_rect": {"top": "25px", "left": "25px", "width": "200px", "height": "200px"}, "page_ranges": "1,2-5,7-", "odd_or_even_pages": "odd" }, ... ], ... ] | Mandatory | Control how images are inserted into the PDF. Each outer array element corresponds to an uploaded image file in the same order. image_rect – Specify the position and dimensions of the image to insert. page_ranges(optional) – Specify the pages in which the image should be inserted. odd_or_even_pages(optional) – Specify if the image should be inserted in odd or even pages only. |
input_options Parameters
| Parameter | Type | Possible Values | Default Value |
|---|---|---|---|
| image_rect | String | Specify the position and size of the image in the PDF. Provide values in pixels for top, left, width, and height. | – |
| page_ranges | String | Specify the pages in which the image needs to be inserted. Examples: 1,2,5 / 2-4,7-9 | All pages |
| odd_or_even_pages | String | odd, even | All pages |
Notes and Limits
- The maximum file size allowed for the input PDF is 50 MB.
- Up to 10 images can be inserted per request. Each image file must not exceed 10 MB. Supported formats: PNG, JPEG.
- To use this API, an OAuth token should be generated with the following scopes: ZohoWriter.pdfEditor.ALL
Possible Errors
Refer to the following pages for the list of possible errors for this API:
Sample Request
Copiedcurl --location --request POST "https://www.zohoapis.com/pdfeditor/api/v1/pdf/addimages" \
--header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
--form 'file=@"/Users/username/Documents/Sample.pdf"' \
--form ‘image_files=@"/Users/username/Documents/img.png”’ \
--form 'output_settings=“{\”name\”:\”ModifiedFile.pdf\"}"' \
--form 'input_options="{\"image_rect\":{\"top\":\"25px\",\"left\":\"25px\",\"height\":\"200px\",\"width\":\"200px\"}}"'Sample Response
Copied{
"status_check_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/addimages/job/f931a01183b33",
"status": inprogress
}Success Response
Copied{
"download_url" :"https://pdf.zoho.com/pdfeditor/api/v1/pdf/addimages/download/{jobId}",
"status": "success"
}