Some test text!

menu
search
Open MS Office filekeyboard_arrow_down

Open an MS Office document

If you have a URL for a document, you can pass it to the WebViewer constructor or loadDocument function to open it.

WebViewer({
  ...,
  initialDoc: 'https://myserver.com/myfile.docx',
}, document.getElementById('viewer'));

// or

WebViewer(...)
  .then(function(instance) {
    instance.loadDocument('https://myserver.com/myfile.docx', { filename: 'myfile.docx' });
  });

linkAdvanced office loading

Creating an Office document is the same as creating a PDF document except that we need to initialize the Office worker.

// Instantiate a Document object.
const doc = new CoreControls.Document('YOUR_FILE_ID', 'office');

CoreControls.getDefaultBackendType().then(backendType => {
  // Determine the PartRetriever that should be used. Office files and PDF files share the same partRetriever
  // If you are loading the Office file as a Blob, you need to use PartRetrievers.LocalPdfPartRetriever
  const partRetriever = new CoreControls.PartRetrievers.ExternalPdfPartRetriever('YOUR_PDF_FILE_PATH');
  const options = {
    workerTransportPromise: CoreControls.initOfficeWorkerTransports(backendType, {}, 'YOUR_LICENSE_KEY')
  };

  doc.loadAsync(partRetriever, error => {
    // The Office file has been created, you can call APIs of the Document class
  }, options)
});

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn more
close