java.lang.Object
com.aspose.words.PageLayoutEvent
public class PageLayoutEvent
- extends java.lang.Object
Utility class containing constants.
A code of event raised during page layout model build and rendering.
Page layout model is built in two steps.
First, "conversion step", this is when page layout pulls document content and creates object graph.
Second, "reflow step", this is when structures are split, merged and arranged into pages.
Depending of the operation which triggered build, page layout model may or may not be further rendered into fixed page format.
For example, computing number of pages in the document or updating fields does not require rendering, whereas export to Pdf does.Example:
Shows how to track layout/rendering progress with layout callback.
@Test
public void pageLayoutCallback() throws Exception {
Document doc = new Document(getMyDir() + "Document.docx");
doc.getLayoutOptions().setCallback(new RenderPageLayoutCallback());
doc.updatePageLayout();
}
private static class RenderPageLayoutCallback implements IPageLayoutCallback {
public void notify(PageLayoutCallbackArgs a) throws Exception {
switch (a.getEvent()) {
case PageLayoutEvent.PART_REFLOW_FINISHED:
notifyPartFinished(a);
break;
}
}
private void notifyPartFinished(PageLayoutCallbackArgs a) throws Exception {
System.out.println("Part at page {a.PageIndex + 1} reflow");
renderPage(a, a.getPageIndex());
}
private void renderPage(PageLayoutCallbackArgs a, int pageIndex) throws Exception {
ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.PNG);
saveOptions.setPageIndex(pageIndex);
saveOptions.setPageCount(1);
OutputStream stream = new FileOutputStream(getArtifactsDir() + MessageFormat.format("PageLayoutCallback.page-{0} {1}.png", pageIndex + 1, ++mNum));
try {
a.getDocument().save(stream, saveOptions);
} finally {
if (stream != null) stream.close();
}
}
private int mNum;
}
Field Summary |
static final int | NONE = 0 | |
Default value
|
static final int | WATCH_DOG = 1 | |
Corresponds to a checkpoint in code which is often visited and which is suitable to abort process.
While inside IPageLayoutCallback.notify(com.aspose.words.PageLayoutCallbackArgs) throw custom exception to abort process.
You can throw when handling any callback event to abort process.
Note that if process is aborted the page layout model remains in undefined state. If process is aborted upon reflow of a complete page,
however, it should be possible to use layout model up to the end of that page. |
static final int | BUILD_STARTED = 2 | |
Build of the page layout has started. Fired once.
This is the first event which occurs when Document.updatePageLayout() is called.
|
static final int | BUILD_FINISHED = 3 | |
Build of the page layout has finished. Fired once.
This is the last event which occurs when Document.updatePageLayout() is called.
|
static final int | CONVERSION_STARTED = 4 | |
Conversion of document model to page layout has started. Fired once.
This occurs when layout model starts pulling document content.
|
static final int | CONVERSION_FINISHED = 5 | |
Conversion of document model to page layout has finished. Fired once.
This occurs when layout model stops pulling document content.
|
static final int | REFLOW_STARTED = 6 | |
Reflow of the page layout has started. Fired once.
This occurs when layout model starts reflowing document content.
|
static final int | REFLOW_FINISHED = 7 | |
Reflow of the page layout has finished. Fired once.
This occurs when layout model stops reflowing document content.
|
static final int | PART_REFLOW_STARTED = 8 | |
Reflow of the page has started.
Note that page may reflow multiple times and that reflow may restart before it is finished.
|
static final int | PART_REFLOW_FINISHED = 9 | |
Reflow of the page has finished.
Note that page may reflow multiple times and that reflow may restart before it is finished.
|
static final int | PART_RENDERING_STARTED = 10 | |
Rendering of page has started. This is fired once per page.
|
static final int | PART_RENDERING_FINISHED = 11 | |
Rendering of page has finished. This is fired once per page.
|
NONE = 0 | |
public static final int NONE |
-
Default value
WATCH_DOG = 1 | |
public static final int WATCH_DOG |
-
Corresponds to a checkpoint in code which is often visited and which is suitable to abort process.
While inside IPageLayoutCallback.notify(com.aspose.words.PageLayoutCallbackArgs) throw custom exception to abort process.
You can throw when handling any callback event to abort process.
Note that if process is aborted the page layout model remains in undefined state. If process is aborted upon reflow of a complete page,
however, it should be possible to use layout model up to the end of that page.
BUILD_STARTED = 2 | |
public static final int BUILD_STARTED |
-
Build of the page layout has started. Fired once.
This is the first event which occurs when Document.updatePageLayout() is called.
BUILD_FINISHED = 3 | |
public static final int BUILD_FINISHED |
-
Build of the page layout has finished. Fired once.
This is the last event which occurs when Document.updatePageLayout() is called.
CONVERSION_STARTED = 4 | |
public static final int CONVERSION_STARTED |
-
Conversion of document model to page layout has started. Fired once.
This occurs when layout model starts pulling document content.
CONVERSION_FINISHED = 5 | |
public static final int CONVERSION_FINISHED |
-
Conversion of document model to page layout has finished. Fired once.
This occurs when layout model stops pulling document content.
REFLOW_STARTED = 6 | |
public static final int REFLOW_STARTED |
-
Reflow of the page layout has started. Fired once.
This occurs when layout model starts reflowing document content.
REFLOW_FINISHED = 7 | |
public static final int REFLOW_FINISHED |
-
Reflow of the page layout has finished. Fired once.
This occurs when layout model stops reflowing document content.
PART_REFLOW_STARTED = 8 | |
public static final int PART_REFLOW_STARTED |
-
Reflow of the page has started.
Note that page may reflow multiple times and that reflow may restart before it is finished.
- See Also:
- PageLayoutCallbackArgs.PageIndex
PART_REFLOW_FINISHED = 9 | |
public static final int PART_REFLOW_FINISHED |
-
Reflow of the page has finished.
Note that page may reflow multiple times and that reflow may restart before it is finished.
- See Also:
- PageLayoutCallbackArgs.PageIndex
PART_RENDERING_STARTED = 10 | |
public static final int PART_RENDERING_STARTED |
-
Rendering of page has started. This is fired once per page.
PART_RENDERING_FINISHED = 11 | |
public static final int PART_RENDERING_FINISHED |
-
Rendering of page has finished. This is fired once per page.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.