public class XamlFlowSaveOptions extends SaveOptions
SaveFormat.XAML_FLOW or SaveFormat.XAML_FLOW_PACK format.
To learn more, visit the Specify Save Options documentation article.
Examples:
Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.
public void imageFolder() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
ImageUriPrinter callback = new ImageUriPrinter(getArtifactsDir() + "XamlFlowImageFolderAlias");
// Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we save the document to the XAML save format.
XamlFlowSaveOptions options = new XamlFlowSaveOptions();
Assert.assertEquals(SaveFormat.XAML_FLOW, options.getSaveFormat());
// Use the "ImagesFolder" property to assign a folder in the local file system into which
// Aspose.Words will save all the document's linked images.
options.setImagesFolder(getArtifactsDir() + "XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options.setImagesFolderAlias(getArtifactsDir() + "XamlFlowImageFolderAlias");
options.setImageSavingCallback(callback);
// A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
// We must ensure the folder exists before the callback's streams can put their resources into it.
new File(options.getImagesFolderAlias()).mkdir();
doc.save(getArtifactsDir() + "XamlFlowSaveOptions.ImageFolder.xaml", options);
for (String resource : callback.getResources())
System.out.println("{callback.ImagesFolderAlias}/{resource}");
}
/// <summary>
/// Counts and prints filenames of images while their parent document is converted to flow-form .xaml.
/// </summary>
private static class ImageUriPrinter implements IImageSavingCallback {
public ImageUriPrinter(String imagesFolderAlias) {
mImagesFolderAlias = imagesFolderAlias;
mResources = new ArrayList<String>();
}
public void imageSaving(ImageSavingArgs args) throws Exception {
getResources().add(args.getImageFileName());
// If we specified an image folder alias, we would also need
// to redirect each stream to put its image in the alias folder.
args.setImageStream(new FileOutputStream(MessageFormat.format("{0}/{1}", mImagesFolderAlias, args.getImageFileName())));
args.setKeepImageStreamOpen(false);
}
public String getImagesFolderAlias() {
return mImagesFolderAlias;
}
private final String mImagesFolderAlias;
public ArrayList<String> getResources() {
return mResources;
}
private final ArrayList<String> mResources;
}
| Constructor and Description |
|---|
XamlFlowSaveOptions()
Initializes a new instance of this class that can be used to save a document in the
SaveFormat.XAML_FLOW format. |
XamlFlowSaveOptions(int saveFormat)
Initializes a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
IImageSavingCallback |
getImageSavingCallback()
Allows to control how images are saved when a document is saved to XAML.
|
java.lang.String |
getImagesFolder()
Specifies the physical folder where images are saved when exporting a document to XAML format.
|
java.lang.String |
getImagesFolderAlias()
Specifies the name of the folder used to construct image URIs written into an XAML document.
|
boolean |
getReplaceBackslashWithYenSign()
Specifies whether backslash characters should be replaced with yen signs.
|
int |
getSaveFormat()
Specifies the format in which the document will be saved if this save options object is used.
|
void |
setImageSavingCallback(IImageSavingCallback value)
Allows to control how images are saved when a document is saved to XAML.
|
void |
setImagesFolder(java.lang.String value)
Specifies the physical folder where images are saved when exporting a document to XAML format.
|
void |
setImagesFolderAlias(java.lang.String value)
Specifies the name of the folder used to construct image URIs written into an XAML document.
|
void |
setReplaceBackslashWithYenSign(boolean value)
Specifies whether backslash characters should be replaced with yen signs.
|
void |
setSaveFormat(int value)
Specifies the format in which the document will be saved if this save options object is used.
|
createSaveOptions, createSaveOptions, getAllowEmbeddingPostScriptFonts, getCustomTimeZoneInfo, getDefaultTemplate, getDml3DEffectsRenderingMode, getDmlEffectsRenderingMode, getDmlRenderingMode, getExportGeneratorName, getImlRenderingMode, getMemoryOptimization, getPrettyFormat, getProgressCallback, getTempFolder, getUpdateAmbiguousTextFont, getUpdateCreatedTimeProperty, getUpdateFields, getUpdateLastPrintedProperty, getUpdateLastSavedTimeProperty, getUseAntiAliasing, getUseHighQualityRendering, setAllowEmbeddingPostScriptFonts, setCustomTimeZoneInfo, setDefaultTemplate, setDml3DEffectsRenderingMode, setDmlEffectsRenderingMode, setDmlRenderingMode, setExportGeneratorName, setImlRenderingMode, setMemoryOptimization, setPrettyFormat, setProgressCallback, setTempFolder, setUpdateAmbiguousTextFont, setUpdateCreatedTimeProperty, setUpdateFields, setUpdateLastPrintedProperty, setUpdateLastSavedTimeProperty, setUseAntiAliasing, setUseHighQualityRenderingpublic XamlFlowSaveOptions()
SaveFormat.XAML_FLOW format.
Examples:
Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.
public void imageFolder() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
ImageUriPrinter callback = new ImageUriPrinter(getArtifactsDir() + "XamlFlowImageFolderAlias");
// Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we save the document to the XAML save format.
XamlFlowSaveOptions options = new XamlFlowSaveOptions();
Assert.assertEquals(SaveFormat.XAML_FLOW, options.getSaveFormat());
// Use the "ImagesFolder" property to assign a folder in the local file system into which
// Aspose.Words will save all the document's linked images.
options.setImagesFolder(getArtifactsDir() + "XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options.setImagesFolderAlias(getArtifactsDir() + "XamlFlowImageFolderAlias");
options.setImageSavingCallback(callback);
// A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
// We must ensure the folder exists before the callback's streams can put their resources into it.
new File(options.getImagesFolderAlias()).mkdir();
doc.save(getArtifactsDir() + "XamlFlowSaveOptions.ImageFolder.xaml", options);
for (String resource : callback.getResources())
System.out.println("{callback.ImagesFolderAlias}/{resource}");
}
/// <summary>
/// Counts and prints filenames of images while their parent document is converted to flow-form .xaml.
/// </summary>
private static class ImageUriPrinter implements IImageSavingCallback {
public ImageUriPrinter(String imagesFolderAlias) {
mImagesFolderAlias = imagesFolderAlias;
mResources = new ArrayList<String>();
}
public void imageSaving(ImageSavingArgs args) throws Exception {
getResources().add(args.getImageFileName());
// If we specified an image folder alias, we would also need
// to redirect each stream to put its image in the alias folder.
args.setImageStream(new FileOutputStream(MessageFormat.format("{0}/{1}", mImagesFolderAlias, args.getImageFileName())));
args.setKeepImageStreamOpen(false);
}
public String getImagesFolderAlias() {
return mImagesFolderAlias;
}
private final String mImagesFolderAlias;
public ArrayList<String> getResources() {
return mResources;
}
private final ArrayList<String> mResources;
}
public XamlFlowSaveOptions(int saveFormat)
public int getSaveFormat()
SaveFormat.XAML_FLOW.
Examples:
Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.
public void imageFolder() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
ImageUriPrinter callback = new ImageUriPrinter(getArtifactsDir() + "XamlFlowImageFolderAlias");
// Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we save the document to the XAML save format.
XamlFlowSaveOptions options = new XamlFlowSaveOptions();
Assert.assertEquals(SaveFormat.XAML_FLOW, options.getSaveFormat());
// Use the "ImagesFolder" property to assign a folder in the local file system into which
// Aspose.Words will save all the document's linked images.
options.setImagesFolder(getArtifactsDir() + "XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options.setImagesFolderAlias(getArtifactsDir() + "XamlFlowImageFolderAlias");
options.setImageSavingCallback(callback);
// A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
// We must ensure the folder exists before the callback's streams can put their resources into it.
new File(options.getImagesFolderAlias()).mkdir();
doc.save(getArtifactsDir() + "XamlFlowSaveOptions.ImageFolder.xaml", options);
for (String resource : callback.getResources())
System.out.println("{callback.ImagesFolderAlias}/{resource}");
}
/// <summary>
/// Counts and prints filenames of images while their parent document is converted to flow-form .xaml.
/// </summary>
private static class ImageUriPrinter implements IImageSavingCallback {
public ImageUriPrinter(String imagesFolderAlias) {
mImagesFolderAlias = imagesFolderAlias;
mResources = new ArrayList<String>();
}
public void imageSaving(ImageSavingArgs args) throws Exception {
getResources().add(args.getImageFileName());
// If we specified an image folder alias, we would also need
// to redirect each stream to put its image in the alias folder.
args.setImageStream(new FileOutputStream(MessageFormat.format("{0}/{1}", mImagesFolderAlias, args.getImageFileName())));
args.setKeepImageStreamOpen(false);
}
public String getImagesFolderAlias() {
return mImagesFolderAlias;
}
private final String mImagesFolderAlias;
public ArrayList<String> getResources() {
return mResources;
}
private final ArrayList<String> mResources;
}
getSaveFormat in class SaveOptionsint value. The returned value is one of SaveFormat constants.public void setSaveFormat(int value)
SaveFormat.XAML_FLOW.
Examples:
Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.
public void imageFolder() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
ImageUriPrinter callback = new ImageUriPrinter(getArtifactsDir() + "XamlFlowImageFolderAlias");
// Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we save the document to the XAML save format.
XamlFlowSaveOptions options = new XamlFlowSaveOptions();
Assert.assertEquals(SaveFormat.XAML_FLOW, options.getSaveFormat());
// Use the "ImagesFolder" property to assign a folder in the local file system into which
// Aspose.Words will save all the document's linked images.
options.setImagesFolder(getArtifactsDir() + "XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options.setImagesFolderAlias(getArtifactsDir() + "XamlFlowImageFolderAlias");
options.setImageSavingCallback(callback);
// A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
// We must ensure the folder exists before the callback's streams can put their resources into it.
new File(options.getImagesFolderAlias()).mkdir();
doc.save(getArtifactsDir() + "XamlFlowSaveOptions.ImageFolder.xaml", options);
for (String resource : callback.getResources())
System.out.println("{callback.ImagesFolderAlias}/{resource}");
}
/// <summary>
/// Counts and prints filenames of images while their parent document is converted to flow-form .xaml.
/// </summary>
private static class ImageUriPrinter implements IImageSavingCallback {
public ImageUriPrinter(String imagesFolderAlias) {
mImagesFolderAlias = imagesFolderAlias;
mResources = new ArrayList<String>();
}
public void imageSaving(ImageSavingArgs args) throws Exception {
getResources().add(args.getImageFileName());
// If we specified an image folder alias, we would also need
// to redirect each stream to put its image in the alias folder.
args.setImageStream(new FileOutputStream(MessageFormat.format("{0}/{1}", mImagesFolderAlias, args.getImageFileName())));
args.setKeepImageStreamOpen(false);
}
public String getImagesFolderAlias() {
return mImagesFolderAlias;
}
private final String mImagesFolderAlias;
public ArrayList<String> getResources() {
return mResources;
}
private final ArrayList<String> mResources;
}
setSaveFormat in class SaveOptionsvalue - The corresponding int value. The value must be one of SaveFormat constants.public java.lang.String getImagesFolder()
Remarks:
When you save a Document in XAML format, Aspose.Words needs to save all images embedded in the document as standalone files. getImagesFolder() / setImagesFolder(java.lang.String) allows you to specify where the images will be saved and getImagesFolderAlias() / setImagesFolderAlias(java.lang.String) 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 getImagesFolder() / setImagesFolder(java.lang.String) 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 getImagesFolder() / setImagesFolder(java.lang.String) property or provide custom streams via the getImageSavingCallback() / setImageSavingCallback(com.aspose.words.IImageSavingCallback) event handler.
Examples:
Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.
public void imageFolder() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
ImageUriPrinter callback = new ImageUriPrinter(getArtifactsDir() + "XamlFlowImageFolderAlias");
// Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we save the document to the XAML save format.
XamlFlowSaveOptions options = new XamlFlowSaveOptions();
Assert.assertEquals(SaveFormat.XAML_FLOW, options.getSaveFormat());
// Use the "ImagesFolder" property to assign a folder in the local file system into which
// Aspose.Words will save all the document's linked images.
options.setImagesFolder(getArtifactsDir() + "XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options.setImagesFolderAlias(getArtifactsDir() + "XamlFlowImageFolderAlias");
options.setImageSavingCallback(callback);
// A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
// We must ensure the folder exists before the callback's streams can put their resources into it.
new File(options.getImagesFolderAlias()).mkdir();
doc.save(getArtifactsDir() + "XamlFlowSaveOptions.ImageFolder.xaml", options);
for (String resource : callback.getResources())
System.out.println("{callback.ImagesFolderAlias}/{resource}");
}
/// <summary>
/// Counts and prints filenames of images while their parent document is converted to flow-form .xaml.
/// </summary>
private static class ImageUriPrinter implements IImageSavingCallback {
public ImageUriPrinter(String imagesFolderAlias) {
mImagesFolderAlias = imagesFolderAlias;
mResources = new ArrayList<String>();
}
public void imageSaving(ImageSavingArgs args) throws Exception {
getResources().add(args.getImageFileName());
// If we specified an image folder alias, we would also need
// to redirect each stream to put its image in the alias folder.
args.setImageStream(new FileOutputStream(MessageFormat.format("{0}/{1}", mImagesFolderAlias, args.getImageFileName())));
args.setKeepImageStreamOpen(false);
}
public String getImagesFolderAlias() {
return mImagesFolderAlias;
}
private final String mImagesFolderAlias;
public ArrayList<String> getResources() {
return mResources;
}
private final ArrayList<String> mResources;
}
String value.getImagesFolderAlias(),
setImagesFolderAlias(java.lang.String),
getImageSavingCallback(),
setImageSavingCallback(com.aspose.words.IImageSavingCallback)public void setImagesFolder(java.lang.String value)
Remarks:
When you save a Document in XAML format, Aspose.Words needs to save all images embedded in the document as standalone files. getImagesFolder() / setImagesFolder(java.lang.String) allows you to specify where the images will be saved and getImagesFolderAlias() / setImagesFolderAlias(java.lang.String) 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 getImagesFolder() / setImagesFolder(java.lang.String) 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 getImagesFolder() / setImagesFolder(java.lang.String) property or provide custom streams via the getImageSavingCallback() / setImageSavingCallback(com.aspose.words.IImageSavingCallback) event handler.
Examples:
Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.
public void imageFolder() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
ImageUriPrinter callback = new ImageUriPrinter(getArtifactsDir() + "XamlFlowImageFolderAlias");
// Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we save the document to the XAML save format.
XamlFlowSaveOptions options = new XamlFlowSaveOptions();
Assert.assertEquals(SaveFormat.XAML_FLOW, options.getSaveFormat());
// Use the "ImagesFolder" property to assign a folder in the local file system into which
// Aspose.Words will save all the document's linked images.
options.setImagesFolder(getArtifactsDir() + "XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options.setImagesFolderAlias(getArtifactsDir() + "XamlFlowImageFolderAlias");
options.setImageSavingCallback(callback);
// A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
// We must ensure the folder exists before the callback's streams can put their resources into it.
new File(options.getImagesFolderAlias()).mkdir();
doc.save(getArtifactsDir() + "XamlFlowSaveOptions.ImageFolder.xaml", options);
for (String resource : callback.getResources())
System.out.println("{callback.ImagesFolderAlias}/{resource}");
}
/// <summary>
/// Counts and prints filenames of images while their parent document is converted to flow-form .xaml.
/// </summary>
private static class ImageUriPrinter implements IImageSavingCallback {
public ImageUriPrinter(String imagesFolderAlias) {
mImagesFolderAlias = imagesFolderAlias;
mResources = new ArrayList<String>();
}
public void imageSaving(ImageSavingArgs args) throws Exception {
getResources().add(args.getImageFileName());
// If we specified an image folder alias, we would also need
// to redirect each stream to put its image in the alias folder.
args.setImageStream(new FileOutputStream(MessageFormat.format("{0}/{1}", mImagesFolderAlias, args.getImageFileName())));
args.setKeepImageStreamOpen(false);
}
public String getImagesFolderAlias() {
return mImagesFolderAlias;
}
private final String mImagesFolderAlias;
public ArrayList<String> getResources() {
return mResources;
}
private final ArrayList<String> mResources;
}
value - The corresponding String value.getImagesFolderAlias(),
setImagesFolderAlias(java.lang.String),
getImageSavingCallback(),
setImageSavingCallback(com.aspose.words.IImageSavingCallback)public java.lang.String getImagesFolderAlias()
Remarks:
When you save a Document in XAML format, Aspose.Words needs to save all images embedded in the document as standalone files. getImagesFolder() / setImagesFolder(java.lang.String) allows you to specify where the images will be saved and getImagesFolderAlias() / setImagesFolderAlias(java.lang.String) allows to specify how the image URIs will be constructed.
If getImagesFolderAlias() / setImagesFolderAlias(java.lang.String) is not an empty string, then the image URI written to XAML will be ImagesFolderAlias +
If getImagesFolderAlias() / setImagesFolderAlias(java.lang.String) is an empty string, then the image URI written to XAML will be ImagesFolder +
If getImagesFolderAlias() / setImagesFolderAlias(java.lang.String) is set to '.' (dot), then the image file name will be written to XAML without path regardless of other options.
Examples:
Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.
public void imageFolder() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
ImageUriPrinter callback = new ImageUriPrinter(getArtifactsDir() + "XamlFlowImageFolderAlias");
// Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we save the document to the XAML save format.
XamlFlowSaveOptions options = new XamlFlowSaveOptions();
Assert.assertEquals(SaveFormat.XAML_FLOW, options.getSaveFormat());
// Use the "ImagesFolder" property to assign a folder in the local file system into which
// Aspose.Words will save all the document's linked images.
options.setImagesFolder(getArtifactsDir() + "XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options.setImagesFolderAlias(getArtifactsDir() + "XamlFlowImageFolderAlias");
options.setImageSavingCallback(callback);
// A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
// We must ensure the folder exists before the callback's streams can put their resources into it.
new File(options.getImagesFolderAlias()).mkdir();
doc.save(getArtifactsDir() + "XamlFlowSaveOptions.ImageFolder.xaml", options);
for (String resource : callback.getResources())
System.out.println("{callback.ImagesFolderAlias}/{resource}");
}
/// <summary>
/// Counts and prints filenames of images while their parent document is converted to flow-form .xaml.
/// </summary>
private static class ImageUriPrinter implements IImageSavingCallback {
public ImageUriPrinter(String imagesFolderAlias) {
mImagesFolderAlias = imagesFolderAlias;
mResources = new ArrayList<String>();
}
public void imageSaving(ImageSavingArgs args) throws Exception {
getResources().add(args.getImageFileName());
// If we specified an image folder alias, we would also need
// to redirect each stream to put its image in the alias folder.
args.setImageStream(new FileOutputStream(MessageFormat.format("{0}/{1}", mImagesFolderAlias, args.getImageFileName())));
args.setKeepImageStreamOpen(false);
}
public String getImagesFolderAlias() {
return mImagesFolderAlias;
}
private final String mImagesFolderAlias;
public ArrayList<String> getResources() {
return mResources;
}
private final ArrayList<String> mResources;
}
String value.getImagesFolder(),
setImagesFolder(java.lang.String),
getImageSavingCallback(),
setImageSavingCallback(com.aspose.words.IImageSavingCallback)public void setImagesFolderAlias(java.lang.String value)
Remarks:
When you save a Document in XAML format, Aspose.Words needs to save all images embedded in the document as standalone files. getImagesFolder() / setImagesFolder(java.lang.String) allows you to specify where the images will be saved and getImagesFolderAlias() / setImagesFolderAlias(java.lang.String) allows to specify how the image URIs will be constructed.
If getImagesFolderAlias() / setImagesFolderAlias(java.lang.String) is not an empty string, then the image URI written to XAML will be ImagesFolderAlias +
If getImagesFolderAlias() / setImagesFolderAlias(java.lang.String) is an empty string, then the image URI written to XAML will be ImagesFolder +
If getImagesFolderAlias() / setImagesFolderAlias(java.lang.String) is set to '.' (dot), then the image file name will be written to XAML without path regardless of other options.
Examples:
Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.
public void imageFolder() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
ImageUriPrinter callback = new ImageUriPrinter(getArtifactsDir() + "XamlFlowImageFolderAlias");
// Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we save the document to the XAML save format.
XamlFlowSaveOptions options = new XamlFlowSaveOptions();
Assert.assertEquals(SaveFormat.XAML_FLOW, options.getSaveFormat());
// Use the "ImagesFolder" property to assign a folder in the local file system into which
// Aspose.Words will save all the document's linked images.
options.setImagesFolder(getArtifactsDir() + "XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options.setImagesFolderAlias(getArtifactsDir() + "XamlFlowImageFolderAlias");
options.setImageSavingCallback(callback);
// A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
// We must ensure the folder exists before the callback's streams can put their resources into it.
new File(options.getImagesFolderAlias()).mkdir();
doc.save(getArtifactsDir() + "XamlFlowSaveOptions.ImageFolder.xaml", options);
for (String resource : callback.getResources())
System.out.println("{callback.ImagesFolderAlias}/{resource}");
}
/// <summary>
/// Counts and prints filenames of images while their parent document is converted to flow-form .xaml.
/// </summary>
private static class ImageUriPrinter implements IImageSavingCallback {
public ImageUriPrinter(String imagesFolderAlias) {
mImagesFolderAlias = imagesFolderAlias;
mResources = new ArrayList<String>();
}
public void imageSaving(ImageSavingArgs args) throws Exception {
getResources().add(args.getImageFileName());
// If we specified an image folder alias, we would also need
// to redirect each stream to put its image in the alias folder.
args.setImageStream(new FileOutputStream(MessageFormat.format("{0}/{1}", mImagesFolderAlias, args.getImageFileName())));
args.setKeepImageStreamOpen(false);
}
public String getImagesFolderAlias() {
return mImagesFolderAlias;
}
private final String mImagesFolderAlias;
public ArrayList<String> getResources() {
return mResources;
}
private final ArrayList<String> mResources;
}
value - The corresponding String value.getImagesFolder(),
setImagesFolder(java.lang.String),
getImageSavingCallback(),
setImageSavingCallback(com.aspose.words.IImageSavingCallback)public IImageSavingCallback getImageSavingCallback()
Examples:
Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.
public void imageFolder() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
ImageUriPrinter callback = new ImageUriPrinter(getArtifactsDir() + "XamlFlowImageFolderAlias");
// Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we save the document to the XAML save format.
XamlFlowSaveOptions options = new XamlFlowSaveOptions();
Assert.assertEquals(SaveFormat.XAML_FLOW, options.getSaveFormat());
// Use the "ImagesFolder" property to assign a folder in the local file system into which
// Aspose.Words will save all the document's linked images.
options.setImagesFolder(getArtifactsDir() + "XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options.setImagesFolderAlias(getArtifactsDir() + "XamlFlowImageFolderAlias");
options.setImageSavingCallback(callback);
// A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
// We must ensure the folder exists before the callback's streams can put their resources into it.
new File(options.getImagesFolderAlias()).mkdir();
doc.save(getArtifactsDir() + "XamlFlowSaveOptions.ImageFolder.xaml", options);
for (String resource : callback.getResources())
System.out.println("{callback.ImagesFolderAlias}/{resource}");
}
/// <summary>
/// Counts and prints filenames of images while their parent document is converted to flow-form .xaml.
/// </summary>
private static class ImageUriPrinter implements IImageSavingCallback {
public ImageUriPrinter(String imagesFolderAlias) {
mImagesFolderAlias = imagesFolderAlias;
mResources = new ArrayList<String>();
}
public void imageSaving(ImageSavingArgs args) throws Exception {
getResources().add(args.getImageFileName());
// If we specified an image folder alias, we would also need
// to redirect each stream to put its image in the alias folder.
args.setImageStream(new FileOutputStream(MessageFormat.format("{0}/{1}", mImagesFolderAlias, args.getImageFileName())));
args.setKeepImageStreamOpen(false);
}
public String getImagesFolderAlias() {
return mImagesFolderAlias;
}
private final String mImagesFolderAlias;
public ArrayList<String> getResources() {
return mResources;
}
private final ArrayList<String> mResources;
}
IImageSavingCallback value.public void setImageSavingCallback(IImageSavingCallback value)
Examples:
Shows how to print the filenames of linked images created while converting a document to flow-form .xaml.
public void imageFolder() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
ImageUriPrinter callback = new ImageUriPrinter(getArtifactsDir() + "XamlFlowImageFolderAlias");
// Create a "XamlFlowSaveOptions" object, which we can pass to the document's "Save" method
// to modify how we save the document to the XAML save format.
XamlFlowSaveOptions options = new XamlFlowSaveOptions();
Assert.assertEquals(SaveFormat.XAML_FLOW, options.getSaveFormat());
// Use the "ImagesFolder" property to assign a folder in the local file system into which
// Aspose.Words will save all the document's linked images.
options.setImagesFolder(getArtifactsDir() + "XamlFlowImageFolder");
// Use the "ImagesFolderAlias" property to use this folder
// when constructing image URIs instead of the images folder's name.
options.setImagesFolderAlias(getArtifactsDir() + "XamlFlowImageFolderAlias");
options.setImageSavingCallback(callback);
// A folder specified by "ImagesFolderAlias" will need to contain the resources instead of "ImagesFolder".
// We must ensure the folder exists before the callback's streams can put their resources into it.
new File(options.getImagesFolderAlias()).mkdir();
doc.save(getArtifactsDir() + "XamlFlowSaveOptions.ImageFolder.xaml", options);
for (String resource : callback.getResources())
System.out.println("{callback.ImagesFolderAlias}/{resource}");
}
/// <summary>
/// Counts and prints filenames of images while their parent document is converted to flow-form .xaml.
/// </summary>
private static class ImageUriPrinter implements IImageSavingCallback {
public ImageUriPrinter(String imagesFolderAlias) {
mImagesFolderAlias = imagesFolderAlias;
mResources = new ArrayList<String>();
}
public void imageSaving(ImageSavingArgs args) throws Exception {
getResources().add(args.getImageFileName());
// If we specified an image folder alias, we would also need
// to redirect each stream to put its image in the alias folder.
args.setImageStream(new FileOutputStream(MessageFormat.format("{0}/{1}", mImagesFolderAlias, args.getImageFileName())));
args.setKeepImageStreamOpen(false);
}
public String getImagesFolderAlias() {
return mImagesFolderAlias;
}
private final String mImagesFolderAlias;
public ArrayList<String> getResources() {
return mResources;
}
private final ArrayList<String> mResources;
}
value - The corresponding IImageSavingCallback value.public boolean getReplaceBackslashWithYenSign()
false.
Remarks:
By default, Aspose.Words mimics MS Word's behavior and doesn't replace backslash characters with yen signs in generated XAML documents. However, previous versions of Aspose.Words performed such replacements in certain scenarios. This flag enables backward compatibility with previous versions of Aspose.Words.
Examples:
Shows how to replace backslash characters with yen signs (Xaml).
Document doc = new Document(getMyDir() + "Korean backslash symbol.docx");
// By default, Aspose.Words mimics MS Word's behavior and doesn't replace backslash characters with yen signs in
// generated HTML documents. However, previous versions of Aspose.Words performed such replacements in certain
// scenarios. This flag enables backward compatibility with previous versions of Aspose.Words.
XamlFlowSaveOptions saveOptions = new XamlFlowSaveOptions();
saveOptions.setReplaceBackslashWithYenSign(true);
doc.save(getArtifactsDir() + "HtmlSaveOptions.ReplaceBackslashWithYenSign.xaml", saveOptions);
boolean value.public void setReplaceBackslashWithYenSign(boolean value)
false.
Remarks:
By default, Aspose.Words mimics MS Word's behavior and doesn't replace backslash characters with yen signs in generated XAML documents. However, previous versions of Aspose.Words performed such replacements in certain scenarios. This flag enables backward compatibility with previous versions of Aspose.Words.
Examples:
Shows how to replace backslash characters with yen signs (Xaml).
Document doc = new Document(getMyDir() + "Korean backslash symbol.docx");
// By default, Aspose.Words mimics MS Word's behavior and doesn't replace backslash characters with yen signs in
// generated HTML documents. However, previous versions of Aspose.Words performed such replacements in certain
// scenarios. This flag enables backward compatibility with previous versions of Aspose.Words.
XamlFlowSaveOptions saveOptions = new XamlFlowSaveOptions();
saveOptions.setReplaceBackslashWithYenSign(true);
doc.save(getArtifactsDir() + "HtmlSaveOptions.ReplaceBackslashWithYenSign.xaml", saveOptions);
value - The corresponding boolean value.