Some test text!
There are a few ways to open a document such as from a URL, a blob, the filesystem, or base64 data. Additionally, there are loading options to help WebViewer determine the type of the file being loaded.
When loading a document, WebViewer will use the URL to determine what type of file it is. For example http://myserver.com/myfile.docx
ends with .docx
so WebViewer will assume it's a docx file.
You can use the extension
option to explicitly tell WebViewer what type of file it is, for example, extension: 'docx'
or extension: 'png'
. Sometimes a URL might not contain an extension or you might be loading a blob so there is no URL. By default WebViewer will assume it's a PDF file but that might not be correct.
WebViewer({
path: '../../../lib',
initialDoc: 'http://<documentserver>/FileDownload?param1=foo',
extension: 'docx',
...
}, document.getElementById('viewer'))
.then(instance => {
// ...
});
You can also pass extension
as an option to the loadDocument
method like this:
WebViewer(...)
.then(instance => {
instance.UI.loadDocument('http://<documentserver>/FileDownload?param1=foo', {
extension: 'docx'
});
//...
});
The filename
option is used to indicate the name of the file when you press the download button in the viewer. However the option can also be used as a way of indicating the type of file you are opening when the URL does not end with a file extension. Note that the extension
property has precedence over filename
for determining the document type.
WebViewer({
path: '../../../lib',
initialDoc: 'http://<documentserver>/FileDownload?param1=foo',
filename: 'report.docx',
...
}, document.getElementById('viewer'))
.then(instance => {
// ...
});
/// or
WebViewer(...)
.then(instance => {
instance.UI.loadDocument('http://<documentserver>/FileDownload?param1=foo', {
filename: 'report.docx'
});
//...
});
Get the answers you need: Support
PDFTron SDK
COMPANY