com.aspose.words
Class SaveOptions

java.lang.Object
    extended by com.aspose.words.SaveOptions
All Implemented Interfaces:
java.lang.Cloneable

public class SaveOptions 
extends java.lang.Object

Provides various options that control how a document is saved.

The SaveOptions objectis a set of options that allow you to control how Aspose.Words saves a Document. SaveOptions is not persisted with the Document.

Example:

Shows how to set save options before saving a document.
Document doc = new Document(getMyDir() + "Document.doc");

// Set an option to export form fields as plain text, not as HTML input elements.
doc.getSaveOptions().setHtmlExportTextInputFormFieldAsText(true);

doc.save(getMyDir() + "Document.SaveWithOptions Out.html");
See Also:
Document, Document.SaveOptions

Property Getters/Setters Summary
java.lang.StringgetExportImagesFolder()
voidsetExportImagesFolder(java.lang.String value)
           Specifies the physical folder where images are saved when saving a document to a stream in the HTML or Aspose.Pdf XML format.
booleangetHtmlExportAllowNegativeLeftIndent()
voidsetHtmlExportAllowNegativeLeftIndent(boolean value)
           Specifies whether negative left indent of paragraphs is normalized when exporting to HTML. Default value is false.
java.lang.StringgetHtmlExportCssStyleSheetFileName()
voidsetHtmlExportCssStyleSheetFileName(java.lang.String value)
           Specifies the name of the Cascading Style Sheet (CSS) file written with the exported document. Default is an empty string.
intgetHtmlExportCssStyleSheetType()
voidsetHtmlExportCssStyleSheetType(int value)
           Specifies how CSS (Cascading Style Sheet) styles are exported to HTML. The value of the property is CssStyleSheetType integer constant.
booleangetHtmlExportDocumentProperties()
voidsetHtmlExportDocumentProperties(boolean value)
           Specifies whether to export built-in and custom document properties to HTML. Default value is false.
java.nio.charset.CharsetgetHtmlExportEncoding()
voidsetHtmlExportEncoding(java.nio.charset.Charset value)
           Specifies the encoding to use when exporting to HTML format. Default value is 'UTF-8' Charset.
booleangetHtmlExportHeadersFooters()
voidsetHtmlExportHeadersFooters(boolean value)
           Specifies whether to output headers and footers to HTML. Default value is true.
intgetHtmlExportImageResolution()
voidsetHtmlExportImageResolution(int value)
           Specifies the output resolution for images when exporting to HTML. Default is 96 dpi.
java.lang.StringgetHtmlExportImagesFolder()
voidsetHtmlExportImagesFolder(java.lang.String value)
           Specifies the physical folder where images are saved when exporting a document to HTML format. Default is an empty string.
java.lang.StringgetHtmlExportImagesFolderAlias()
voidsetHtmlExportImagesFolderAlias(java.lang.String value)
           Specifies the name of the folder used to construct image URIs written into an HTML document. Default is an empty string.
booleangetHtmlExportMetafileAsRaster()
voidsetHtmlExportMetafileAsRaster(boolean value)
           Specifies whether to convert metafiles into raster images when exporting to HTML. Default value is true.
intgetHtmlExportMetafileResolution()
voidsetHtmlExportMetafileResolution(int value)
           Specifies the resolution at which metafiles are converted to raster images when exporting to HTML. Default is 96 dpi.
booleangetHtmlExportPageSetup()
voidsetHtmlExportPageSetup(boolean value)
           Specifies whether page setup is exported to HTML. Default is false.
booleangetHtmlExportScaleImageToShapeSize()
voidsetHtmlExportScaleImageToShapeSize(boolean value)
           Specifies whether images are scaled by Aspose.Words to the bounding shape size when exporting to HTML. Default value is true.
booleangetHtmlExportTextInputFormFieldAsText()
voidsetHtmlExportTextInputFormFieldAsText(boolean value)
           Specifies how to export Word text input form fields to HTML. Default value is false.
booleangetHtmlExportXhtmlTransitional()
voidsetHtmlExportXhtmlTransitional(boolean value)
           When true, writes a DOCTYPE declaration in the document prior to the root element. Default value is false.
booleangetRtfExportCompactSize()
voidsetRtfExportCompactSize(boolean value)
           Specifies whether to generate compact size RTF documents. When this property is true, some RTF features intended for old readers are omitted. Default value is false.
java.nio.charset.CharsetgetTxtExportEncoding()
voidsetTxtExportEncoding(java.nio.charset.Charset value)
           Specifies the encoding to use when exporting in plain text format. Default value is 'UTF-8' Charset.
booleangetTxtExportHeadersFooters()
voidsetTxtExportHeadersFooters(boolean value)
           Specifies whether to output headers and footers when exporting in plain text format. Default value is true.
java.lang.StringgetTxtExportParagraphBreak()
voidsetTxtExportParagraphBreak(java.lang.String value)
           Specifies the string to use as a paragraph break when exporting in plain text format.
booleangetTxtExportTableLayout()
voidsetTxtExportTableLayout(boolean value)
           Specifies whether tables should preserve layout when exporting in plain text format. The default value is false.
 
Method Summary
voidaddHtmlExportImageSavingEventHandler(ExportImageSavingEventHandler newListener)
          Adds the ExportImageSavingEventHandler to the list of subscribed listeners of HtmlExportImageSaving event.
booleangetHtmlExportMetafileAsRaster()
           Specifies whether to save metafiles as rasters or not to save.
voidremoveHtmlExportImageSavingEventHandler(ExportImageSavingEventHandler oldListener)
          Removes the ExportImageSavingEventHandler from the list of subscribed listeners of HtmlExportImageSaving event.
voidsetHtmlExportMetafileAsRaster(boolean value)
           Specifies whether to save metafiles as rasters or not to save.
 

Property Getters/Setters Detail

getExportImagesFolder/setExportImagesFolder

public java.lang.String getExportImagesFolder() / public void setExportImagesFolder(java.lang.String value)
Specifies the physical folder where images are saved when saving a document to a stream in the HTML or Aspose.Pdf XML format.

getHtmlExportImagesFolder/setHtmlExportImagesFolder

public java.lang.String getHtmlExportImagesFolder() / public void setHtmlExportImagesFolder(java.lang.String value)
Specifies the physical folder where images are saved when exporting a document to HTML format. Default is an empty string.

When you save a Document in HTML format, Aspose.Words needs to save all images embedded in the document as standalone files. HtmlExportImagesFolder allows you to specify where the images will be saved and HtmlExportImagesFolderAlias allows to specify how the image URIs will be constructed.

If you save a document into a file and provide a file name, Aspose.Words, by default, saves the images in the same folder where the document file is saved. Use HtmlExportImagesFolder to override this behavior.

If you save a document into a stream, Aspose.Words does not have a folder where to save the images, but still needs to save the images somewhere. In this case, you need to specify an accessible folder in the HtmlExportImagesFolder property or provide custom streams via the ExportImageSavingEventHandler.

See Also:
HtmlExportImagesFolderAlias, ExportImageSavingEventHandler

getHtmlExportImagesFolderAlias/setHtmlExportImagesFolderAlias

public java.lang.String getHtmlExportImagesFolderAlias() / public void setHtmlExportImagesFolderAlias(java.lang.String value)
Specifies the name of the folder used to construct image URIs written into an HTML document. Default is an empty string.

When you save a Document in HTML format, Aspose.Words needs to save all images embedded in the document as standalone files. HtmlExportImagesFolder allows you to specify where the images will be saved and HtmlExportImagesFolderAlias allows to specify how the image URIs will be constructed.

If HtmlExportImagesFolderAlias is not an empty string, then the image URI written to HTML will be HtmlExportImagesFolderAlias + <image file name>.

If HtmlExportImagesFolderAlias is an empty string, then the image URI written to HTML will be HtmlExportImagesFolder + <image file name>.

If HtmlExportImagesFolderAlias is set to '.' (dot), then the image file name will be written to HTML without path regardless of other options.

See Also:
HtmlExportImagesFolder, ExportImageSavingEventHandler

getHtmlExportCssStyleSheetFileName/setHtmlExportCssStyleSheetFileName

public java.lang.String getHtmlExportCssStyleSheetFileName() / public void setHtmlExportCssStyleSheetFileName(java.lang.String value)
Specifies the name of the Cascading Style Sheet (CSS) file written with the exported document. Default is an empty string.

Note, this property has effect only when saving a Document in HTML format and external CSS style sheet is requested using HtmlExportCssStyleSheetType.

If you don't specify a value for this property, then the style sheet file will have the same name as the HTML document name, but with a ".css" extension.

See Also:
HtmlExportCssStyleSheetType

getHtmlExportTextInputFormFieldAsText/setHtmlExportTextInputFormFieldAsText

public boolean getHtmlExportTextInputFormFieldAsText() / public void setHtmlExportTextInputFormFieldAsText(boolean value)
Specifies how to export Word text input form fields to HTML. Default value is false.

When false, exports Word text input form fields as INPUT elements in HTML. When set to true, exports text input form fields as normal text.

Example:

Shows how to set save options before saving a document.
Document doc = new Document(getMyDir() + "Document.doc");

// Set an option to export form fields as plain text, not as HTML input elements.
doc.getSaveOptions().setHtmlExportTextInputFormFieldAsText(true);

doc.save(getMyDir() + "Document.SaveWithOptions Out.html");

getHtmlExportHeadersFooters/setHtmlExportHeadersFooters

public boolean getHtmlExportHeadersFooters() / public void setHtmlExportHeadersFooters(boolean value)
Specifies whether to output headers and footers to HTML. Default value is true.

It is hard to meaningfully output headers and footers to HTML because HTML is not paginated. When this property is true, Aspose.Words exports only primary headers and footers at the beginning and end of each section. You can disable export of headers and footers altogether by setting this property to false.


getHtmlExportAllowNegativeLeftIndent/setHtmlExportAllowNegativeLeftIndent

public boolean getHtmlExportAllowNegativeLeftIndent() / public void setHtmlExportAllowNegativeLeftIndent(boolean value)
Specifies whether negative left indent of paragraphs is normalized when exporting to HTML. Default value is false.

When negative left indent is not allowed, it is exported as zero left margin to HTML. When negative left indent is allowed, a paragraph might appear partially outside of the browser window.


getHtmlExportXhtmlTransitional/setHtmlExportXhtmlTransitional

public boolean getHtmlExportXhtmlTransitional() / public void setHtmlExportXhtmlTransitional(boolean value)
When true, writes a DOCTYPE declaration in the document prior to the root element. Default value is false.

Aspose.Words always writes well formed HTML regardless of this setting.

When true, the beginning of the HTML output document will look like this:

            <?xml version="1.0" encoding="utf-8" standalone="no" ?>
            <!DOCTYPE html 
            	  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
            

Aspose.Words aims to output XHTML according to the XHTML 1.0 Transitional specification, but the output will not always validate against the DTD. Some structures inside a Microsoft Word document are hard or impossible to map to a document that will validate against the XHTML schema. For example, XHTML does not allow nested lists (UL cannot be nested inside another UL element), but in Microsoft Word document multilevel lists occur quite often.


getHtmlExportDocumentProperties/setHtmlExportDocumentProperties

public boolean getHtmlExportDocumentProperties() / public void setHtmlExportDocumentProperties(boolean value)
Specifies whether to export built-in and custom document properties to HTML. Default value is false.

getHtmlExportMetafileAsRaster/setHtmlExportMetafileAsRaster

public boolean getHtmlExportMetafileAsRaster() / public void setHtmlExportMetafileAsRaster(boolean value)
Specifies whether to convert metafiles into raster images when exporting to HTML. Default value is true.

Metafiles are not natively displayed by HTML browsers. By default, Aspose.Words converts WMF and EMF images into PNG files when exporting to HTML. Setting this property to false causes metafiles to be exported to HTML without conversion.

Some image transforms, in particular image cropping, will not be applied to metafile images if this property is false.

See Also:
HtmlExportImageResolution, HtmlExportScaleImageToShapeSize

getHtmlExportScaleImageToShapeSize/setHtmlExportScaleImageToShapeSize

public boolean getHtmlExportScaleImageToShapeSize() / public void setHtmlExportScaleImageToShapeSize(boolean value)
Specifies whether images are scaled by Aspose.Words to the bounding shape size when exporting to HTML. Default value is true.

An image in a Microsoft Word document is a shape. The shape has a size and the image has its own size. The sizes are not directly linked. For example, the image can be 1024x786 pixels, but shape that displays this image can be 400x300 points.

In order to display an image in the browser, it must be scaled to the shape size. The HtmlExportScaleImageToShapeSize property controls where the scaling of the image takes place: in Aspose.Words during export to HTML or in the browser when displaying the document.

When HtmlExportScaleImageToShapeSize is true, the image is scaled by Aspose.Words using high quality scaling during export to HTML. When HtmlExportScaleImageToShapeSize is false, the image is output with its original size and the browser has to scale it.

In general, browsers do quick and poor quality scaling. As a result, you will normally get better display quality in the browser and smaller file size when HtmlExportScaleImageToShapeSize is true, but better printing quality and faster conversion when HtmlExportScaleImageToShapeSize is false.

See Also:
HtmlExportImageResolution

getHtmlExportImageResolution/setHtmlExportImageResolution

public int getHtmlExportImageResolution() / public void setHtmlExportImageResolution(int value)
Specifies the output resolution for images when exporting to HTML. Default is 96 dpi.

This property has effect for raster images only when HtmlExportScaleImageToShapeSize is true and it has effect for metafiles only when HtmlExportMetafileAsRaster is true.

See Also:
HtmlExportScaleImageToShapeSize

getHtmlExportMetafileResolution/setHtmlExportMetafileResolution

public int getHtmlExportMetafileResolution() / public void setHtmlExportMetafileResolution(int value)
Specifies the resolution at which metafiles are converted to raster images when exporting to HTML. Default is 96 dpi.

Metafiles are not natively displayed by browsers and therefore Aspose.Words converts WMF and EMF images into PNG files when exporting to HTML. This setting specifies the resolution of the created PNG files. If the HTML file is intended to be viewed on the screen, the default setting will produce images of adequate quality and small size.


getHtmlExportCssStyleSheetType/setHtmlExportCssStyleSheetType

public int getHtmlExportCssStyleSheetType() / public void setHtmlExportCssStyleSheetType(int value)
Specifies how CSS (Cascading Style Sheet) styles are exported to HTML. The value of the property is CssStyleSheetType integer constant.

The default value is CssStyleSheetType.INLINE.

See Also:
HtmlExportCssStyleSheetFileName

getHtmlExportPageSetup/setHtmlExportPageSetup

public boolean getHtmlExportPageSetup() / public void setHtmlExportPageSetup(boolean value)
Specifies whether page setup is exported to HTML. Default is false.

Each Section in Aspose.Words document model provides page setup information via PageSetup class. When you export a document to HTML format you might need to keep this information for further usage. In particular, page setup might be important for rendering to paged media (printing) or subsequent conversion to the native Microsoft Word file formats (DOCX, DOC, RTF, WML).

In most cases HTML is intended for viewing in browsers where pagination is not performed. So this feature is inactive by default.


getHtmlExportEncoding/setHtmlExportEncoding

public java.nio.charset.Charset getHtmlExportEncoding() / public void setHtmlExportEncoding(java.nio.charset.Charset value)
Specifies the encoding to use when exporting to HTML format. Default value is 'UTF-8' Charset.

getRtfExportCompactSize/setRtfExportCompactSize

public boolean getRtfExportCompactSize() / public void setRtfExportCompactSize(boolean value)
Specifies whether to generate compact size RTF documents. When this property is true, some RTF features intended for old readers are omitted. Default value is false.

getTxtExportHeadersFooters/setTxtExportHeadersFooters

public boolean getTxtExportHeadersFooters() / public void setTxtExportHeadersFooters(boolean value)
Specifies whether to output headers and footers when exporting in plain text format. Default value is true.

It is hard to meaningfully output headers and footers to plain text because it is not paginated. When this property is true, Aspose.Words exports only primary headers and footers at the beginning and end of each section. You can disable export of headers and footers altogether by setting this property to false.


getTxtExportEncoding/setTxtExportEncoding

public java.nio.charset.Charset getTxtExportEncoding() / public void setTxtExportEncoding(java.nio.charset.Charset value)
Specifies the encoding to use when exporting in plain text format. Default value is 'UTF-8' Charset.

getTxtExportParagraphBreak/setTxtExportParagraphBreak

public java.lang.String getTxtExportParagraphBreak() / public void setTxtExportParagraphBreak(java.lang.String value)
Specifies the string to use as a paragraph break when exporting in plain text format.

The default value is ControlChar.CR_LF.


getTxtExportTableLayout/setTxtExportTableLayout

public boolean getTxtExportTableLayout() / public void setTxtExportTableLayout(boolean value)
Specifies whether tables should preserve layout when exporting in plain text format. The default value is false.

Method Detail

getHtmlExportMetafileAsRaster

public boolean getHtmlExportMetafileAsRaster()
Specifies whether to save metafiles as rasters or not to save.

By default aspose.words converts metafiles (.wmf and .emf images) into a raster format (.png). Setting this property and HtmlExportScaleImageToShapeSize to false leaves metafiles as is.


setHtmlExportMetafileAsRaster

public void setHtmlExportMetafileAsRaster(boolean value)
Specifies whether to save metafiles as rasters or not to save.

By default aspose.words converts metafiles (.wmf and .emf images) into a raster format (.png). Setting this property and HtmlExportScaleImageToShapeSize to false leaves metafiles as is.


addHtmlExportImageSavingEventHandler

public void addHtmlExportImageSavingEventHandler(ExportImageSavingEventHandler newListener)
Adds the ExportImageSavingEventHandler to the list of subscribed listeners of HtmlExportImageSaving event.

removeHtmlExportImageSavingEventHandler

public void removeHtmlExportImageSavingEventHandler(ExportImageSavingEventHandler oldListener)
Removes the ExportImageSavingEventHandler from the list of subscribed listeners of HtmlExportImageSaving event.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.