Converts this document to any supported format using SVG, OCR and Raster technologies.
Document.prototype.convert = function(jobData)
convert(jobData: DocumentConverterJobData): JQueryPromise<DocumentConvertResult>;
jobData
The job data.
A Promise object that may resolve successfully to an object of type DocumentConvertResult object.
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.
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.
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);
});
}