Replace Pages from PDF

Purpose

This API allows you to replace specific pages in an original PDF with pages from a replacement PDF, and either download the result or store it in Zoho WorkDrive.

Quick Reference

PropertyValue
MethodPOST
Request URL (Download)https://{zohoapis_domain}/pdfeditor/api/v1/pdf/pages/replace
Request URL (Store)https://{zohoapis_domain}/pdfeditor/api/v1/pdf/pages/replace/store

Body Parameters

ParameterValueMandatory/OptionalDescription
original_pdf_fileFile or StringMandatoryUpload the PDF whose pages need to be replaced from your local drive or desktop, or via a publicly accessible web URL.
replacement_pdf_fileFile or StringMandatoryUpload the PDF containing the replacement pages from your local drive or desktop, or via a publicly accessible web URL.
input_options{
  "original_page_ranges": ["1-3", "5"],
  "replacement_page_ranges": ["1-3", "2"]
}
MandatorySpecify the page ranges in the original PDF to be replaced and the page ranges from the replacement PDF to use.
output_settings{
  "name": "<document_name>"
}
Mandatory for download variantSpecify output configuration for downloadable result.
output_settings{
  "name": "<document_name>",
  "folder_id": "<folder_id>",
  "overwrite_existing_file": true | false
}
Mandatory for store variantname – Specify the name for the modified PDF document.
folder_id – Specify the ID of the WorkDrive folder in which to store the output file.
overwrite_existing_file(optional) – Set to true to overwrite an existing file with the same name in the folder.

input_options Parameters

ParameterData TypePossible ValuesDefault Value
original_page_rangesJSON Array["1-4"], ["5"]
replacement_page_rangesJSON Array["5-8"], ["2"]

output_settings (Download) Parameters

ParameterData TypePossible ValuesDefault Value
nameStringName for the modified PDF document

output_settings (Store) Parameters

ParameterData TypePossible ValuesDefault Value
nameStringName for the modified PDF document
folder_idStringID of the folder in Zoho WorkDrive to store the modified PDF
overwrite_existing_fileBooleantrue, falsefalse

Notes and Limits

  • The maximum file size allowed for each input PDF is 50 MB. Each input PDF cannot exceed 400 pages.
  • The total number of pages specified in original_page_ranges and replacement_page_ranges must be equal.
  • The store variant requires a Zoho WorkDrive account.
  • To use the download variant, an OAuth token should be generated with the following scopes: ZohoWriter.pdfEditor.ALL
  • To use the store variant, an OAuth token should be generated with the following scopes: ZohoWriter.pdfEditor.ALL, WorkDrive.files.ALL, WorkDrive.organization.ALL

Possible Errors

Refer to the following pages for the list of possible errors for this API:

Download Variant Sample Request

Copiedcurl --location --request POST "https://www.zohoapis.com/pdfeditor/api/v1/pdf/pages/replace" \
  --header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
  --form 'original_pdf_file=@"/Users/username/Documents/Original.pdf"' \
  --form 'replacement_pdf_file=@"/Users/username/Documents/Replacement.pdf"' \
  --form 'input_options=“{\”original_page_ranges\”:\”1-4\",\”replacement_page_ranges\”:\”5-8\"}"' \
  --form 'output_settings=“{\”name\”:\”ModifiedFile.pdf\"}"' 

Once the process begins, you will initially receive the 'status_url'. By invoking the 'status_url', you will be able to monitor the status of the scheduled job.

Store Variant Sample Request

Copiedcurl --location --request POST "https://www.zohoapis.com/pdfeditor/api/v1/pdf/pages/replace" \
  --header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
  --form 'original_pdf_file=@"/Users/username/Documents/Original.pdf"' \
  --form 'replacement_pdf_file=@"/Users/username/Documents/Replacement.pdf"' \
  --form 'input_options=“{\”original_page_ranges\”:\”1-4\",\”replacement_page_ranges\”:\”5-8\"}"' \
  --form 'output_settings=“{\”name\”:\”ModifiedFile.pdf\"}"' 

Once the process begins, you will initially receive the 'status_url'. By invoking the 'status_url', you will be able to monitor the status of the scheduled job.

Download Variant Sample Response

Copied{
	"status_check_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/pages/replace/job/f931a01183b33",
	"status": "inprogress"
}

Download Variant Success Response

Copied{
	"download_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/pages/replace/download/f931a01183b33",
	"status": "success"
}

Store Variant Sample Response

Copied{
	"download_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/pages/replace/download/f931a01183b33",
	"status": "success"
}

Store Variant Success Response

Copied{
	"status_check_url" : "https://pdf.zoho.com/pdfeditor/api/v1/pdf/pages/replace/job/f931a01183b33",
	"document_url" : "https://workdrive.zoho.com/file/ponazfea04477109f4681a831e7177d96bc40",
	"document_id" : "ponazfea04477109f4681a831e7177d96bc40",
	"status" : "inprogress"
}