convert Method

Summary

Converts this document to any supported format using SVG, OCR and Raster technologies.

Syntax

JavaScript Syntax
Document.prototype.convert = function(jobData) 
TypeScript Syntax
convert(jobData: DocumentConverterJobData): JQueryPromise<DocumentConvertResult>; 

Parameters

jobData

The job data.

Return Value

A Promise object that may resolve successfully to an object of type DocumentConvertResult object.

Remarks

The Convert method allows conversion the document to any of the supported formats with minimal amount of code.

The output document types can be any type of file formats supported by LEADTOOLS. but not limited to:

  • Adobe Acrobat PDF and PDF/A

  • Microsoft Office DOC/DOCX, XLS/XLSX and PPT/PPTX

  • CAD formats such as DXF, DWG and DWF

  • TIFF, JPEG, PNG, EXIF, BMP and hundred more raster image formats

  • Plain Text and RTF

  • HTML

  • ePub

The Convert method will analyze the input and output documents types and then automatically uses a combination of the LEADTOOLS Raster, SVG and OCR engines to convert the data using the best possible combination of accuracy and speed. Each conversion operation is called a Document Converter Job in the framework.

Example

This example will show how to load a PDF document and convert it to Microsoft Word DOCX.

Start with the example in Document and replace the example function call to the function below.

JavaScript Example
function convertDocumentExample() { 
   // Load a new document 
   var url = "https://demo.leadtools.com/images/pdf/leadtools.pdf"; 
   console.log("Loading document ..."); 
   var loadDocumentOptions = new lt.Documents.LoadDocumentOptions(); 
   lt.Documents.DocumentFactory.loadFromUri(url, loadDocumentOptions) 
       .done(function (doc) { 
          console.log("Loaded, converting..."); 
          // Convert this document to Microsoft Word DOCX format 
          var jobData = new lt.Documents.DocumentConverterJobData(); 
          jobData.documentFormat = lt.Documents.Writers.DocumentFormat.docx; 
          jobData.rasterImageFormat = lt.Documents.RasterImageFormat.unknown; 
          // Set document options 
          var docxOptions = new lt.Documents.Writers.DocxDocumentOptions(); 
          docxOptions.textMode = lt.Documents.Writers.DocumentTextMode.auto; 
          jobData.documentOptions = docxOptions; 
          doc.convert(jobData) 
              .done(function (result) { 
                 console.log("Converted..."); 
                 // Show it in a new tab 
                 // This is generic code, we know the result is in "document" since DOCX supports that 
                 // But this code checks if the results have been archived into a ZIP file if this 
                 // example was converting to, say SVG 
                 var resultDocument = result.document != null ? result.document.url : result.archive.url; 
                 window.open(resultDocument); 
              }) 
              .fail(function (jqXHR, statusText, errorThrown) { 
                 showServiceError(jqXHR, statusText, errorThrown); 
              }); 
       }) 
       .fail(function (jqXHR, statusText, errorThrown) { 
          showServiceError(jqXHR, statusText, errorThrown); 
       }); 
} 

Requirements

Target Platforms

Help Version 19.0.2017.10.18
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Documents Assembly