Package org.openpdf.pdf
Class ITextOutputDevice
java.lang.Object
org.openpdf.render.AbstractOutputDevice
org.openpdf.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 classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<ITextOutputDevice.Bookmark>private @Nullable Areaprivate Colorprivate @Nullable PdfContentByteprivate @Nullable PdfDestinationprivate final floatprivate @Nullable Colorprivate @Nullable ITextFSFontprivate final List<@Nullable ITextOutputDevice.Metadata>private intprivate @Nullable Strokeprivate floatprivate @Nullable Strokeprivate floatprivate @Nullable Boxprivate @Nullable SharedContextprivate intprivate @Nullable Strokeprivate @Nullable Colorprivate AffineTransformprivate @Nullable PdfWriterprivate static final intprivate static final intprivate static final AffineTransformprivate static final booleanprivate static final intprivate static final BasicStroke -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Rectangleprivate voidaddLinkAnnotation(PdfAction action, Rectangle targetArea) voidaddMetadata(String name, String value) Appends a name/content metadata pair to this output device.private @Nullable PagePositioncalcPDFPagePosition(CssContext c, String id, Box box) private RectanglecalcTotalLinkArea(RenderingContext c, Box box) checkLinkArea(RenderingContext c, Box box) voidprivate @Nullable PdfDestinationcreateDestination(RenderingContext c, Box box) createLocalTargetArea(RenderingContext c, Box box) private RectanglecreateLocalTargetArea(RenderingContext c, Box box, boolean useAggregateBounds) private StringcreateRectKey(Rectangle rect) createTargetArea(RenderingContext c, Box box) voidvoiddrawBorderLine(Shape bounds, int side, int lineWidth, boolean solid) voidprotected voiddrawLine(int x1, int y1, int x2, int y2) voiddrawLinearGradient(FSLinearGradient gradient, int x, int y, int width, int height) voiddrawOval(int x, int y, int width, int height) private voiddrawPDFAsImage(PDFAsImage image, int x, int y) voiddrawRect(int x, int y, int width, int height) voiddrawSelection(RenderingContext c, InlineText inlineText) voiddrawString(String s, float x, float y, @Nullable JustificationInfo info) private voidprivate voidvoidvoidfillOval(int x, int y, int width, int height) voidfillRect(int x, int y, int width, int height) findPagePositionsByID(CssContext c, Pattern pattern) voidfinish(RenderingContext c, Box root) voidprivate voidfollowPath(Shape s, int drawType) @Nullable ShapegetClip()floatgetDeviceLength(float length) float@Nullable StringgetMetadataByName(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.intprivate intgetPageRefY(Box box) @Nullable Objectint@Nullable PdfWriterprivate static PdfActionvoidinitializePage(PdfContentByte currentPage, float height) private booleanisMakeDash(boolean oldOk, BasicStroke nStroke, BasicStroke oStroke) booleanbooleanprivate voidloadBookmark(ITextOutputDevice.Bookmark parent, Element bookmark) private voidloadBookmarks(Document doc) private voidloadMetadata(Document doc) Locates and stores all metadata values in the document head that contain name/content pairs.private PdfTextArrayprivate AffineTransformnormalizeMatrix(AffineTransform current) private floatnormalizeY(float y) private voidnormalizeY(float[] coords) voidpaintBackground(RenderingContext c, Box box) voidprivate voidprocessLink(RenderingContext c, Box box) private StringreplaceMissingCharacters(String string) voidvoidvoidvoidsetMetadata(String name, String value) Replaces all copies of the named metadata with a single value.voidsetOpacity(float opacity) voidsetRenderingHint(RenderingHints.Key key, Object value) voidvoidsetSharedContext(SharedContext sharedContext) voidsetStartPageNo(int startPageNo) voidprivate voidsetStrokeDiff(Stroke newStroke, @Nullable Stroke oldStroke) voidvoidprivate StroketransformStroke(Stroke stroke) voidtranslate(double tx, double ty) private voidwriteBookmark(RenderingContext c, Box root, PdfOutline parent, ITextOutputDevice.Bookmark bookmark) private voidwriteBookmarks(RenderingContext c, Box root, PdfOutline parent, List<ITextOutputDevice.Bookmark> bookmarks) private voidprivate voidwriteOutline(RenderingContext c, Box root) Methods inherited from class org.openpdf.render.AbstractOutputDevice
drawDebugOutline, drawText, drawTextDecoration, drawTextDecoration, getFontSpecification, paintBackground, paintBorder, paintBorder, paintCollapsedBorder, setFontSpecificationMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openpdf.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
-
_pageHeight
private float _pageHeight -
_font
-
_transform
-
_color
-
_fillColor
-
_strokeColor
-
_stroke
-
_originalStroke
-
_oldStroke
-
_opacity
private float _opacity -
_clip
-
_dotsPerPoint
private final float _dotsPerPoint -
_writer
-
_readerCache
-
_defaultDestination
-
_bookmarks
-
_metadata
-
_root
-
_startPageNo
private int _startPageNo -
_nextFormFieldIndex
private int _nextFormFieldIndex -
_linkTargetAreas
-
-
Constructor Details
-
ITextOutputDevice
public ITextOutputDevice(float dotsPerPoint)
-
-
Method Details
-
setWriter
-
getWriter
-
getNextFormFieldIndex
public int getNextFormFieldIndex() -
initializePage
-
finishPage
public void finishPage() -
paintReplacedElement
- Specified by:
paintReplacedElementin interfaceOutputDevice
-
paintBackground
- Specified by:
paintBackgroundin interfaceOutputDevice- Overrides:
paintBackgroundin classAbstractOutputDevice
-
calcTotalLinkArea
-
add
-
createRectKey
-
checkLinkArea
-
processLink
-
gotoDestination
-
addLinkAnnotation
-
createLocalTargetArea
-
createLocalTargetArea
-
createTargetArea
-
getDeviceLength
public float getDeviceLength(float length) -
createDestination
-
drawBorderLine
- Specified by:
drawBorderLinein interfaceOutputDevice
-
setOpacity
public void setOpacity(float opacity) - Specified by:
setOpacityin interfaceOutputDevice
-
setColor
- Specified by:
setColorin interfaceOutputDevice
-
draw
- Specified by:
drawin interfaceOutputDevice
-
drawLine
protected void drawLine(int x1, int y1, int x2, int y2) - Specified by:
drawLinein classAbstractOutputDevice
-
drawRect
public void drawRect(int x, int y, int width, int height) - Specified by:
drawRectin interfaceOutputDevice
-
drawOval
public void drawOval(int x, int y, int width, int height) - Specified by:
drawOvalin interfaceOutputDevice
-
fill
- Specified by:
fillin interfaceOutputDevice
-
fillRect
public void fillRect(int x, int y, int width, int height) - Specified by:
fillRectin interfaceOutputDevice
-
fillOval
public void fillOval(int x, int y, int width, int height) - Specified by:
fillOvalin interfaceOutputDevice
-
translate
public void translate(double tx, double ty) - Specified by:
translatein interfaceOutputDevice
-
getRenderingHint
- Specified by:
getRenderingHintin interfaceOutputDevice
-
setRenderingHint
- Specified by:
setRenderingHintin interfaceOutputDevice
-
setFont
- Specified by:
setFontin interfaceOutputDevice
-
normalizeMatrix
-
drawString
-
replaceMissingCharacters
-
makeJustificationArray
-
getTransform
-
ensureFillColor
private void ensureFillColor() -
ensureStrokeColor
private void ensureStrokeColor() -
getCurrentPage
-
followPath
-
normalizeY
private float normalizeY(float y) -
normalizeY
private void normalizeY(float[] coords) -
setStrokeDiff
-
isMakeDash
-
setStroke
- Specified by:
setStrokein interfaceOutputDevice
-
transformStroke
-
clip
- Specified by:
clipin interfaceOutputDevice
-
getClip
- Specified by:
getClipin interfaceOutputDevice
-
setClip
- Specified by:
setClipin interfaceOutputDevice
-
getStroke
- Specified by:
getStrokein interfaceOutputDevice
-
drawImage
- Specified by:
drawImagein interfaceOutputDevice
-
drawLinearGradient
- Specified by:
drawLinearGradientin interfaceOutputDevice
-
drawPDFAsImage
-
getReader
- Throws:
IOException
-
getDotsPerPoint
public float getDotsPerPoint() -
start
-
finish
-
writeOutline
-
writeBookmarks
private void writeBookmarks(RenderingContext c, Box root, PdfOutline parent, List<ITextOutputDevice.Bookmark> bookmarks) -
writeNamedDestinations
-
getPageRefY
-
writeBookmark
private void writeBookmark(RenderingContext c, Box root, 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. UseaddMetadatato 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:
drawSelectionin interfaceOutputDevice
-
isSupportsSelection
public boolean isSupportsSelection()- Specified by:
isSupportsSelectionin interfaceOutputDevice
-
isSupportsCMYKColors
public boolean isSupportsCMYKColors()- Specified by:
isSupportsCMYKColorsin interfaceOutputDevice
-
findPagePositionsByID
-
calcPDFPagePosition
-