public class

W2ML

extends Object
java.lang.Object
   ↳ com.priint.comet.renderer.util.W2ML

Summary

Public Methods
static int calculateSpreadIndex(int pageIndex, boolean facingPages, PageType firstPageType)

Calculates the spread index for a given page index

The spread index is calculated based on the following assumptions:

  • the document either has 'facing pages' or not
  • facing pages means: there are exactly 2 pages per spread
  • all spreads contain the same number of pages
  • if the first page is a right page, the first spread contains only one page
  • if the last page is a left page, the last spread contains only one page also

final static void clearContent(W2MLDocument from)

Removes all content of a W2MLDocument.

final static W2MLDocument documentFromPath(Path path)

Creates a W2MLDocument from file denoted by path

@return
final static W2MLDocument documentFromStream(InputStream in)
final static W2MLDocument documentFromString(String w2mlStr)
final static String documentToString(W2MLDocument document)
final static W2MLDocument extractSpread(byte[] source, int spreadIndex)
final static void removeElement(W2MLDocument from, int elementId)
final static void removePage(W2MLDocument from, int pageIndex)
final static void removePages(W2MLDocument from)

Removes all pages and related content from a W2ML document

Removes all pages page by page and related content from a W2MLDocument.org.junit.Test The result is an empty document, containing just masterpages, style definitions, swatches etc.org.junit.Test Note: a renderer document requires at least one page.

[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static int calculateSpreadIndex (int pageIndex, boolean facingPages, PageType firstPageType)

Calculates the spread index for a given page index

The spread index is calculated based on the following assumptions:

  • the document either has 'facing pages' or not
  • facing pages means: there are exactly 2 pages per spread
  • all spreads contain the same number of pages
  • if the first page is a right page, the first spread contains only one page
  • if the last page is a left page, the last spread contains only one page also

Parameters
pageIndex 0-based index of the page
facingPages whether document has facing pages or not
firstPageType type of the first page

public static final void clearContent (W2MLDocument from)

Removes all content of a W2MLDocument.

Removes all content (including pages, but not master pages) from a document by clearing the root nodes of content related elements in the documents DOM.

See removePages(W2MLDocument) for further documentation, also Note: the result of this method call is literally the same like when calling removePages(W2MLDocument). clearContent(W2MLDocument) may be slightly faster, but in terms of observing document integrity less accurate than removePages(W2MLDocument). One or the other may be removed in future or just delegate to the other, depending on which works better in "real life".

public static final W2MLDocument documentFromPath (Path path)

Creates a W2MLDocument from file denoted by path

@return

public static final W2MLDocument documentFromStream (InputStream in)

public static final W2MLDocument documentFromString (String w2mlStr)

public static final String documentToString (W2MLDocument document)

public static final W2MLDocument extractSpread (byte[] source, int spreadIndex)

public static final void removeElement (W2MLDocument from, int elementId)

public static final void removePage (W2MLDocument from, int pageIndex)

public static final void removePages (W2MLDocument from)

Removes all pages and related content from a W2ML document

Removes all pages page by page and related content from a W2MLDocument.org.junit.Test The result is an empty document, containing just masterpages, style definitions, swatches etc.org.junit.Test Note: a renderer document requires at least one page. Unlike common rendering applications (such as Adobe InDesign® or Adobe Illustrator®), the pdf renderer does not crash, if a zero-page document is opened, but adds a single default page instead.org.junit.Test Hence, the page count reported by the renderer will always be at least 1 and not 0, what you might expect after removing all pages.

Note: the result of this method call is literally the same like when calling clearContent(W2MLDocument). These methods only differ in internal functionality. One or the other may be removed in future or just delegate to the other, depending on which works better in "real life".

Parameters
from document to delete from