Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
The DocumentConverter component included in XtremeDocumentStudio Java is a powerful component to convert your documents from one file format to another. It provides easy to use APIs to convert documents in your applications. It also provides extensive options for customizing the output being generated based on input and output format specific features.
Input formats: PDF, DOC, DOCX, BMP, GIF, JPG, PNG, TIF, JP2.
Output formats: PDF, TXT, BMP, GIF, JPG, PNG, TIF, JP2.
Copy all the jar files and folders included in the bin/jdk16 directory of the product in your application’s classpath to include document conversion capability.
For all the scenarios listed below you can use the below code snippet to activate the product license and set the fonts directory path that contains font files used in source documents that may not be installed in OS Fonts directory.
// Activate XtremeDocumentStudio for Java license. Framework.activate("authorizationKey", "productKey"); //Set UserFontsDirectory path. Framework.setUserFontsDirectory("C:\\FontsCollection\\");
You can download trial version of XtremeDocumentStudio for Java and obtain a trial key for product activation by following the download link given below. https://www.gnostice.com/XtremeDocumentStudio_Java.asp?show=downloads
Below code snippet shows how you can convert the documents from one file format to another.
Scenario 1: Converting DOCX to PDF
// Create DocumentConverter instance. DocumentConverter documentConverter = new DocumentConverter(); // Convert DOCX to PDF. documentConverter.convertToFile("input.docx", "output.pdf");
Scenario 2: Converting multiple images to single PDF document
// Create DocumentConverter instance. DocumentConverter documentConverter = new DocumentConverter(); // Add input file names to the input list. ArrayListinputFileNamesList = new ArrayList (Arrays.asList( "1.bmp", "2.png", "3.jpg", "4.jpeg", "5.tif", "6.tiff", "7.jp2" )); // Specify the output MIMEType. String outputMIMEType = "application/pdf"; // Specify the output directory path. // "" = currentDir. String outputDirPath = ""; // Specify the prefix/baseFileName for the output file name. String baseFileName = "Converted"; // Specify the EncoderSettings, if null then default settings // will be used for the specified output MIMEType. EncoderSettings encoderSettings = null; // Set ConversionMode to specify whether input documents // should be converted to separate output documents or merged // together into single output file. ConversionMode conversionMode = ConversionMode.CONVERT_TO_SINGLE_FILE; // Passwords for the encrypted files in the input list. // Since the input files are images set null. ArrayList pwdsForInputs = null; // Page range settings for each input files // Set null as default where all pages are considered. ArrayList pageRangeSettingsForInputs = null; // Convert list of images to single PDF document. // ConvertToFile converts the input documents and returns list // of output file path(s) of the converted document(s). List outputFiles = documentConverter.convertToFile( inputFileNamesList, outputMIMEType, outputDirPath, baseFileName, encoderSettings, conversionMode, pwdsForInputs, pageRangeSettingsForInputs);
Scenario 3: Converting multiple files to single multipage TIFF file
// Create DocumentConverter instance. DocumentConverter documentConverter = new DocumentConverter(); // Add input file names to the input list. ArrayListinputFileNamesList = new ArrayList (Arrays.asList( "1.pdf", "2.docx", "3.bmp", "4.png", "5.tif", "6.jpeg", "7.jp2" )); // Specify the output MIMEType. String outputMIMEType = "image/tiff"; // Specify the output directory path. // "" = currentDir. String outputDirPath = ""; // Specify the prefix/baseFileName for the output file name. String baseFileName = "Converted"; // Additional parameters to create multipage tiff file. TiffImageEncoderSettings tiffImageEncoderSettings = new TiffImageEncoderSettings(); // By default multipage property is true for TIFF image // encoder settings. Hence it need not be set explicitly. // tiffImageEncoderSettings.setMultiPage(true); // Specify the compression type. By default it is NONE. tiffImageEncoderSettings.setCompressionType(TiffCompressionType.JPEG); // Specify the compression quality in a range of 0 to 1. Note: // compression quality is used only when the specified // compression type supports using of compression quality. tiffImageEncoderSettings.setCompressionQuality(1.0f); // Set ConversionMode to specify whether input documents // should be converted to separate output documents or merged // together into single file output. ConversionMode conversionMode = ConversionMode.CONVERT_TO_SINGLE_FILE; // Passwords for the encrypted files in the input list. // Since the input files are images set null. ArrayList pwdsForInputs = null; // Page range settings for each input files. // Set null as by default all pages are considered. ArrayList pageRangeSettingsForInputs = null; // Convert list of documents to single multipage TIFF document. List outputFiles = documentConverter.convertToFile( inputFileNamesList, outputMIMEType, outputDirPath, baseFileName, tiffImageEncoderSettings, conversionMode, pwdsForInputs, pageRangeSettingsForInputs);
Scenario 4: Creating a PDF Portfolio
// Create DocumentConverter instance. DocumentConverter documentConverter = new DocumentConverter(); // Add input file names to the input list. ArrayListinputFileNamesList = new ArrayList (Arrays.asList( "1.pdf", "2.docx", "3.bmp", "4.png", "5.tif", "6.jpeg", "7.jp2" )); // Specify the output MIMEType. String outputMIMEType = "application/pdf"; // Specify the output directory path. // "" = currentDir. String outputDirPath = ""; // Specify the prefix/baseFileName for the output file name. String baseFileName = "Converted"; // Additional parameters to create PDF Portfolio. PDFEncoderSettings encoderSettings = new PDFEncoderSettings(); encoderSettings.getPortfolioSettings() .setPortfolioCreationMode( PortfolioCreationMode.ONLY_WHEN_ATTACHMENTS_EXIST); encoderSettings.getPortfolioSettings() .setLayoutMode(PortfolioLayoutMode.TILE); // Set ConversionMode to specify that a blank new document // needs to be created and all input documents needs to be // included as file attachments in that new document. ConversionMode conversionMode = ConversionMode.CREATE_NEW_FILE_AND_ATTACH_ALL_AS_ORIGINAL; // Passwords for the encrypted files in the input list. // Since the input files are images set null. ArrayList pwdsForInputs = null; // Page range settings for each input files. // Set null as by default all pages are considered. ArrayList pageRangeSettingsForInputs = null; // Convert list of documents to PDF portfolio. List outputFiles = documentConverter.convertToFile( inputFileNamesList, outputMIMEType, outputDirPath, baseFileName, encoderSettings, conversionMode, pwdsForInputs, pageRangeSettingsForInputs);
Scenario 5: Converting images and scanned PDFs to searchable PDF document with OCR
// Create DocumentConverter instance. DocumentConverter documentConverter = new DocumentConverter(); // Add input file names to the input list. These contain the scanned images. ArrayListinputFileNamesList = new ArrayList (Arrays.asList( "1.png", "2.pdf" )); // Specify the output MIMEType. String outputMIMEType = "application/pdf"; // Specify the output directory path. // "" = currentDir. String outputDirPath = ""; // Specify the prefix/baseFileName for the output file name. String baseFileName = "Converted"; // Specify the EncoderSettings, if null then default settings // will be used for the specified output MIMEType. EncoderSettings encoderSettings = null; // Set ConversionMode to specify whether input documents // should be converted to separate output documents or merged // together into single file output. ConversionMode conversionMode = ConversionMode.CONVERT_TO_SEPARATE_FILES; // Passwords for the encrypted files in the input list. // Since the input files are images set null. ArrayList pwdsForInputs = null; // Page range settings for each input files. // Set null as by default all pages are considered. ArrayList pageRangeSettingsForInputs = null; // Additional parameters perform OCR ConverterDigitizerSettings digitizerSettings = documentConverter .getPreferences().getDigitizerSettings(); digitizerSettings.setDigitizationMode(DigitizationMode.ALL_IMAGES); digitizerSettings.getImageEnhancementSettings() .setImageEnhancementMode(ImageEnhancementMode.AUTO); // Language you need to recognize digitizerSettings.getOCRSettings().setDocumentLanguage("eng+deu+fra"); digitizerSettings.setRecognizeElementTypes(RecognizeElementTypes.TEXT); // Convert list of documents to searchable PDF. List outputFiles = documentConverter.convertToFile( inputFileNamesList, outputMIMEType, outputDirPath, baseFileName, encoderSettings, conversionMode, pwdsForInputs, pageRangeSettingsForInputs);
---o0O0o---
Our .NET Developer Tools | |
---|---|
Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved. |