We are trying to load a pdf in the webviewer from local machine using file selector.
var config = {
path: '../ui/resources/vendor/scripts/webviewer/lib',
type: 'html5',
documentType: 'pdf',
enableAnnotations: false,
streaming: true,
documentId: 'pdf',
path: '../ui/resources/vendor/scripts/webviewer/lib/',
config: '../ui/resources/vendor/scripts/webviewer/lib/templateConfig.js',
initialDoc: '../ui/resources/docs/place_holder.pdf'
}
webviewer = new $window.PDFTron.WebViewer(config, viewerElement);
InitialDoc is provided to allow webviewer to load required assets before actual pdf is loaded.
webviewer.instance.loadLocalFile(file, {}); //file is file object from dropzone
But webviewer takes very long time to load its resources like PDFNetC.js (11.MB), PDFWorker.pexe(4MB), and a file pdfnet.res(2.8MB).
link(rel='preload' href='../ui/resources/vendor/scripts/webviewer/lib/templateConfig.js')
link(rel='preload' href='../ui/resources/vendor/scripts/webviewer/lib/html5/pdf/PDFNetC.js')
link(rel='preload' href='../ui/resources/vendor/scripts/webviewer/lib/html5/pdf/PDFNetC.js.mem')
link(rel='preload' href='../ui/resources/vendor/scripts/webviewer/lib/html5/pdf/PDFWorker.pexe')
I tried using link prefetching but it is still fetched at the time of webviewer initilalization. Is there any way to preload these file at the time of application load itself?