public class Converter extends Processor
Remarks:
The specified input and output files or streams, along with the desired save format, are used to convert the given input document of the one format into the output document of the other specified format.
The convert functionality supports over 35+ different file formats.
The M:Aspose.Words.LowCode.Converter.ConvertToImages(System.String,Aspose.Words.SaveFormat) group of methods are designed to transform documents into images, with each page being converted into a separate image file. These methods also convert PDF documents directly to fixed-page formats without loading them into the document model, which enhances both performance and accuracy.
With ImageSaveOptions.getPageSet() / ImageSaveOptions.setPageSet(com.aspose.words.PageSet), you can specify a particular set of pages to convert into images.
mResultDocument| Modifier and Type | Method and Description |
|---|---|
static void |
convert(java.io.InputStream inputStream,
LoadOptions loadOptions,
java.io.OutputStream outputStream,
SaveOptions saveOptions) |
static void |
convert(java.io.InputStream inputStream,
java.io.OutputStream outputStream,
int saveFormat) |
static void |
convert(java.io.InputStream inputStream,
java.io.OutputStream outputStream,
SaveOptions saveOptions) |
static void |
convert(java.lang.String inputFile,
LoadOptions loadOptions,
java.lang.String outputFile,
SaveOptions saveOptions)
Converts the given input document into the output document using specified input output file names its load/save options.
|
static void |
convert(java.lang.String inputFile,
java.lang.String outputFile)
Converts the given input document into the output document using specified input output file names and its extensions.
|
static void |
convert(java.lang.String inputFile,
java.lang.String outputFile,
int saveFormat) |
static void |
convert(java.lang.String inputFile,
java.lang.String outputFile,
SaveOptions saveOptions)
Converts the given input document into the output document using specified input output file names and save options.
|
static java.io.OutputStream[] |
convertToImages(Document doc,
ImageSaveOptions saveOptions)
Converts the pages of the specified document to images using the specified save options and returns an array of streams containing the images.
|
static java.io.OutputStream[] |
convertToImages(Document doc,
int saveFormat) |
static java.io.OutputStream[] |
convertToImages(java.io.InputStream inputStream,
ImageSaveOptions saveOptions)
Converts the pages of the specified input stream to images using the specified save options and returns an array of streams containing the images.
|
static java.io.OutputStream[] |
convertToImages(java.io.InputStream inputStream,
int saveFormat) |
static java.io.OutputStream[] |
convertToImages(java.io.InputStream inputStream,
LoadOptions loadOptions,
ImageSaveOptions saveOptions)
Converts the pages of the specified input stream to images using the provided load and save options, and returns an array of streams containing the images.
|
static java.io.OutputStream[] |
convertToImages(java.lang.String inputFile,
ImageSaveOptions saveOptions)
Converts the pages of the specified input file to images using the specified save options and returns an array of streams containing the images.
|
static java.io.OutputStream[] |
convertToImages(java.lang.String inputFile,
int saveFormat) |
static void |
convertToImages(java.lang.String inputFile,
LoadOptions loadOptions,
java.lang.String outputFile,
ImageSaveOptions saveOptions)
Converts the pages of the specified input file to image files using the provided load and save options.
|
static void |
convertToImages(java.lang.String inputFile,
java.lang.String outputFile)
Converts the pages of the specified input file to image files.
|
static void |
convertToImages(java.lang.String inputFile,
java.lang.String outputFile,
ImageSaveOptions saveOptions)
Converts the pages of the specified input file to image files using the specified save options.
|
static void |
convertToImages(java.lang.String inputFile,
java.lang.String outputFile,
int saveFormat) |
static Converter |
create()
Creates new instance of the converter processor.
|
static Converter |
create(ConverterContext context)
Creates new instance of the converter processor.
|
protected void |
executeCore() |
public static Converter create()
public static Converter create(ConverterContext context)
Examples:
Shows how to convert documents with a single line of code using context.
String doc = getMyDir() + "Big document.docx";
ConverterContext converterContext = new ConverterContext();
Converter.create(converterContext)
.from(doc)
.to(getArtifactsDir() + "LowCode.ConvertContext.1.pdf")
.execute();
Converter.create(converterContext)
.from(doc)
.to(getArtifactsDir() + "LowCode.ConvertContext.2.pdf", SaveFormat.RTF)
.execute();
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
{
saveOptions.setPassword("Aspose.Words");
}
LoadOptions loadOptions = new LoadOptions();
{
loadOptions.setIgnoreOleData(true);
}
Converter.create(converterContext)
.from(doc, loadOptions)
.to(getArtifactsDir() + "LowCode.ConvertContext.3.docx", saveOptions)
.execute();
Converter.create(converterContext)
.from(doc)
.to(getArtifactsDir() + "LowCode.ConvertContext.4.png", new ImageSaveOptions(SaveFormat.PNG))
.execute();
Shows how to convert documents from a stream with a single line of code using context.
String doc = getMyDir() + "Document.docx";
ConverterContext converterContext = new ConverterContext();
try (FileInputStream streamIn = new FileInputStream(doc)) {
try (FileOutputStream streamOut = new FileOutputStream(getArtifactsDir() + "LowCode.ConvertContextStream.1.docx")) {
Converter.create(converterContext)
.from(streamIn)
.to(streamOut, SaveFormat.RTF)
.execute();
}
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
{
saveOptions.setPassword("Aspose.Words");
}
LoadOptions loadOptions = new LoadOptions();
{
loadOptions.setIgnoreOleData(true);
}
try (FileOutputStream streamOut1 = new FileOutputStream(getArtifactsDir() + "LowCode.ConvertContextStream.2.docx")) {
Converter.create(converterContext)
.from(streamIn, loadOptions)
.to(streamOut1, saveOptions)
.execute();
}
}
protected void executeCore()
throws java.lang.Exception
executeCore in class Processorjava.lang.Exceptionpublic static void convert(java.lang.String inputFile,
java.lang.String outputFile)
throws java.lang.Exception
Remarks:
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
Examples:
Shows how to convert documents with a single line of code.
String doc = getMyDir() + "Document.docx";
Converter.convert(doc, getArtifactsDir() + "LowCode.Convert.pdf");
Converter.convert(doc, getArtifactsDir() + "LowCode.Convert.SaveFormat.rtf", SaveFormat.RTF);
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
{
saveOptions.setPassword("Aspose.Words");
}
LoadOptions loadOptions = new LoadOptions();
{
loadOptions.setIgnoreOleData(true);
}
Converter.convert(doc, loadOptions, getArtifactsDir() + "LowCode.Convert.LoadOptions.docx", saveOptions);
Converter.convert(doc, getArtifactsDir() + "LowCode.Convert.SaveOptions.docx", saveOptions);
inputFile - The input file name.outputFile - The output file name.java.lang.Exceptionpublic static void convert(java.lang.String inputFile,
java.lang.String outputFile,
int saveFormat)
throws java.lang.Exception
java.lang.Exceptionpublic static void convert(java.lang.String inputFile,
java.lang.String outputFile,
SaveOptions saveOptions)
throws java.lang.Exception
Remarks:
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
Examples:
Shows how to convert documents with a single line of code.
String doc = getMyDir() + "Document.docx";
Converter.convert(doc, getArtifactsDir() + "LowCode.Convert.pdf");
Converter.convert(doc, getArtifactsDir() + "LowCode.Convert.SaveFormat.rtf", SaveFormat.RTF);
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
{
saveOptions.setPassword("Aspose.Words");
}
LoadOptions loadOptions = new LoadOptions();
{
loadOptions.setIgnoreOleData(true);
}
Converter.convert(doc, loadOptions, getArtifactsDir() + "LowCode.Convert.LoadOptions.docx", saveOptions);
Converter.convert(doc, getArtifactsDir() + "LowCode.Convert.SaveOptions.docx", saveOptions);
inputFile - The input file name.outputFile - The output file name.saveOptions - The save options.java.lang.Exceptionpublic static void convert(java.lang.String inputFile,
LoadOptions loadOptions,
java.lang.String outputFile,
SaveOptions saveOptions)
throws java.lang.Exception
Remarks:
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
Examples:
Shows how to convert documents with a single line of code.
String doc = getMyDir() + "Document.docx";
Converter.convert(doc, getArtifactsDir() + "LowCode.Convert.pdf");
Converter.convert(doc, getArtifactsDir() + "LowCode.Convert.SaveFormat.rtf", SaveFormat.RTF);
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
{
saveOptions.setPassword("Aspose.Words");
}
LoadOptions loadOptions = new LoadOptions();
{
loadOptions.setIgnoreOleData(true);
}
Converter.convert(doc, loadOptions, getArtifactsDir() + "LowCode.Convert.LoadOptions.docx", saveOptions);
Converter.convert(doc, getArtifactsDir() + "LowCode.Convert.SaveOptions.docx", saveOptions);
inputFile - The input file name.loadOptions - The input document load options.outputFile - The output file name.saveOptions - The save options.java.lang.Exceptionpublic static void convert(java.io.InputStream inputStream,
java.io.OutputStream outputStream,
int saveFormat)
throws java.lang.Exception
java.lang.Exceptionpublic static void convert(java.io.InputStream inputStream,
java.io.OutputStream outputStream,
SaveOptions saveOptions)
throws java.lang.Exception
java.lang.Exceptionpublic static void convert(java.io.InputStream inputStream,
LoadOptions loadOptions,
java.io.OutputStream outputStream,
SaveOptions saveOptions)
throws java.lang.Exception
java.lang.Exceptionpublic static void convertToImages(java.lang.String inputFile,
java.lang.String outputFile)
throws java.lang.Exception
Examples:
Shows how to convert document to images.
String doc = getMyDir() + "Big document.docx";
Converter.convertToImages(doc, getArtifactsDir() + "LowCode.ConvertToImages.1.png");
Converter.convertToImages(doc, getArtifactsDir() + "LowCode.ConvertToImages.2.jpeg", SaveFormat.JPEG);
LoadOptions loadOptions = new LoadOptions();
{
loadOptions.setIgnoreOleData(false);
}
ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.PNG);
imageSaveOptions.setPageSet(new PageSet(1));
Converter.convertToImages(doc, loadOptions, getArtifactsDir() + "LowCode.ConvertToImages.3.png", imageSaveOptions);
Converter.convertToImages(doc, getArtifactsDir() + "LowCode.ConvertToImages.4.png", imageSaveOptions);
inputFile - The input file name.outputFile - The output file name used to generate file name for page images using rule "outputFile_pageIndex.extension"java.lang.Exceptionpublic static void convertToImages(java.lang.String inputFile,
java.lang.String outputFile,
int saveFormat)
throws java.lang.Exception
java.lang.Exceptionpublic static void convertToImages(java.lang.String inputFile,
java.lang.String outputFile,
ImageSaveOptions saveOptions)
throws java.lang.Exception
Examples:
Shows how to convert document to images.
String doc = getMyDir() + "Big document.docx";
Converter.convertToImages(doc, getArtifactsDir() + "LowCode.ConvertToImages.1.png");
Converter.convertToImages(doc, getArtifactsDir() + "LowCode.ConvertToImages.2.jpeg", SaveFormat.JPEG);
LoadOptions loadOptions = new LoadOptions();
{
loadOptions.setIgnoreOleData(false);
}
ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.PNG);
imageSaveOptions.setPageSet(new PageSet(1));
Converter.convertToImages(doc, loadOptions, getArtifactsDir() + "LowCode.ConvertToImages.3.png", imageSaveOptions);
Converter.convertToImages(doc, getArtifactsDir() + "LowCode.ConvertToImages.4.png", imageSaveOptions);
inputFile - The input file name.outputFile - The output file name used to generate file name for page images using rule "outputFile_pageIndex.extension"saveOptions - Image save options.java.lang.Exceptionpublic static void convertToImages(java.lang.String inputFile,
LoadOptions loadOptions,
java.lang.String outputFile,
ImageSaveOptions saveOptions)
throws java.lang.Exception
Examples:
Shows how to convert document to images.
String doc = getMyDir() + "Big document.docx";
Converter.convertToImages(doc, getArtifactsDir() + "LowCode.ConvertToImages.1.png");
Converter.convertToImages(doc, getArtifactsDir() + "LowCode.ConvertToImages.2.jpeg", SaveFormat.JPEG);
LoadOptions loadOptions = new LoadOptions();
{
loadOptions.setIgnoreOleData(false);
}
ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.PNG);
imageSaveOptions.setPageSet(new PageSet(1));
Converter.convertToImages(doc, loadOptions, getArtifactsDir() + "LowCode.ConvertToImages.3.png", imageSaveOptions);
Converter.convertToImages(doc, getArtifactsDir() + "LowCode.ConvertToImages.4.png", imageSaveOptions);
inputFile - The input file name.loadOptions - The input document load options.outputFile - The output file name used to generate file name for page images using rule "outputFile_pageIndex.extension"saveOptions - Image save options.java.lang.Exceptionpublic static java.io.OutputStream[] convertToImages(java.lang.String inputFile,
int saveFormat)
throws java.lang.Exception
java.lang.Exceptionpublic static java.io.OutputStream[] convertToImages(java.lang.String inputFile,
ImageSaveOptions saveOptions)
throws java.lang.Exception
Examples:
Shows how to convert document to images stream.
String doc = getMyDir() + "Big document.docx";
OutputStream[] streams = Converter.convertToImages(doc, SaveFormat.PNG);
ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.PNG);
imageSaveOptions.setPageSet(new PageSet(1));
streams = Converter.convertToImages(doc, imageSaveOptions);
streams = Converter.convertToImages(new Document(doc), SaveFormat.PNG);
streams = Converter.convertToImages(new Document(doc), imageSaveOptions);
inputFile - The input file name.saveOptions - Image save options.java.lang.Exceptionpublic static java.io.OutputStream[] convertToImages(java.io.InputStream inputStream,
int saveFormat)
throws java.lang.Exception
java.lang.Exceptionpublic static java.io.OutputStream[] convertToImages(java.io.InputStream inputStream,
ImageSaveOptions saveOptions)
throws java.lang.Exception
Examples:
Shows how to convert document to images from stream.
try (FileInputStream streamIn = new FileInputStream(getMyDir() + "Big document.docx")) {
OutputStream[] streams = Converter.convertToImages(streamIn, SaveFormat.JPEG);
ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.PNG);
imageSaveOptions.setPageSet(new PageSet(1));
streams = Converter.convertToImages(streamIn, imageSaveOptions);
LoadOptions loadOptions = new LoadOptions();
{
loadOptions.setIgnoreOleData(false);
}
Converter.convertToImages(streamIn, loadOptions, imageSaveOptions);
}
inputStream - The input stream.saveOptions - Image save options.java.lang.Exceptionpublic static java.io.OutputStream[] convertToImages(java.io.InputStream inputStream,
LoadOptions loadOptions,
ImageSaveOptions saveOptions)
throws java.lang.Exception
Examples:
Shows how to convert document to images from stream.
try (FileInputStream streamIn = new FileInputStream(getMyDir() + "Big document.docx")) {
OutputStream[] streams = Converter.convertToImages(streamIn, SaveFormat.JPEG);
ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.PNG);
imageSaveOptions.setPageSet(new PageSet(1));
streams = Converter.convertToImages(streamIn, imageSaveOptions);
LoadOptions loadOptions = new LoadOptions();
{
loadOptions.setIgnoreOleData(false);
}
Converter.convertToImages(streamIn, loadOptions, imageSaveOptions);
}
inputStream - The input stream.loadOptions - The input document load options.saveOptions - Image save options.java.lang.Exceptionpublic static java.io.OutputStream[] convertToImages(Document doc, int saveFormat) throws java.lang.Exception
java.lang.Exceptionpublic static java.io.OutputStream[] convertToImages(Document doc, ImageSaveOptions saveOptions) throws java.lang.Exception
Examples:
Shows how to convert document to images stream.
String doc = getMyDir() + "Big document.docx";
OutputStream[] streams = Converter.convertToImages(doc, SaveFormat.PNG);
ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.PNG);
imageSaveOptions.setPageSet(new PageSet(1));
streams = Converter.convertToImages(doc, imageSaveOptions);
streams = Converter.convertToImages(new Document(doc), SaveFormat.PNG);
streams = Converter.convertToImages(new Document(doc), imageSaveOptions);
doc - The input document.saveOptions - Image save options.java.lang.Exception