Package org.xhtmlrenderer.pdf
Class ITextOutputDevice
java.lang.Object
org.xhtmlrenderer.render.AbstractOutputDevice
org.xhtmlrenderer.pdf.ITextOutputDevice
- All Implemented Interfaces:
OutputDevice
This class is largely based on
PdfGraphics2D
.
See http://sourceforge.net/
projects/itext/ for license information.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<ITextOutputDevice.Bookmark>
private @Nullable Area
private Color
private @Nullable com.lowagie.text.pdf.PdfContentByte
private @Nullable com.lowagie.text.pdf.PdfDestination
private final float
private @Nullable Color
private @Nullable ITextFSFont
private final List<@Nullable ITextOutputDevice.Metadata>
private int
private @Nullable Stroke
private @Nullable Stroke
private float
private @Nullable Box
private @Nullable SharedContext
private int
private @Nullable Stroke
private @Nullable Color
private AffineTransform
private @Nullable com.lowagie.text.pdf.PdfWriter
private static final int
private static final int
private static final AffineTransform
private static final boolean
private static final int
private static final BasicStroke
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate com.lowagie.text.Rectangle
add
(com.lowagie.text.Rectangle r1, com.lowagie.text.Rectangle r2) private void
addLinkAnnotation
(com.lowagie.text.pdf.PdfAction action, com.lowagie.text.Rectangle targetArea) void
addMetadata
(String name, String value) Appends a name/content metadata pair to this output device.private @Nullable PagePosition
calcPDFPagePosition
(CssContext c, String id, Box box) private com.lowagie.text.Rectangle
calcTotalLinkArea
(RenderingContext c, Box box) private Optional<com.lowagie.text.Rectangle>
checkLinkArea
(RenderingContext c, Box box) void
private @Nullable com.lowagie.text.pdf.PdfDestination
createDestination
(RenderingContext c, Box box) com.lowagie.text.Rectangle
createLocalTargetArea
(RenderingContext c, Box box) private com.lowagie.text.Rectangle
createLocalTargetArea
(RenderingContext c, Box box, boolean useAggregateBounds) private String
createRectKey
(com.lowagie.text.Rectangle rect) com.lowagie.text.Rectangle
createTargetArea
(RenderingContext c, Box box) void
void
drawBorderLine
(Shape bounds, int side, int lineWidth, boolean solid) void
protected void
drawLine
(int x1, int y1, int x2, int y2) void
drawOval
(int x, int y, int width, int height) private void
drawPDFAsImage
(PDFAsImage image, int x, int y) void
drawRect
(int x, int y, int width, int height) void
drawSelection
(RenderingContext c, InlineText inlineText) void
drawString
(String s, float x, float y, @Nullable JustificationInfo info) private void
private void
void
void
fillOval
(int x, int y, int width, int height) void
fillRect
(int x, int y, int width, int height) findPagePositionsByID
(CssContext c, Pattern pattern) void
finish
(RenderingContext c, Box root) void
private void
followPath
(Shape s, int drawType) @Nullable Shape
getClip()
com.lowagie.text.pdf.PdfContentByte
float
getDeviceLength
(float length) float
@Nullable String
getMetadataByName
(String name) Searches the metadata name/content pairs of the current document and returns the content value from the first pair with a matching name.getMetadataListByName
(String name) Searches the metadata name/content pairs of the current document and returns any content values with a matching name in an ArrayList.int
private int
getPageRefY
(Box box) com.lowagie.text.pdf.PdfReader
@Nullable Object
int
@Nullable com.lowagie.text.pdf.PdfWriter
private static com.lowagie.text.pdf.PdfAction
gotoDestination
(com.lowagie.text.pdf.PdfDestination dest) void
initializePage
(com.lowagie.text.pdf.PdfContentByte currentPage, float height) private boolean
isMakeDash
(boolean oldOk, BasicStroke nStroke, BasicStroke oStroke) boolean
boolean
private void
loadBookmark
(ITextOutputDevice.Bookmark parent, Element bookmark) private void
loadBookmarks
(Document doc) private void
loadMetadata
(Document doc) Locates and stores all metadata values in the document head that contain name/content pairs.private com.lowagie.text.pdf.PdfTextArray
private AffineTransform
normalizeMatrix
(AffineTransform current) private float
normalizeY
(float y) private void
normalizeY
(float[] coords) void
paintBackground
(RenderingContext c, Box box) void
private void
processLink
(RenderingContext c, Box box) private String
replaceMissingCharacters
(String string) void
void
void
void
setMetadata
(String name, String value) Replaces all copies of the named metadata with a single value.void
setRenderingHint
(RenderingHints.Key key, Object value) void
void
setSharedContext
(SharedContext sharedContext) void
setStartPageNo
(int startPageNo) void
private void
setStrokeDiff
(Stroke newStroke, @Nullable Stroke oldStroke) void
setWriter
(com.lowagie.text.pdf.PdfWriter writer) void
private Stroke
transformStroke
(Stroke stroke) void
translate
(double tx, double ty) private void
writeBookmark
(RenderingContext c, Box root, com.lowagie.text.pdf.PdfOutline parent, ITextOutputDevice.Bookmark bookmark) private void
writeBookmarks
(RenderingContext c, Box root, com.lowagie.text.pdf.PdfOutline parent, List<ITextOutputDevice.Bookmark> bookmarks) private void
private void
writeOutline
(RenderingContext c, Box root) Methods inherited from class org.xhtmlrenderer.render.AbstractOutputDevice
drawDebugOutline, drawText, drawTextDecoration, drawTextDecoration, getFontSpecification, paintBackground, paintBorder, paintBorder, paintCollapsedBorder, setFontSpecification
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xhtmlrenderer.extend.OutputDevice
drawDebugOutline, drawText, drawTextDecoration, drawTextDecoration, paintBackground, paintBorder, paintBorder, paintCollapsedBorder
-
Field Details
-
FILL
private static final int FILL- See Also:
-
STROKE
private static final int STROKE- See Also:
-
CLIP
private static final int CLIP- See Also:
-
IDENTITY
-
STROKE_ONE
-
ROUND_RECT_DIMENSIONS_DOWN
private static final boolean ROUND_RECT_DIMENSIONS_DOWN -
_currentPage
private @Nullable com.lowagie.text.pdf.PdfContentByte _currentPage -
_pageHeight
private float _pageHeight -
_font
-
_transform
-
_color
-
_fillColor
-
_strokeColor
-
_stroke
-
_originalStroke
-
_oldStroke
-
_clip
-
_dotsPerPoint
private final float _dotsPerPoint -
_writer
private @Nullable com.lowagie.text.pdf.PdfWriter _writer -
_readerCache
-
_defaultDestination
private @Nullable com.lowagie.text.pdf.PdfDestination _defaultDestination -
_bookmarks
-
_metadata
-
_root
-
_startPageNo
private int _startPageNo -
_nextFormFieldIndex
private int _nextFormFieldIndex -
_linkTargetAreas
-
-
Constructor Details
-
ITextOutputDevice
public ITextOutputDevice(float dotsPerPoint)
-
-
Method Details
-
setWriter
public void setWriter(com.lowagie.text.pdf.PdfWriter writer) -
getWriter
public @Nullable com.lowagie.text.pdf.PdfWriter getWriter() -
getNextFormFieldIndex
public int getNextFormFieldIndex() -
initializePage
public void initializePage(com.lowagie.text.pdf.PdfContentByte currentPage, float height) -
finishPage
public void finishPage() -
paintReplacedElement
- Specified by:
paintReplacedElement
in interfaceOutputDevice
-
paintBackground
- Specified by:
paintBackground
in interfaceOutputDevice
- Overrides:
paintBackground
in classAbstractOutputDevice
-
calcTotalLinkArea
-
add
private com.lowagie.text.Rectangle add(com.lowagie.text.Rectangle r1, com.lowagie.text.Rectangle r2) -
createRectKey
-
checkLinkArea
-
processLink
-
gotoDestination
private static com.lowagie.text.pdf.PdfAction gotoDestination(com.lowagie.text.pdf.PdfDestination dest) -
addLinkAnnotation
private void addLinkAnnotation(com.lowagie.text.pdf.PdfAction action, com.lowagie.text.Rectangle targetArea) -
createLocalTargetArea
-
createLocalTargetArea
private com.lowagie.text.Rectangle createLocalTargetArea(RenderingContext c, Box box, boolean useAggregateBounds) -
createTargetArea
-
getDeviceLength
public float getDeviceLength(float length) -
createDestination
private @Nullable com.lowagie.text.pdf.PdfDestination createDestination(RenderingContext c, Box box) -
drawBorderLine
- Specified by:
drawBorderLine
in interfaceOutputDevice
-
setColor
- Specified by:
setColor
in interfaceOutputDevice
-
draw
- Specified by:
draw
in interfaceOutputDevice
-
drawLine
protected void drawLine(int x1, int y1, int x2, int y2) - Specified by:
drawLine
in classAbstractOutputDevice
-
drawRect
public void drawRect(int x, int y, int width, int height) - Specified by:
drawRect
in interfaceOutputDevice
-
drawOval
public void drawOval(int x, int y, int width, int height) - Specified by:
drawOval
in interfaceOutputDevice
-
fill
- Specified by:
fill
in interfaceOutputDevice
-
fillRect
public void fillRect(int x, int y, int width, int height) - Specified by:
fillRect
in interfaceOutputDevice
-
fillOval
public void fillOval(int x, int y, int width, int height) - Specified by:
fillOval
in interfaceOutputDevice
-
translate
public void translate(double tx, double ty) - Specified by:
translate
in interfaceOutputDevice
-
getRenderingHint
- Specified by:
getRenderingHint
in interfaceOutputDevice
-
setRenderingHint
- Specified by:
setRenderingHint
in interfaceOutputDevice
-
setFont
- Specified by:
setFont
in interfaceOutputDevice
-
normalizeMatrix
-
drawString
-
replaceMissingCharacters
-
makeJustificationArray
-
getTransform
-
ensureFillColor
private void ensureFillColor() -
ensureStrokeColor
private void ensureStrokeColor() -
getCurrentPage
public com.lowagie.text.pdf.PdfContentByte getCurrentPage() -
followPath
-
normalizeY
private float normalizeY(float y) -
normalizeY
private void normalizeY(float[] coords) -
setStrokeDiff
-
isMakeDash
-
setStroke
- Specified by:
setStroke
in interfaceOutputDevice
-
transformStroke
-
clip
- Specified by:
clip
in interfaceOutputDevice
-
getClip
- Specified by:
getClip
in interfaceOutputDevice
-
setClip
- Specified by:
setClip
in interfaceOutputDevice
-
getStroke
- Specified by:
getStroke
in interfaceOutputDevice
-
drawImage
- Specified by:
drawImage
in interfaceOutputDevice
-
drawPDFAsImage
-
getReader
- Throws:
IOException
-
getDotsPerPoint
public float getDotsPerPoint() -
start
-
finish
-
writeOutline
-
writeBookmarks
private void writeBookmarks(RenderingContext c, Box root, com.lowagie.text.pdf.PdfOutline parent, List<ITextOutputDevice.Bookmark> bookmarks) -
writeNamedDestinations
-
getPageRefY
-
writeBookmark
private void writeBookmark(RenderingContext c, Box root, com.lowagie.text.pdf.PdfOutline parent, ITextOutputDevice.Bookmark bookmark) -
loadBookmarks
-
loadBookmark
-
addMetadata
Appends a name/content metadata pair to this output device. A name or content value of null will be ignored.- Parameters:
name
- the name of the metadata element to add.
-
getMetadataByName
Searches the metadata name/content pairs of the current document and returns the content value from the first pair with a matching name. The search is case-insensitive.- Parameters:
name
- the metadata element name to locate.- Returns:
- the content value of the first found metadata element; otherwise null.
-
getMetadataListByName
Searches the metadata name/content pairs of the current document and returns any content values with a matching name in an ArrayList. The search is case-insensitive.- Parameters:
name
- the metadata element name to locate.- Returns:
- an ArrayList with matching content values; otherwise an empty list.
-
loadMetadata
Locates and stores all metadata values in the document head that contain name/content pairs. If there is no pair with a name of "title", any content in the title element is saved as a "title" metadata item.- Parameters:
doc
- the Document level node of the parsed xhtml file.
-
setMetadata
Replaces all copies of the named metadata with a single value. A new value of null will result in the removal of all copies of the named metadata. UseaddMetadata
to append additional values with the same name.- Parameters:
name
- the metadata element name to locate.
-
setRoot
-
getStartPageNo
public int getStartPageNo() -
setStartPageNo
public void setStartPageNo(int startPageNo) -
drawSelection
- Specified by:
drawSelection
in interfaceOutputDevice
-
isSupportsSelection
public boolean isSupportsSelection()- Specified by:
isSupportsSelection
in interfaceOutputDevice
-
isSupportsCMYKColors
public boolean isSupportsCMYKColors()- Specified by:
isSupportsCMYKColors
in interfaceOutputDevice
-
findPagePositionsByID
-
calcPDFPagePosition
-