public interface IPageSavingCallback
Example:
Shows how separate pages are saved when a document is exported to fixed page format.
public void pageFileName() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
HtmlFixedSaveOptions htmlFixedSaveOptions =
new HtmlFixedSaveOptions();
{
htmlFixedSaveOptions.setPageIndex(0);
htmlFixedSaveOptions.setPageCount(doc.getPageCount());
}
htmlFixedSaveOptions.setPageSavingCallback(new CustomPageFileNamePageSavingCallback());
doc.save(getArtifactsDir() + "SavingCallback.PageFileName.html", htmlFixedSaveOptions);
ArrayList<String> filePaths = DocumentHelper.directoryGetFiles(getArtifactsDir(), "SavingCallback.PageFileName.Page_*.html");
for (int i = 0; i < doc.getPageCount(); i++) {
String file = getArtifactsDir() + MessageFormat.format("SavingCallback.PageFileName.Page_{0}.html", i);
}
}
/// <summary>
/// Custom PageFileName is specified.
/// </summary>
private static class CustomPageFileNamePageSavingCallback implements IPageSavingCallback {
public void pageSaving(PageSavingArgs args) throws Exception {
String outFileName = getArtifactsDir() + MessageFormat.format("SavingCallback.PageFileName.Page_{0}.html", args.getPageIndex());
// Specify name of the output file for the current page either in this
args.setPageFileName(outFileName);
// ..or by setting up a custom stream
args.setPageStream(new FileOutputStream(outFileName));
Assert.assertFalse(args.getKeepPageStreamOpen());
}
}
| Method Summary | ||
|---|---|---|
abstract void | pageSaving(PageSavingArgs args) | |
Called when Aspose.Words saves a separate page to fixed page formats.
|
||
public abstract void pageSaving(PageSavingArgs args) throws java.lang.Exception
Example:
Shows how separate pages are saved when a document is exported to fixed page format.
public void pageFileName() throws Exception {
Document doc = new Document(getMyDir() + "Rendering.docx");
HtmlFixedSaveOptions htmlFixedSaveOptions =
new HtmlFixedSaveOptions();
{
htmlFixedSaveOptions.setPageIndex(0);
htmlFixedSaveOptions.setPageCount(doc.getPageCount());
}
htmlFixedSaveOptions.setPageSavingCallback(new CustomPageFileNamePageSavingCallback());
doc.save(getArtifactsDir() + "SavingCallback.PageFileName.html", htmlFixedSaveOptions);
ArrayList<String> filePaths = DocumentHelper.directoryGetFiles(getArtifactsDir(), "SavingCallback.PageFileName.Page_*.html");
for (int i = 0; i < doc.getPageCount(); i++) {
String file = getArtifactsDir() + MessageFormat.format("SavingCallback.PageFileName.Page_{0}.html", i);
}
}
/// <summary>
/// Custom PageFileName is specified.
/// </summary>
private static class CustomPageFileNamePageSavingCallback implements IPageSavingCallback {
public void pageSaving(PageSavingArgs args) throws Exception {
String outFileName = getArtifactsDir() + MessageFormat.format("SavingCallback.PageFileName.Page_{0}.html", args.getPageIndex());
// Specify name of the output file for the current page either in this
args.setPageFileName(outFileName);
// ..or by setting up a custom stream
args.setPageStream(new FileOutputStream(outFileName));
Assert.assertFalse(args.getKeepPageStreamOpen());
}
}