Using Cloud API for conversion to XOD

53 views
Skip to first unread message

Support

unread,
Nov 5, 2012, 8:38:23 PM11/5/12
to pdfnet-w...@googlegroups.com

Q:

We have been facing some errors from PDFTron Cloud api.

If we try to access this link after a while, the file download works without any problem. This problem is evident with files larger than 2 MB.

Steps to Upload , Shared and Download File :

 

Note: CustomWebClient is class derived from WebClient to set request time out.

 

1.         Upload File:

   apiEndPoint = “https://api.pdftron.com/v1

CustomWebClient client = new CustomWebClient(1000 * 60 * 5);

client.Credentials = new NetworkCredential(apiKey, apiSecretKey);

string requestUrl = apiEndPoint + "/document";

response = client.UploadFile(requestUrl, "POST", documentPath);

 

2.       Share File:

shareUrl = "https://api.pdftron.com/v1/document/{0}/share";

client = new CustomWebClient(1000 * 60 * 5);

client.Credentials = new NetworkCredential(apiKey, apiSecretKey);

response = client.UploadData(string.Format(shareUrl, documentId), new Byte[] { });

 

 

3.  Download file:

       downloadXODUrl = "https://api.pdftron.com/v1/download/{0}?type=xod";

       client = new CustomWebClient(1000 * 60 * 5);

client.Credentials = new NetworkCredential(apiKey, apiSecretKey);

response = client.DownloadData(string.Format(downloadXODUrl, shareId));

 

Here it throws exception : The remote server returned an error: (403) Forbidden.
 
  
------
A:

You are seeing this error because the xod file has not finished converting yet.

Documents larger in size may take longer to convert.

 

You can use a GET request on https://api.pdftron.com/v1/document/{0}/ to get the status of the documents.

So you might want to poll the document status until you get xodState is ready, then make the download request.

 

Alternatively, you could try providing a URL that the Cloud API notify after conversion is done.

http://www.pdftron.com/pdfnet/cloud/advanced.html

 

 

As for providing the XOD document to Cloud API:

First make a request to https://api.pdftron.com/v1/download/{0}?type=xod&redirect=false

You'll get back an xml response that contains the direct URL to the xod file.

You can pass that URL into initialDoc.

Reply all
Reply to author
Forward
0 new messages