Leadtools.Documents Namespace > DocumentFactory Object : DownloadDocument Method |
function Leadtools.Documents.DocumentFactory.downloadDocument( documentId , uri , position , dataSize )
Parameter | Type | Description |
---|---|---|
documentId | string | The document ID to download. This can be null. |
uri | string | The URL to the resource to download. This can be null. |
position | int | Current byte position. |
dataSize | int | Maximum data chunk size to download. |
Type | Description |
---|---|
jQueryApi.IDeferred | A Promise object that may resolve succesfully to an array of bytes. |
DownloadDocument allows downloading any document output file from a conversion result. If the value of documentId is not null, then the data of the main file of the document will be downloaded. This is the content of the original PDF or DOCX file if the document was uploaded from a PDF file or DOCX file respectively.
In this mode, the entire document can be downloaded in one call by passing 0 for the dataSize parameter. The data can also be downloaded in chunks by using the dataSize and position parameters. For a document in the cache, the length of the original file is set in the Document.FileLength property.
If the value of uri is not null, then the data of this URL will be downloaded. The URL most me an item on the documents service cache, for example, the result of a convert operation through Document.Convert. The result of this method is a DocumentConvertResult object that contains the URL, MIME Type and length of any output files. The URL can be passed to DownloadDocument to obtain the file data as a byte array. Similar to the discussion above, passing 0 for dataSize result in downloading the whole of the file in one call. Otherwise, ConvertItem.Length can be used to download the data in chunks.
For an example, refer to UploadDocument.