import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.FOEventHandler;
-import org.apache.fop.fo.extensions.Outline;
import org.apache.fop.fo.extensions.Bookmarks;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.Root;
}
}
- /**
- * End the document.
- *
- * @throws SAXException if there is some error
- */
- public void endDocument() throws SAXException {
- addBookmarks(rootFObj.getBookmarks());
-
- model.endDocument();
-
- if (outputStatistics) {
- long memoryNow = runtime.totalMemory() - runtime.freeMemory();
- long memoryUsed = (memoryNow - initialMemory) / 1024L;
- long timeUsed = System.currentTimeMillis() - startTime;
- log.debug("Initial heap size: " + (initialMemory / 1024L) + "Kb");
- log.debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
- log.debug("Total memory used: " + memoryUsed + "Kb");
- log.debug("Total time used: " + timeUsed + "ms");
- log.debug("Pages rendered: " + pageCount);
- if (pageCount > 0) {
- log.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
- }
- }
- }
-
/**
* End the PageSequence.
* The PageSequence formats Pages and adds them to the AreaTree.
}
/**
- * Create the bookmark data in the area tree.
+ * End the document.
+ *
+ * @throws SAXException if there is some error
*/
- private void addBookmarks(Bookmarks bookmarks) {
- if (bookmarks == null) {
- return;
- }
+ public void endDocument() throws SAXException {
- BookmarkData data = new BookmarkData();
- for (int count = 0; count < bookmarks.getOutlines().size(); count++) {
- Outline out = (Outline)(bookmarks.getOutlines()).get(count);
- data.addSubData(createBookmarkData(out));
+ // process fo:bookmark-tree
+ Bookmarks bookmarks = rootFObj.getBookmarks();
+ if (bookmarks != null) {
+ BookmarkData data = new BookmarkData(bookmarks);
+ addOffDocumentItem(data);
}
- addOffDocumentItem(data);
- }
- /**
- * Create and return the bookmark data for this outline.
- * This creates a bookmark data with the destination
- * and adds all the data from child outlines.
- *
- * @param outline the Outline object for which a bookmark entry should be
- * created
- * @return the new bookmark data
- */
- private BookmarkData createBookmarkData(Outline outline) {
- BookmarkData data = new BookmarkData(outline.getInternalDestination());
- data.setLabel(outline.getLabel());
- for (int count = 0; count < outline.getOutlines().size(); count++) {
- Outline out = (Outline)(outline.getOutlines()).get(count);
- data.addSubData(createBookmarkData(out));
+ model.endDocument();
+
+ if (outputStatistics) {
+ long memoryNow = runtime.totalMemory() - runtime.freeMemory();
+ long memoryUsed = (memoryNow - initialMemory) / 1024L;
+ long timeUsed = System.currentTimeMillis() - startTime;
+ log.debug("Initial heap size: " + (initialMemory / 1024L) + "Kb");
+ log.debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
+ log.debug("Total memory used: " + memoryUsed + "Kb");
+ log.debug("Total time used: " + timeUsed + "ms");
+ log.debug("Pages rendered: " + pageCount);
+ if (pageCount > 0) {
+ log.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
+ }
}
- return data;
}
/**
import java.util.List;
import java.util.HashMap;
+import org.apache.fop.fo.extensions.Bookmarks;
+import org.apache.fop.fo.extensions.Outline;
+
/**
* An instance of this class is either a PDF bookmark-tree and
* its child bookmark-items, or a bookmark-item and the child
* Create a new bookmark data object.
* This should only be called by the bookmark-tree item because
* it has no idref item that needs to be resolved.
+ *
+ * @param bookmarks fo:bookmark-tree for this document
*/
- public BookmarkData() {
+ public BookmarkData(Bookmarks bookmarks) {
idRef = null;
whenToProcess = END_OF_DOC;
+
+ for (int count = 0; count < bookmarks.getOutlines().size(); count++) {
+ Outline out = (Outline)(bookmarks.getOutlines()).get(count);
+ addSubData(createBookmarkData(out));
+ }
}
/**
public String getName() {
return "Bookmarks";
}
+
+ /**
+ * Create and return the bookmark data for this outline.
+ * This creates a bookmark data with the destination
+ * and adds all the data from child outlines.
+ *
+ * @param outline the Outline object for which a bookmark entry should be
+ * created
+ * @return the new bookmark data
+ */
+ private BookmarkData createBookmarkData(Outline outline) {
+ BookmarkData data = new BookmarkData(outline.getInternalDestination());
+ data.setLabel(outline.getLabel());
+ for (int count = 0; count < outline.getOutlines().size(); count++) {
+ Outline out = (Outline)(outline.getOutlines()).get(count);
+ data.addSubData(createBookmarkData(out));
+ }
+ return data;
+ }
+
}