Class PDFTextFormat

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class PDFTextFormat
    extends java.lang.Object
    implements java.lang.Cloneable
    a class encapsulating the text state
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.geom.AffineTransform cur
      current matrix transform
      private PDFFont font
      font
      private float fsize
      font size
      private boolean inuse
      are we between BT and ET?
      private java.awt.geom.AffineTransform line
      matrix transform at start of line
      private java.awt.geom.Point2D.Float prevEnd
      location of the end of the previous hunk of text
      private float tc
      character spacing
      private float th
      horizontal scaling
      private float tk
      text knockout
      private float tl
      leading
      private int tm
      text mode
      private float tr
      rise amount
      private float tw
      word spacing
      private java.lang.StringBuffer word
      build text rep of word
      private java.awt.geom.Point2D.Float wordStart
      start location of the hunk of text
    • Constructor Summary

      Constructors 
      Constructor Description
      PDFTextFormat()
      create a new PDFTextFormat, with initial values
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void carriageReturn()
      perform a carriage return
      void carriageReturn​(float x, float y)
      perform a carriage return by translating by x and y.
      java.lang.Object clone()
      Clone the text format
      void doText​(PDFPage cmds, java.lang.Object[] ary)
      add some text to the page.
      void doText​(PDFPage cmds, java.lang.String text)
      add some text to the page.
      void end()
      end a span of text
      void flush()
      finish any unfinished words.
      float getCharSpacing()
      get the char spacing
      PDFFont getFont()
      get the font
      float getFontSize()
      get the font size
      float getHorizontalScale()
      Get the horizontal scale
      float getLeading()
      get the leading
      int getMode()
      Get the mode of the text
      float getRise()
      Get the rise
      java.awt.geom.AffineTransform getTransform()
      Get the current transform
      float getWordSpacing()
      get the word spacing
      void reset()
      reset the PDFTextFormat for a new run
      void setCharSpacing​(float spc)
      set the character spacing
      void setFont​(PDFFont f, float size)
      set the font and size
      void setHorizontalScale​(float scl)
      set the horizontal scale.
      void setLeading​(float spc)
      set the leading
      void setMatrix​(float[] matrix)
      set the transform matrix directly
      void setMode​(int m)
      set the mode of the text.
      void setRise​(float spc)
      set the rise
      void setTextFormatMode​(int mode)
      Set the mode from another text format mode
      void setWordSpacing​(float spc)
      set the word spacing
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • tc

        private float tc
        character spacing
      • tw

        private float tw
        word spacing
      • th

        private float th
        horizontal scaling
      • tl

        private float tl
        leading
      • tr

        private float tr
        rise amount
      • tm

        private int tm
        text mode
      • tk

        private float tk
        text knockout
      • cur

        private java.awt.geom.AffineTransform cur
        current matrix transform
      • line

        private java.awt.geom.AffineTransform line
        matrix transform at start of line
      • fsize

        private float fsize
        font size
      • inuse

        private boolean inuse
        are we between BT and ET?
      • word

        private java.lang.StringBuffer word
        build text rep of word
      • wordStart

        private java.awt.geom.Point2D.Float wordStart
        start location of the hunk of text
      • prevEnd

        private java.awt.geom.Point2D.Float prevEnd
        location of the end of the previous hunk of text
    • Constructor Detail

      • PDFTextFormat

        public PDFTextFormat()
        create a new PDFTextFormat, with initial values
    • Method Detail

      • reset

        public void reset()
        reset the PDFTextFormat for a new run
      • end

        public void end()
        end a span of text
      • getCharSpacing

        public float getCharSpacing()
        get the char spacing
      • setCharSpacing

        public void setCharSpacing​(float spc)
        set the character spacing
      • getWordSpacing

        public float getWordSpacing()
        get the word spacing
      • setWordSpacing

        public void setWordSpacing​(float spc)
        set the word spacing
      • getHorizontalScale

        public float getHorizontalScale()
        Get the horizontal scale
        Returns:
        the horizontal scale, in percent
      • setHorizontalScale

        public void setHorizontalScale​(float scl)
        set the horizontal scale.
        Parameters:
        scl - the horizontal scale, in percent (100=normal)
      • getLeading

        public float getLeading()
        get the leading
      • setLeading

        public void setLeading​(float spc)
        set the leading
      • getFont

        public PDFFont getFont()
        get the font
      • getFontSize

        public float getFontSize()
        get the font size
      • setFont

        public void setFont​(PDFFont f,
                            float size)
        set the font and size
      • getMode

        public int getMode()
        Get the mode of the text
      • setMode

        public void setMode​(int m)
        set the mode of the text. The correspondence of m to mode is show in the following table. m is a value from 0-7 in binary: 000 Fill 001 Stroke 010 Fill + Stroke 011 Nothing 100 Fill + Clip 101 Stroke + Clip 110 Fill + Stroke + Clip 111 Clip Therefore: Fill corresponds to the low bit being 0; Clip corresponds to the hight bit being 1; and Stroke corresponds to the middle xor low bit being 1.
      • setTextFormatMode

        public void setTextFormatMode​(int mode)
        Set the mode from another text format mode
        Parameters:
        mode - the text render mode using the codes from PDFShapeCmd and not the wacky PDF codes
      • getRise

        public float getRise()
        Get the rise
      • setRise

        public void setRise​(float spc)
        set the rise
      • carriageReturn

        public void carriageReturn()
        perform a carriage return
      • carriageReturn

        public void carriageReturn​(float x,
                                   float y)
        perform a carriage return by translating by x and y. The next carriage return will be relative to the new location.
      • getTransform

        public java.awt.geom.AffineTransform getTransform()
        Get the current transform
      • setMatrix

        public void setMatrix​(float[] matrix)
        set the transform matrix directly
      • doText

        public void doText​(PDFPage cmds,
                           java.lang.String text)
        add some text to the page.
        Parameters:
        cmds - the PDFPage to add the commands to
        text - the text to add
      • doText

        public void doText​(PDFPage cmds,
                           java.lang.Object[] ary)
                    throws PDFParseException
        add some text to the page.
        Parameters:
        cmds - the PDFPage to add the commands to
        ary - an array of Strings and Doubles, where the Strings represent text to be added, and the Doubles represent kerning amounts.
        Throws:
        PDFParseException
      • flush

        public void flush()
        finish any unfinished words. TODO: write this!
      • clone

        public java.lang.Object clone()
        Clone the text format
        Overrides:
        clone in class java.lang.Object