Class PdfTemplate

java.lang.Object
com.itextpdf.text.pdf.PdfContentByte
com.itextpdf.text.pdf.PdfTemplate
All Implemented Interfaces:
IAccessibleElement
Direct Known Subclasses:
PdfAppearance, PdfImportedPage, PdfPatternPainter, PdfPSXObject

public class PdfTemplate extends PdfContentByte implements IAccessibleElement
Implements the form XObject.
  • Field Details

  • Constructor Details

    • PdfTemplate

      protected PdfTemplate()
      Creates a PdfTemplate.
    • PdfTemplate

      PdfTemplate(PdfWriter wr)
      Creates new PdfTemplate
      Parameters:
      wr - the PdfWriter
  • Method Details

    • createTemplate

      public static PdfTemplate createTemplate(PdfWriter writer, float width, float height)
      Creates a new template.

      Creates a new template that is nothing more than a form XObject. This template can be included in this template or in another template. Templates are only written to the output when the document is closed permitting things like showing text in the first page that is only defined in the last page.

      Parameters:
      writer - the PdfWriter to use
      width - the bounding box width
      height - the bounding box height
      Returns:
      the created template
    • createTemplate

      static PdfTemplate createTemplate(PdfWriter writer, float width, float height, PdfName forcedName)
    • isTagged

      public boolean isTagged()
      Description copied from class: PdfContentByte
      Checks if the content needs to be tagged.
      Overrides:
      isTagged in class PdfContentByte
      Returns:
      false if no tags need to be added
    • setWidth

      public void setWidth(float width)
      Sets the bounding width of this template.
      Parameters:
      width - the bounding width
    • setHeight

      public void setHeight(float height)
      Sets the bounding height of this template.
      Parameters:
      height - the bounding height
    • getWidth

      public float getWidth()
      Gets the bounding width of this template.
      Returns:
      width the bounding width
    • getHeight

      public float getHeight()
      Gets the bounding height of this template.
      Returns:
      height the bounding height
    • getBoundingBox

      public Rectangle getBoundingBox()
    • setBoundingBox

      public void setBoundingBox(Rectangle bBox)
    • setLayer

      public void setLayer(PdfOCG layer)
      Sets the layer this template belongs to.
      Parameters:
      layer - the layer this template belongs to
    • getLayer

      public PdfOCG getLayer()
      Gets the layer this template belongs to.
      Returns:
      the layer this template belongs to or null for no layer defined
    • setMatrix

      public void setMatrix(float a, float b, float c, float d, float e, float f)
    • getMatrix

      PdfArray getMatrix()
    • getIndirectReference

      public PdfIndirectReference getIndirectReference()
      Gets the indirect reference to this template.
      Returns:
      the indirect reference to this template
    • beginVariableText

      public void beginVariableText()
    • endVariableText

      public void endVariableText()
    • getResources

      PdfObject getResources()
      Constructs the resources used by this template.
      Returns:
      the resources used by this template
    • getFormXObject

      public PdfStream getFormXObject(int compressionLevel) throws IOException
      Gets the stream representing this template.
      Parameters:
      compressionLevel - the compressionLevel
      Returns:
      the stream representing this template
      Throws:
      IOException
      Since:
      2.1.3 (replacing the method without param compressionLevel)
    • getDuplicate

      public PdfContentByte getDuplicate()
      Gets a duplicate of this PdfTemplate. All the members are copied by reference but the buffer stays different.
      Overrides:
      getDuplicate in class PdfContentByte
      Returns:
      a copy of this PdfTemplate
    • getType

      public int getType()
    • getPageResources

      PageResources getPageResources()
      Overrides:
      getPageResources in class PdfContentByte
    • getGroup

      public PdfTransparencyGroup getGroup()
      Getter for property group.
      Returns:
      Value of property group.
    • setGroup

      public void setGroup(PdfTransparencyGroup group)
      Setter for property group.
      Parameters:
      group - New value of property group.
    • getAdditional

      public PdfDictionary getAdditional()
      Getter for the dictionary with additional information.
      Returns:
      a PdfDictionary with additional information.
      Since:
      5.1.0
    • setAdditional

      public void setAdditional(PdfDictionary additional)
      Sets a dictionary with extra entries, for instance /Measure.
      Parameters:
      additional - a PdfDictionary with additional information.
      Since:
      5.1.0
    • getCurrentPage

      public PdfIndirectReference getCurrentPage()
      Overrides:
      getCurrentPage in class PdfContentByte
    • getPageReference

      public PdfIndirectReference getPageReference()
    • setPageReference

      public void setPageReference(PdfIndirectReference pageReference)
    • isContentTagged

      public boolean isContentTagged()
    • setContentTagged

      public void setContentTagged(boolean contentTagged)
    • getAccessibleAttribute

      public PdfObject getAccessibleAttribute(PdfName key)
      Description copied from interface: IAccessibleElement
      Get the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).
      Specified by:
      getAccessibleAttribute in interface IAccessibleElement
      Parameters:
      key -
      Returns:
    • setAccessibleAttribute

      public void setAccessibleAttribute(PdfName key, PdfObject value)
      Description copied from interface: IAccessibleElement
      Set the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).
      Specified by:
      setAccessibleAttribute in interface IAccessibleElement
      Parameters:
      key -
      value -
    • getAccessibleAttributes

      public HashMap<PdfName,PdfObject> getAccessibleAttributes()
      Description copied from interface: IAccessibleElement
      Gets all the properties of accessible element.
      Specified by:
      getAccessibleAttributes in interface IAccessibleElement
      Returns:
    • getRole

      public PdfName getRole()
      Description copied from interface: IAccessibleElement
      Gets the role of the accessible element.
      Specified by:
      getRole in interface IAccessibleElement
      Returns:
    • setRole

      public void setRole(PdfName role)
      Description copied from interface: IAccessibleElement
      Sets the role of the accessiblee element. Set role to null if you don't want to tag this element. Note that all child elements won't also be tagged.
      Specified by:
      setRole in interface IAccessibleElement
      Parameters:
      role -
    • getId

      public AccessibleElementId getId()
      Specified by:
      getId in interface IAccessibleElement
    • setId

      public void setId(AccessibleElementId id)
      Specified by:
      setId in interface IAccessibleElement
    • isInline

      public boolean isInline()
      Specified by:
      isInline in interface IAccessibleElement