public class CSSBoxTree extends PDFDomTree
BoxFactory result for HTML documents. The resulting tree contains the boxes
together with their styles. Its further processing (layout and positioning) is the same as for the tree of boxes
obtained from the HTML documents.PDFDomTree.HtmlDivLine| Modifier and Type | Field and Description |
|---|---|
protected URL |
baseurl
Base URL used for eventual references in the input file
|
protected org.fit.cssbox.layout.BlockBox |
body
BODY box
|
protected org.fit.cssbox.layout.BrowserConfig |
config
Used CSSBox configuration
|
protected org.fit.cssbox.layout.VisualContext |
ctx
Root visual context
|
protected Dimension |
dim
Preferred dimensions of the result
|
protected Graphics2D |
g
Root graphics context
|
protected org.fit.cssbox.layout.BlockBox |
html
HTML box
|
protected int |
next_order
Internal counter for assigning the node IDs
|
protected org.fit.cssbox.layout.BlockBox |
pagebox
The box representing the page that is currently being created
|
protected cz.vutbr.web.css.TermNumeric.Unit |
unit
Length units used in the output
|
protected float |
unknownFontScale
Scale factor for unknown fonts - it is used to prevent overlaping the boxes when an inappropriate font is used
|
protected org.fit.cssbox.layout.Viewport |
viewport
The resulting viewport
|
curpage, defaultStyle, doc, globalStyle, head, pagecnt, textcnt, titlecssFontFamily, cssFontStyle, cssFontWeight, cur_x, cur_y, curstyle, disableGraphics, disableImageData, disableImages, endPage, fontTable, graphicsPath, lastDia, lastText, path_start_x, path_start_y, path_x, path_y, pdFontType, pdpage, startPage, style, textLine, textMetrics, UNIT| Constructor and Description |
|---|
CSSBoxTree(Graphics2D g,
org.fit.cssbox.layout.VisualContext ctx,
Dimension dim,
URL baseurl)
Creates a new instance bound to certain graphic context.
|
| Modifier and Type | Method and Description |
|---|---|
protected Element |
createAnonymousElement(Document doc,
String name,
String display)
Creates a new DOM element that represents an anonymous box in a document.
|
protected org.fit.cssbox.layout.BlockBox |
createBlock(org.fit.cssbox.layout.BlockBox parent,
Element n,
boolean replaced)
Creates a new block box from the given element with the given parent.
|
protected cz.vutbr.web.css.NodeData |
createBlockStyle()
Creates an empty block style definition.
|
protected cz.vutbr.web.css.NodeData |
createBodyStyle()
Creates a style definition used for the body element.
|
protected cz.vutbr.web.css.Declaration |
createDeclaration(String property,
cz.vutbr.web.css.Term<?> term)
Creates a single property declaration.
|
protected void |
createDocument()
Creates a new empty HTML document tree.
|
protected cz.vutbr.web.css.NodeData |
createLineStyle(float x1,
float y1,
float x2,
float y2) |
protected cz.vutbr.web.css.NodeData |
createPageStyle()
Creates a style definition used for pages.
|
protected cz.vutbr.web.css.NodeData |
createRectangleStyle(float x,
float y,
float width,
float height,
boolean stroke,
boolean fill)
Creates the style definition used for a rectangle element based on the given properties of the rectangle
|
protected org.fit.cssbox.layout.TextBox |
createTextBox(org.fit.cssbox.layout.BlockBox contblock,
Text n)
Creates a text box with the given parent and text node assigned.
|
protected cz.vutbr.web.css.NodeData |
createTextStyle(BoxStyle style,
float width)
Creates the style declaration for a text box based on the given
BoxStyle structure. |
org.fit.cssbox.layout.BrowserConfig |
getConfig() |
int |
getLastId()
Obtains the first unused ID of the box.
|
org.fit.cssbox.layout.Viewport |
getViewport()
Obtains the resulting viewport that represents the root node of the resulting box tree.
|
void |
processDocument(org.apache.pdfbox.pdmodel.PDDocument pdfdocument,
int startPage,
int endPage) |
protected void |
renderImage(float x,
float y,
float width,
float height,
ImageResource resource)
Adds an image to the current page.
|
protected void |
renderPath(List<PathSegment> path,
boolean stroke,
boolean fill)
Adds a rectangle to the current page on the specified position.
|
protected void |
renderText(String data,
TextMetrics metrics)
Creates a new text box in the current page.
|
void |
setConfig(org.fit.cssbox.layout.BrowserConfig config) |
protected void |
showGlyph(org.apache.pdfbox.util.Matrix arg0,
org.apache.pdfbox.pdmodel.font.PDFont arg1,
int arg2,
String arg3,
org.apache.pdfbox.util.Vector arg4) |
protected void |
startNewPage()
Adds a new page to the resulting document and makes it a current (active) page.
|
createDOM, createFontFaces, createGlobalStyle, createImageElement, createLineElement, createPageElement, createPathImage, createRectangleElement, createTextElement, createTextElement, endDocument, getDocument, startDocument, updateFontTable, writeTextcolorString, colorString, colorString, createCurrentPageTransformation, finishBox, floatValue, getCurrentMediaBox, getDisableGraphics, getDisableImageData, getDisableImages, getEndPage, getLength, getStartPage, getTextDirectionality, getTextDirectionality, getTitle, intValue, isReversed, processImageOperation, processOperator, processPage, processTextPosition, setDisableGraphics, setDisableImageData, setDisableImages, setEndPage, setStartPage, stringValue, toRectangle, transformLength, transformPosition, updateStyleendArticle, endPage, getAddMoreFormatting, getArticleEnd, getArticleStart, getAverageCharTolerance, getCurrentPageNo, getDropThreshold, getEndBookmark, getCharactersByArticle, getIndentThreshold, getLineSeparator, getListItemPatterns, getOutput, getPageEnd, getPageStart, getParagraphEnd, getParagraphStart, getSeparateByBeads, getSortByPosition, getSpacingTolerance, getStartBookmark, getSuppressDuplicateOverlappingText, getText, getWordSeparator, matchPattern, processPages, setAddMoreFormatting, setArticleEnd, setArticleStart, setAverageCharTolerance, setDropThreshold, setEndBookmark, setIndentThreshold, setLineSeparator, setListItemPatterns, setPageEnd, setPageStart, setParagraphEnd, setParagraphStart, setShouldSeparateByBeads, setSortByPosition, setSpacingTolerance, setStartBookmark, setSuppressDuplicateOverlappingText, setWordSeparator, startArticle, startArticle, startPage, writeCharacters, writeLineSeparator, writePage, writePageEnd, writePageStart, writeParagraphEnd, writeParagraphSeparator, writeParagraphStart, writeString, writeString, writeWordSeparatoraddOperator, applyTextAdjustment, beginText, endText, getAppearance, getCurrentPage, getGraphicsStackSize, getGraphicsState, getInitialMatrix, getResources, getTextLineMatrix, getTextMatrix, operatorException, processAnnotation, processChildStream, processOperator, processSoftMask, processTilingPattern, processTilingPattern, processTransparencyGroup, processType3Stream, registerOperatorProcessor, restoreGraphicsStack, restoreGraphicsState, saveGraphicsStack, saveGraphicsState, setLineDashPattern, setTextLineMatrix, setTextMatrix, showAnnotation, showFontGlyph, showForm, showText, showTextString, showTextStrings, showTransparencyGroup, showType3Glyph, transformedPoint, transformWidth, unsupportedOperatorprotected float unknownFontScale
protected cz.vutbr.web.css.TermNumeric.Unit unit
protected Graphics2D g
protected org.fit.cssbox.layout.VisualContext ctx
protected Dimension dim
protected URL baseurl
protected org.fit.cssbox.layout.Viewport viewport
protected org.fit.cssbox.layout.BlockBox html
protected org.fit.cssbox.layout.BlockBox body
protected org.fit.cssbox.layout.BlockBox pagebox
protected org.fit.cssbox.layout.BrowserConfig config
protected int next_order
public CSSBoxTree(Graphics2D g, org.fit.cssbox.layout.VisualContext ctx, Dimension dim, URL baseurl) throws IOException, ParserConfigurationException
g - The graphic context used for displaying the rendered result. It is used for obtaining the font metrics.ctx - The initial CSSBox visual context used for the viewport.dim - The initial dimensions of the viewport. The resulting dimensions may be updated according to the page contents.baseurl - Base url used for loading referenced objects.IOExceptionParserConfigurationExceptionpublic org.fit.cssbox.layout.BrowserConfig getConfig()
public void setConfig(org.fit.cssbox.layout.BrowserConfig config)
public org.fit.cssbox.layout.Viewport getViewport()
public int getLastId()
public void processDocument(org.apache.pdfbox.pdmodel.PDDocument pdfdocument,
int startPage,
int endPage)
throws IOException
IOExceptionprotected void createDocument()
throws ParserConfigurationException
PDFDomTreecreateDocument in class PDFDomTreeParserConfigurationExceptionprotected void startNewPage()
PDFBoxTreestartNewPage in class PDFDomTreeprotected void renderText(String data, TextMetrics metrics)
PDFBoxTreePDFBoxTree.curstyle property.renderText in class PDFDomTreedata - The text contents.protected void renderPath(List<PathSegment> path, boolean stroke, boolean fill)
PDFBoxTreerenderPath in class PDFDomTreestroke - should there be a stroke around?fill - should the rectangle be filled?protected void renderImage(float x,
float y,
float width,
float height,
ImageResource resource)
throws IOException
PDFBoxTreerenderImage in class PDFDomTreex - the X coordinate of the imagey - the Y coordinate of the imagewidth - the width coordinate of the imageheight - the height coordinate of the imageresource - the image data depending on the specified typeIOExceptionprotected Element createAnonymousElement(Document doc, String name, String display)
doc - the documentname - the anonymous element name (generally arbitrary)display - the display style value for the blockprotected org.fit.cssbox.layout.BlockBox createBlock(org.fit.cssbox.layout.BlockBox parent,
Element n,
boolean replaced)
parent - The parent box in the tree of boxes.n - The element that this box belongs to.replaced - When set to true, a replaced block box will be created. Otherwise, a normal non-replaced block will be created.protected org.fit.cssbox.layout.TextBox createTextBox(org.fit.cssbox.layout.BlockBox contblock,
Text n)
contblock - The parent node (and the containing block in the same time)n - The corresponding text node in the DOM tree.protected cz.vutbr.web.css.NodeData createTextStyle(BoxStyle style, float width)
BoxStyle structure.style - The source box style.protected cz.vutbr.web.css.NodeData createBlockStyle()
protected cz.vutbr.web.css.NodeData createBodyStyle()
protected cz.vutbr.web.css.NodeData createPageStyle()
protected cz.vutbr.web.css.NodeData createRectangleStyle(float x,
float y,
float width,
float height,
boolean stroke,
boolean fill)
x - The X coordinate of the rectangle.y - The Y coordinate of the rectangle.width - The width of the rectangle.height - The height of the rectangle.stroke - Should there be a stroke around?fill - Should the rectangle be filled?protected cz.vutbr.web.css.NodeData createLineStyle(float x1,
float y1,
float x2,
float y2)
protected cz.vutbr.web.css.Declaration createDeclaration(String property, cz.vutbr.web.css.Term<?> term)
property - Property name.term - Property value.protected void showGlyph(org.apache.pdfbox.util.Matrix arg0,
org.apache.pdfbox.pdmodel.font.PDFont arg1,
int arg2,
String arg3,
org.apache.pdfbox.util.Vector arg4)
throws IOException
showGlyph in class org.apache.pdfbox.contentstream.PDFStreamEngineIOExceptionCopyright © 2016. All rights reserved.