Extract Pages and Store

Purpose

Using this API, you will be able to extract specific pages from a PDF document.

HTTP Request URL

https://{zohoapis_domain}/pdfeditor/api/v1/pdf/pages/extract/store

Body Parameters

ParameterData TypeDescription
Mandatory Parameters

file


 

File

or

String


 

Upload the PDF file in which the pages needs to be extracted 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.

input_options



    {
      "page_ranges": ["0,2-5,7-"],
      "format": "<pdf/jpeg/png>",
    }
   
 

page_ranges -> Specify the pages that needs to be extracted from the uploaded PDF.

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

1,2,5 > To extract selected pages.

2-4,7-9 > To extract a specific range of pages.

-5 > To extract from the first page to a specified page.

7- > To extract from a specified page to the last page.

format -> Specify the format in which the extracted pages need to be stored.

output_settings

"name": "<new document name>",

"folder_id": "<folder_id>" ,    

"single_pdf": "<true/false>",    

"overwrite_existing_file": "<true/false>"

}

 

Pass the values for 'name' and 'folder_id' via this parameter as JSON.

name -> Specify the name for the modified PDF document.

folder_id -> Specify the ID of the folder in which you would like to store the modified PDF document.

single_pdf (optional) -> Specify the type in which you would like to combine the extracted pages. If this key is not passed, the extracted pages will be combined as a single PDF by default.

false - If you would like to have each page as a separate PDF document.

true - If you would like to combine all the extracted pages as a single PDF document.

overwrite_existing_file (optional) -> Use this param if you wish to replace an existing file stored in Zoho WorkDrive with the modified PDF document.

Note:

  • This API will only be available for users who have a Zoho WorkDrive account.
  • To use this API, an OAuth token should be generated with the following scopes: ZohoWriter.pdfEditor.ALL,WorkDrive.files.ALL,WorkDrive.organization.ALL

Sample Request

Copiedcurl --location --request POST "https://www.zohoapis.com/pdfeditor/api/v1/pdf/pages/extract/store" \
  --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.

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

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",
	 "document_url" : "https://{workdrive_service_url}/file/{resource_id}",
	 "document_id" : "{resource_id}"
	},
	.
	.
	.
	{
	 "name" : "file_name_n",
	 "document_url" : "https://{workdrive_service_url}/file/{resource_id}",
	 "document_id" : "{resource_id}"
	}
	]
	"status": "success"
}

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