Merge/Combine multiple PDF documents into a single PDF document issue using Aspose.PDF REST API

Hi

I am using REST API to upload few pdf documents on cloud storage.
http://api.aspose.cloud/v1.1/storage/file/{*path}
This API works. Then I am tries to merge these documents into one.
http://api.aspose.cloud/v1.1/pdf/MergingResult.pdf/merge
I am getting exception 
{“Message”:“Error ‘AmazonS3 exception: The specified key does not exist.’, Path ‘[Ljava.lang.Object;@3974a835’”}

Requests are sent from google apps script. For both methods I use the same SID and appKey.

Hi Rafal,


Thanks for your inquiry. Infect, the URI used for merging documents is expecting source PDF document at root and unable to find these. So you are getting the error message. If you are uploading your source PDF document in some folder then you need to pass folder name as folder parameter. Please double check files path and fix it accordingly.

Please feel free to contact us for any further assistance.

Best Regards,

Hi Ahmad,

I tried both root folder and sub-folder.I always get an error although files were where needed. Strange is the name of the error ‘AmazonS3 …’ when I upload files on aspose cloud storage?

Hi Rafal,


Thanks for contacting support.

Can you please share the step where you are facing the problem i.e.

  • When you are uploading files ?
  • When you are merging files ?
  • When you are trying to download output file ?
  • What are you sending in the request body ?

You need to send the list of input files including paths as
we need to check how you are passing the input files list. Furthermore, your input JSON/XML (the JSON/XML you are sending in the request body) will also be helpful.

Now concerning to the query “‘AmazonS3 …’ when I upload files on aspose cloud storage?”, please note that we are using Amazon servers to host Aspose Cloud and that is why you are able to see Amazon exception. Also the exception message indicates that API is not able to find the files at specified path.

We are sorry for this inconvenience.

PS, We need more details to confirm the root cause of file not found exception.

Hi Nayyer,

The steps are:
1. I upload files to storage (files which will be merged).
2. I try to merge files (now I have workaround and append all files).
3. I download result file.

Only merge method does not work for me. Request url looks like:
http://api.aspose.com/v1.1/storage/file/merge.pdf?appSID={app_ID}&signature={my_signature}
Method that I use to merge file.
function mergePDFs(files){
if (files.length == 0 )
return;
// Upload PDFs and merge them
var options =
{
‘method’: ‘put’,
‘payload’: {
‘List’: files
}
};
var fileName = ‘merge.pdf’;
try{
var response = UrlFetchApp.fetch(sign(base_url+‘pdf/’+fileName+’/merge’, appSID, appKey), options);
Logger.log(response.getContentText());
}catch (e){
Logger.log(e);
}
return fileName;
}

Question - if merge.pdf file should exist before I call method merge?
I tried with existing file but failed too.

Hi Rafal,

Can you please also share what are you passing to files parameter of mergePDFs method and have you uploaded your input files at the root folder or some other folder? Please also share your App SID and App Key. You can send your App SID and Key via private message.

It is not required to upload merge.pdf file. This will be created when you call merge API.

Best Regards,

Hi Muhammad,

Thanks for replay.
In files parameter I’m passing:
[“test_prez.pdf”, “testdoc.pdf”, “InstallationRoche.pdf”]

I have upload input files to root folder before calling method mergePdfs.

Hi Rafal,

I get this exception when I use your account "{"Message":"Your have processed '100' documents. Your pricing plan allows only '100' documents."}". This means your trial quota is complete. You can create a new trial account if you want to continue testing.

You see key not found exception because merge API returns error but your program continues and tries to download merged file which is not present.

Please feel free to contact us in case you have further comments or questions.

Best Regards,

Hi Muhmmad,

I know that I reached the limit. But before that, I was getting error describe in the first post. Can you check my earlier requests?

Hi Rafal,

We will check your logs and get back to you.

Best Regards,

Hi Rafal,

Can you please confirm if the issue has been resolved at your end?

Best Regards,

@rafalfelczuk

Please note we have release Aspose.PDF Cloud API Version 3.0. It has a more simplified API structure and better memory management than the older version. Now, it supports JSON Web Token for a request authorization and provides Storage API methods for cloud storage operations. Please check sample cURL commands for reference and feel free to contact us for any assistance.

# First get Access Token
# Get Customer Key and Customer ID from https://dashboard.aspose.cloud/
curl -X POST "https://api.aspose.cloud/connect/token" 
-d "grant_type=client_credentials&client_id=xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxx" 
-H "Content-Type: application/x-www-form-urlencoded" 
-H "Accept: application/json"

# Upload file to (default)storage
curl -X PUT "https://api.aspose.cloud/v3.0/pdf/storage/file/Temp%2Ftest.pdf" 
-H "accept: application/json" 
-H "authorization: Bearer [Access_Token]" 
-H "Content-Type: multipart/form-data" 
-F "File"="@C:/Temp/test.pdf"

#Merge PDF documents from storage
curl -X PUT "https://api.aspose.cloud/v3.0/pdf/result1.pdf/merge" 
-H "accept: application/json" 
-H "Content-Type: application/json" 
-d "{ \"List\": [ \"4pages.pdf\",\"result.pdf\" ]}" 
-H "authorization: Bearer [Access_Token]"