Skip to product menu
Skip to main content

Combine PDFs

Purpose

Using this API, you will be able to combine PDF documents.

HTTP Request URL

https://{zohoapis_domain}/writer/api/v1/documents/pdf/combine

Body Parameters

ParameterData TypeDescription
Mandatory Parameters

files

or

urls
 

File

or

String
 

Method of providing the input file depending on its location.

 

files - If the input files are from your local drive or desktop.

 

urls - If the input files are publicly accessible Web URLs. You will have to pass them as a comma separated list.

 

Note:

  • Up to 5 input pdf files can be combined at once. A minimum of 2 files must be provided to perform the combine operation.
  • Total file size limit for the input files will be 10 MB.
Optional Parameters
output_settings{
name: <filename>
}
Specify a unique name for the merged or combined output file. By default, the output file name will be "output.pdf".
input_options{
   1: {   
             page_ranges  : "3,5,7" ,    
        },
    2 :  {
           page_ranges : "1-3, 5"
       }
}

It is possible to combine selected pages or a specific range pages in a document.

 

To combine selectedpages, you will have to pass the respective page numbers with comma separated (say 3,5,7,etc.,).

 

To combine a specific range of pages, you will have to pass the page ranges with a hypen (say 1-3).

team_idString
 
If the user has multiple WorkDrive teams and wants to use a specific team for credit usage, use this parameter. By default, the user's preferred team will be used for credit calculation.

Note:

  • This API will be available only for users who have Zoho WorkDrive Account.
  • To use this API, an OAuth token should be generated with the following scopes; ZohoWriter.documentEditor.ALL,ZohoWriter.merge.ALL,WorkDrive.organization.ALL
  • This API is subject to throttle limits. For details on the applicable rate limits, please refer to this help link.

Sample Request

Copiedcurl --location --request POST "https://www.zohoapis.com/writer/api/v1/documents/pdf/combine" \
  --header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
  --form 'output_settings="{\"name\":\"CombinedFile.pdf\"}"' \ 
  --form 'files=@"/Users/username/Documents/Sample1.pdf"' \ 
  --form 'files=@"/Users/username/Documents/Sample2.pdf"' \ 
  --form 'input_options="{\"1\":{\"page_ranges\":\"3,5,6\"},\"2\":{\"page_ranges\":\"1-3,6\"}}"' 
Copiedfileobj1 = invokeurl
[
	url :"https://www.africau.edu/images/default/sample.pdf"
	type :GET
];
info fileobj1;
fileobj2 = invokeurl
[
	url :"https://icseindia.org/document/sample.pdf"
	type :GET
];
info fileobj2;
fileobj2.setParamName("files");
output_settings = Map();
output_settings.put("name", "combined-document"); // name for the combined document
input_options = Map();
document_1 = Map();
document_1.put("page_ranges", "1");   //page_ranges for document 1
document_2 = Map();
document_2.put("page_ranges", "1,5");   //page_ranges for document 2
input_options.put("1", document_1);
input_options.put("2", document_2);
paramList = list();
paramList.add({"paramName":"files","content":fileobj1});
paramList.add({"paramName":"files1","content":fileobj2});
paramList.add({"paramName":"output_settings","content":output_settings.toString(),"Content-Type":"application/json","stringPart":"true"});
paramList.add({"paramName":"input_options","content":input_options.toString(),"Content-Type":"application/json","stringPart":"true"});
combinepdf_response = invokeurl
[
	url :"https://www.zohoapis.com/writer/api/v1/documents/pdf/combine"
	type :POST
	files:paramList
	connection:”<connection_name>”
];
info combinepdf_response;

Once the process is initiated, you will be provided with the 'status_url' initially. By invoking the 'status_url', you will be able to check the status of the scheduled job. 

Sample Response

Copied{
    "status_url": "https://writer.zoho.com/writer/api/v1/documents/pdf/combine/job/f931a01183b33
}

Job completion status can be checked using the 'status' key. Once the status is changed to 'completed', you will be provided with a 'download_url'. Using which, you can download the combined file as bytes.

Copied{
"status": "completed/inprogress/failed"
"download_url":"https://writer.zoho.com/writer/api/v1/documents/pdf/combine/download/e8447fe5069440a15042f5a92d4f29404e26d9b43cd324d8816e46ba869c45ffa4ea798cc574a41281f257cc0c7a74cb937398933f9307f03e018ac4fb9d19640be41a77fc506a6ff4fef7632f12e6744ef0780637a3bcb047204642170ada40"
}