Insert Images in PDF

Purpose

Using this API, you will be able to insert images to a PDF document.

HTTP Request URL

https://{zohoapis_domain}/pdfeditor/api/v1/pdf/addimages

Body Parameters

ParameterData TypeDescription
Mandatory Parameters

file


 

File

or

String


 

PDF file in which the images needs to be inserted can be uploaded using one of the following methods:

  • Upload the input PDF file from your local drive or desktop.
  • If the PDF file is a publicly accessible Web URL, you can pass it via the same parameter.

Note: Maximum file size limit for the input PDF will be 50 MB.

image_files


 

Files

or

String


 

Image files that needs to be inserted in the provided PDF can be uploaded using one of the following methods:

  • Upload the image files from your local drive or desktop.
  • If the image files are publicly accessible Web URLs, you can pass them as a comma-separated list via the same parameter.

Note:

  • Upto 10 images can be inserted in a PDF file.
  • Total file size limit for an image will be 10 MB.
  • Supported image file types: png and jpeg.
output_settings

 

"name": "<new document name>"

}

 

Specify the name for the modified 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"
    },
    {
      "image_rect":
        {
          "top":"500px",
          "left":"250px",
          "width":"200px",
          "height":"200px"
        },
    }
  ],
  [ {}, {}, .. ],
..
]

Using this param, you can control how the images needs to be inserted in the PDF document.

image_rect -> Specify the position (where the image needs to be inserted) and the dimensions of the image that needs to be inserted in the PDF.

page_ranges (optional) -> Specify in which pages the images needs to be inserted.

You can pass the values in following ways based on the requirement;

1,2,5 > To insert images in selected pages.

2-4,7-9 > To insert images to a specific range of pages.

-5 > To insert images from first page to specified page.

7- > To insert images from specified page to last page.

odd_or_even_pages(optional) -> Specify if the images needs to inserted in odd or even pages.

Note: To use this API, an OAuth token should be generated with the following scopes: ZohoWriter.pdfEditor.ALL

input_options

ParameterTypePossible ValuesDefault Value
image_rectstring{
    'top':'25px',
    'left':'25px',
    'width':'200px',
    'height':'200px'
}
 
page_rangesstring0,2-5,7-If this key is not passed or empty, images will get inserted in all pages by default.
odd_or_even_pagesstringodd/evenIf this key is not passed or empty, images will get inserted in all pages by default.

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"
}