Extract Pages from PDF
Purpose
This API allows you to extract specific pages from a PDF and either download the result or store it in Zoho WorkDrive.
Quick Reference
| Property | Value |
|---|---|
| Method | POST |
| Request URL (Download) | https://{zohoapis_domain}/pdfeditor/api/v1/pdf/pages/extract |
| Request URL (Store) | https://{zohoapis_domain}/pdfeditor/api/v1/pdf/pages/extract/store |
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. |
| input_options | { "page_ranges": ["1,2,5", "2-4,7-9"], "format": "pdf" | "jpeg" | "png" } | Mandatory | Specify the pages to extract and the output format for extracted pages. |
| output_settings | { "name": "<document_name>", "single_pdf": true | false } | Mandatory for download variant | Specify output configuration for downloadable result. |
| output_settings | { "name": "<document_name>", "folder_id": "<folder_id>", "single_pdf": true | false, "overwrite_existing_file": true | false } | Mandatory for store variant | name – Specify the name for the output file. folder_id – Specify the ID of the WorkDrive folder in which to store the output file. single_pdf(optional) – Set to true to combine all extracted pages into a single PDF. Set to false to save each page as a separate file. Defaults to true. overwrite_existing_file(optional) – Set to true to overwrite an existing file with the same name in the folder. |
input_options Parameters
| Parameter | Data Type | Possible Values | Default Value |
|---|---|---|---|
| page_ranges | JSON Array | ["1,2,5"], ["2-4,7-9"], ["-5"], ["7-"] | – |
| format | String | pdf, jpeg, png | – |
output_settings (Download) Parameters
| Parameter | Data Type | Possible Values | Default Value |
|---|---|---|---|
| name | String | Name for the output file | – |
| single_pdf | Boolean | true, false | true |
output_settings (Store) Parameters
| Parameter | Data Type | Possible Values | Default Value |
|---|---|---|---|
| name | String | Name for the output file | – |
| folder_id | String | ID of the folder in Zoho WorkDrive to store the output file | – |
| single_pdf | Boolean | true, false | true |
| overwrite_existing_file | Boolean | true, false | false |
Notes and Limits
- The maximum file size allowed for the input PDF is 50 MB, and the PDF cannot exceed 400 pages.
- The store variant requires a Zoho WorkDrive account.
- page_ranges supports selected pages, ranges, first-to-page, and page-to-end values.
- single_pdf defaults to true if not passed.
- 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 Sample Request
Copiedcurl --location --request POST "https://www.zohoapis.com/pdfeditor/api/v1/pdf/pages/extract" \
--header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
--form 'files=@"/Users/username/Documents/Sample.pdf"' \
--form 'input_options=“{\”page_ranges\”:\”1,2\"}"' \
--form 'output_settings=“{\”name\”:\”ModifiedFile.pdf\",\”single_pdf\”:\”true\"}"'
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 Sample Request
Copiedcurl --location --request POST "https://www.zohoapis.com/pdfeditor/api/v1/pdf/pages/extract" \
--header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
--form 'files=@"/Users/username/Documents/Sample.pdf"' \
--form 'input_options=“{\”page_ranges\”:\”1,2\"}"' \
--form 'output_settings=“{\”name\”:\”ModifiedFile.pdf\",\”single_pdf\”:\”true\"}"'
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 Sample Response
Copied{
"status_check_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/pages/extract/job/f931a01183b33",
"status": inprogress
}
Download Success Response
Copied{
"download_url" :"https://pdf.zoho.com/pdfeditor/api/v1/pdf/pages/extract/download/{JobId}",
"status": "success"
}Store Sample Response
Copied{
"download_url" :"https://pdf.zoho.com/pdfeditor/api/v1/pdf/pages/extract/download/{JobId}",
"status": "success"
}Store Partial Structure Response
Copied{
"documents" : [
{
"name" : "file_name_1",
"document_url" : "https://{workdrive_service_url}/file/{resource_id}",
"document_id" : "{resource_id}"
},
{
"name" : "file_name_2",
"document_url" : "https://{workdrive_service_url}/file/{resource_id}",
"document_id" : "{resource_id}"
},
{
"name" : "file_name_3",
"error_code" : "R9006",
"error_message" : "Unable to upload document to WorkDrive"
},
.
.
.
{
"name" : "file_name_n",
"document_url" : "https://{workdrive_service_url}/file/{resource_id}",
"document_id" : "{resource_id}"
}
]
"status_check_url" : "https://pdf.zoho.com/pdfeditor/api/v1/pdf/pages/extract/job/{jobId}",
"status" : inprogress
}Store Success Response
Copied{
"documents" : [
{
"name" : "file_name_1",
"document_url" : "https://{workdrive_service_url}/file/{resource_id}",
"document_id" : "{resource_id}"
},
{
"name" : "file_name_2",
"document_url" : "https://{workdrive_service_url}/file/{resource_id}",
"document_id" : "{resource_id}"
},
{
"name" : "file_name_3",
"error_code" : "R9006",
"error_message" : "Unable to upload document to WorkDrive"
},
.
.
.
{
"name" : "file_name_n",
"document_url" : "https://{workdrive_service_url}/file/{resource_id}",
"document_id" : "{resource_id}"
}
]
"status_check_url" : "https://pdf.zoho.com/pdfeditor/api/v1/pdf/pages/extract/job/{jobId}",
"status": "partial success"
}