Class ITextOutputDevice

java.lang.Object
org.xhtmlrenderer.render.AbstractOutputDevice
org.xhtmlrenderer.pdf.ITextOutputDevice
All Implemented Interfaces:
OutputDevice

public class ITextOutputDevice extends AbstractOutputDevice implements OutputDevice
This class is largely based on PdfGraphics2D. See http://sourceforge.net/ projects/itext/ for license information.
  • 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

      private static final AffineTransform IDENTITY
    • STROKE_ONE

      private static final BasicStroke STROKE_ONE
    • ROUND_RECT_DIMENSIONS_DOWN

      private static final boolean ROUND_RECT_DIMENSIONS_DOWN
    • _currentPage

      private com.lowagie.text.pdf.PdfContentByte _currentPage
    • _pageHeight

      private float _pageHeight
    • _font

      private ITextFSFont _font
    • _transform

      private AffineTransform _transform
    • _color

      private Color _color
    • _fillColor

      private Color _fillColor
    • _strokeColor

      private Color _strokeColor
    • _stroke

      private Stroke _stroke
    • _originalStroke

      private Stroke _originalStroke
    • _oldStroke

      private Stroke _oldStroke
    • _clip

      private Area _clip
    • _sharedContext

      private SharedContext _sharedContext
    • _dotsPerPoint

      private final float _dotsPerPoint
    • _writer

      private com.lowagie.text.pdf.PdfWriter _writer
    • _readerCache

      private final Map<URI,com.lowagie.text.pdf.PdfReader> _readerCache
    • _defaultDestination

      private com.lowagie.text.pdf.PdfDestination _defaultDestination
    • _bookmarks

      private List<ITextOutputDevice.Bookmark> _bookmarks
    • _metadata

      private final List<ITextOutputDevice.Metadata> _metadata
    • _root

      private Box _root
    • _startPageNo

      private int _startPageNo
    • _nextFormFieldIndex

      private int _nextFormFieldIndex
    • _linkTargetAreas

      private Set<String> _linkTargetAreas
  • Constructor Details

    • ITextOutputDevice

      public ITextOutputDevice(float dotsPerPoint)
  • Method Details

    • setWriter

      public void setWriter(com.lowagie.text.pdf.PdfWriter writer)
    • getWriter

      public 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

      public void paintReplacedElement(RenderingContext c, BlockBox box)
      Specified by:
      paintReplacedElement in interface OutputDevice
    • paintBackground

      public void paintBackground(RenderingContext c, Box box)
      Specified by:
      paintBackground in interface OutputDevice
      Overrides:
      paintBackground in class AbstractOutputDevice
    • calcTotalLinkArea

      private com.lowagie.text.Rectangle calcTotalLinkArea(RenderingContext c, Box box)
    • add

      private com.lowagie.text.Rectangle add(com.lowagie.text.Rectangle r1, com.lowagie.text.Rectangle r2)
    • createRectKey

      private String createRectKey(com.lowagie.text.Rectangle rect)
    • checkLinkArea

      private com.lowagie.text.Rectangle checkLinkArea(RenderingContext c, Box box)
    • processLink

      private void processLink(RenderingContext c, Box box)
    • addLinkAnnotation

      private void addLinkAnnotation(com.lowagie.text.pdf.PdfAction action, com.lowagie.text.Rectangle targetArea)
    • createLocalTargetArea

      public com.lowagie.text.Rectangle createLocalTargetArea(RenderingContext c, Box box)
    • createLocalTargetArea

      private com.lowagie.text.Rectangle createLocalTargetArea(RenderingContext c, Box box, boolean useAggregateBounds)
    • createTargetArea

      public com.lowagie.text.Rectangle createTargetArea(RenderingContext c, Box box)
    • getDeviceLength

      public float getDeviceLength(float length)
    • createDestination

      private com.lowagie.text.pdf.PdfDestination createDestination(RenderingContext c, Box box)
    • drawBorderLine

      public void drawBorderLine(Shape bounds, int side, int lineWidth, boolean solid)
      Specified by:
      drawBorderLine in interface OutputDevice
    • setColor

      public void setColor(FSColor color)
      Specified by:
      setColor in interface OutputDevice
    • draw

      public void draw(Shape s)
      Specified by:
      draw in interface OutputDevice
    • drawLine

      protected void drawLine(int x1, int y1, int x2, int y2)
      Specified by:
      drawLine in class AbstractOutputDevice
    • drawRect

      public void drawRect(int x, int y, int width, int height)
      Specified by:
      drawRect in interface OutputDevice
    • drawOval

      public void drawOval(int x, int y, int width, int height)
      Specified by:
      drawOval in interface OutputDevice
    • fill

      public void fill(Shape s)
      Specified by:
      fill in interface OutputDevice
    • fillRect

      public void fillRect(int x, int y, int width, int height)
      Specified by:
      fillRect in interface OutputDevice
    • fillOval

      public void fillOval(int x, int y, int width, int height)
      Specified by:
      fillOval in interface OutputDevice
    • translate

      public void translate(double tx, double ty)
      Specified by:
      translate in interface OutputDevice
    • getRenderingHint

      public Object getRenderingHint(RenderingHints.Key key)
      Specified by:
      getRenderingHint in interface OutputDevice
    • setRenderingHint

      public void setRenderingHint(RenderingHints.Key key, Object value)
      Specified by:
      setRenderingHint in interface OutputDevice
    • setFont

      public void setFont(FSFont font)
      Specified by:
      setFont in interface OutputDevice
    • normalizeMatrix

      private AffineTransform normalizeMatrix(AffineTransform current)
    • drawString

      public void drawString(String s, float x, float y, JustificationInfo info)
    • replaceMissingCharacters

      private String replaceMissingCharacters(String string)
    • makeJustificationArray

      private com.lowagie.text.pdf.PdfTextArray makeJustificationArray(String s, JustificationInfo info)
    • getTransform

      public AffineTransform getTransform()
    • ensureFillColor

      private void ensureFillColor()
    • ensureStrokeColor

      private void ensureStrokeColor()
    • getCurrentPage

      public com.lowagie.text.pdf.PdfContentByte getCurrentPage()
    • followPath

      private void followPath(Shape s, int drawType)
    • normalizeY

      private float normalizeY(float y)
    • normalizeY

      private void normalizeY(float[] coords)
    • setStrokeDiff

      private void setStrokeDiff(Stroke newStroke, Stroke oldStroke)
    • isMakeDash

      private boolean isMakeDash(boolean oldOk, BasicStroke nStroke, BasicStroke oStroke)
    • setStroke

      public void setStroke(Stroke s)
      Specified by:
      setStroke in interface OutputDevice
    • transformStroke

      private Stroke transformStroke(Stroke stroke)
    • clip

      public void clip(Shape s)
      Specified by:
      clip in interface OutputDevice
    • getClip

      public Shape getClip()
      Specified by:
      getClip in interface OutputDevice
    • setClip

      public void setClip(Shape s)
      Specified by:
      setClip in interface OutputDevice
    • getStroke

      public Stroke getStroke()
      Specified by:
      getStroke in interface OutputDevice
    • drawImage

      public void drawImage(FSImage fsImage, int x, int y)
      Specified by:
      drawImage in interface OutputDevice
    • drawPDFAsImage

      private void drawPDFAsImage(PDFAsImage image, int x, int y)
    • getReader

      public com.lowagie.text.pdf.PdfReader getReader(URI uri) throws IOException
      Throws:
      IOException
    • getDotsPerPoint

      public float getDotsPerPoint()
    • start

      public void start(Document doc)
    • finish

      public void finish(RenderingContext c, Box root)
    • writeOutline

      private void writeOutline(RenderingContext c, Box root)
    • writeBookmarks

      private void writeBookmarks(RenderingContext c, Box root, com.lowagie.text.pdf.PdfOutline parent, List<ITextOutputDevice.Bookmark> bookmarks)
    • writeNamedDestinations

      private void writeNamedDestinations(RenderingContext c)
    • getPageRefY

      private int getPageRefY(Box box)
    • writeBookmark

      private void writeBookmark(RenderingContext c, Box root, com.lowagie.text.pdf.PdfOutline parent, ITextOutputDevice.Bookmark bookmark)
    • loadBookmarks

      private void loadBookmarks(Document doc)
    • loadBookmark

      private void loadBookmark(ITextOutputDevice.Bookmark parent, Element bookmark)
    • addMetadata

      public void addMetadata(String name, String value)
      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

      public 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. 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

      public List<String> 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. 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

      private void loadMetadata(Document doc)
      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

      public void setMetadata(String name, String value)
      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. Use addMetadata to append additional values with the same name.
      Parameters:
      name - the metadata element name to locate.
    • getSharedContext

      public SharedContext getSharedContext()
    • setSharedContext

      public void setSharedContext(SharedContext sharedContext)
    • setRoot

      public void setRoot(Box root)
    • getStartPageNo

      public int getStartPageNo()
    • setStartPageNo

      public void setStartPageNo(int startPageNo)
    • drawSelection

      public void drawSelection(RenderingContext c, InlineText inlineText)
      Specified by:
      drawSelection in interface OutputDevice
    • isSupportsSelection

      public boolean isSupportsSelection()
      Specified by:
      isSupportsSelection in interface OutputDevice
    • isSupportsCMYKColors

      public boolean isSupportsCMYKColors()
      Specified by:
      isSupportsCMYKColors in interface OutputDevice
    • findPagePositionsByID

      public List<PagePosition> findPagePositionsByID(CssContext c, Pattern pattern)
    • calcPDFPagePosition

      private PagePosition calcPDFPagePosition(CssContext c, String id, Box box)