ConverterContext
Inheritance: java.lang.Object, com.aspose.words.ProcessorContext
public class ConverterContext extends ProcessorContext
Document converter 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();
}
}
Methods
| Method | Description |
|---|---|
| getFontSettings() | Font settings used by the processor. |
| getLayoutOptions() | Document layout options used by the processor. |
| getWarningCallback() | Warning callback used by the processor. |
| setFontSettings(FontSettings value) | Font settings used by the processor. |
| setWarningCallback(IWarningCallback value) | Warning callback used by the processor. |
getFontSettings()
public FontSettings getFontSettings()
Font settings used by the processor.
Returns: FontSettings - The corresponding FontSettings value.
getLayoutOptions()
public LayoutOptions getLayoutOptions()
Document layout options used by the processor.
Returns: LayoutOptions - The corresponding LayoutOptions value.
getWarningCallback()
public IWarningCallback getWarningCallback()
Warning callback used by the processor.
Returns: IWarningCallback - The corresponding IWarningCallback value.
setFontSettings(FontSettings value)
public void setFontSettings(FontSettings value)
Font settings used by the processor.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | FontSettings | The corresponding FontSettings value. |
setWarningCallback(IWarningCallback value)
public void setWarningCallback(IWarningCallback value)
Warning callback used by the processor.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | IWarningCallback | The corresponding IWarningCallback value. |