Frameworks
Integrations
Mendix
SharePoint
Default UI
Modular UI
AnnotationManager
Annotation Types
Customize
Version 11
Version 10
v10.12
v10.11
v10.10
v10.9
v10.8
v10.7
v10.6
v10.5
v10.4
v10.3
v10.2
v10.1
v10.0
Version 8
v8.12
v8.11
v8.10
v8.9
v8.8
v8.7
v8.6
v8.5
v8.4
v8.3
v8.2
v8.1
v8.0
Version 7
Version 6
v6.3
v6.2
v6.1
v6.0
Version 5
Version 4
Version 3
Version 2
WebViewer Server
WebViewer BIM
There are numerous methods of saving a document depending on what you are looking to do. This may involve triggering a download on the client to save to the local file system or saving the file data to the server. Regardless of the outcome, WebViewer has APIs to support the features you would like to implement.
The simplest way to retrieve document data is by getting the Document object and using the getFileData
API.
Below is a basic example of setting up WebViewer and using the getFileData
API to retrieve document data by clicking a custom header button.
The getFileData
API also takes in an options object to change some of the characteristics of the saved file data. The most commonly used options are:
xfdfString
: A string containing the XFDF annotation data to include in the downloaded file. This can be retrieved from the exportAnnotations
function on AnnotationManager
.downloadType
: A string value for the output format. Possible values are:'pdf'
: Get file data in a PDF format. This is the default option and can be used for any loaded document.'office'
: If an office file is loaded (docx, xlsx, pptx, etc) then get file data in the current document format.flags
: optional enum flags for how to save the PDF data. They can be found in Core.SaveOptions
and the most commonly used values are:REMOVE_UNUSED
: Remove unused PDF data during save. This is the default option.LINEARIZED
: Optimize data for speed and remove unused data.After getting a Blob object, there are a variety of ways to save it from the browser:
You can use the APIs found in the browser to open the document and allow downloading it.
You can also use a library like FileSaver.js to help facilitate a direct download.
You can save the binary data of the document to your remote server using the browser fetch API. This is not recommended for larger files. Saving the annotation XFDF string is recommended.
You can save the binary data of the document to your remote server using the browser XMLHttpRequest API. This is not recommended for larger files. Saving the annotation XFDF string is recommended.
The UI
namespace provides a downloadPdf
API with similar options to getFileData
.
Getting document data without a viewer is possible and very similar to the method mentioned in this guide.
Get document data without a viewer
To get document data as a blob without a viewer.
Loading and saving annotations
To import/load and export/save annotations with a PDF document.
Saving a document in Salesforce
To save a PDF through WebViewer in a Salesforce deployment.
Sending data with XMLHttpRequest
Mozilla documentation on sending binary data using XMLHttpRequest.
Sending data with fetch
Google documentation on working with fetch API.
Sending post request with jQuery
jQuery documentation on using post requests.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales