Class PdfContentByte
- java.lang.Object
-
- com.itextpdf.text.pdf.PdfContentByte
-
- Direct Known Subclasses:
PdfCopy.StampContent,PdfTemplate,StampContent,Type3Glyph
public class PdfContentByte extends java.lang.ObjectPdfContentByteis an object containing the user positioned text and graphic contents of a page. It knows how to apply the proper font encoding.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPdfContentByte.GraphicStateThis class keeps the graphic state of the current page(package private) static classPdfContentByte.UncoloredPattern
-
Field Summary
Fields Modifier and Type Field Description private static java.util.HashMap<PdfName,java.lang.String>abrevstatic intALIGN_CENTERThe alignment is centerstatic intALIGN_LEFTThe alignment is leftstatic intALIGN_RIGHTThe alignment is rightprotected ByteBuffercontentThis is the actual contentprotected PdfContentByteduplicatedFromprivate booleaninTextprotected java.util.ArrayList<java.lang.Integer>layerDepthThe list were we save/restore the layer depthstatic intLINE_CAP_BUTTA possible line cap valuestatic intLINE_CAP_PROJECTING_SQUAREA possible line cap valuestatic intLINE_CAP_ROUNDA possible line cap valuestatic intLINE_JOIN_BEVELA possible line join valuestatic intLINE_JOIN_MITERA possible line join valuestatic intLINE_JOIN_ROUNDA possible line join valueprotected intmarkedContentSizeprivate intmcDepthprivate java.util.ArrayList<IAccessibleElement>mcElementsprotected PdfDocumentpdfThis is the PdfDocumentprotected intseparatorThe separator between commands.protected PdfContentByte.GraphicStatestateThis is the GraphicState in useprotected java.util.ArrayList<PdfContentByte.GraphicState>stateListThe list were we save/restore the stateprivate booleansuppressTaggingstatic intTEXT_RENDER_MODE_CLIPA possible text rendering valuestatic intTEXT_RENDER_MODE_FILLA possible text rendering valuestatic intTEXT_RENDER_MODE_FILL_CLIPA possible text rendering valuestatic intTEXT_RENDER_MODE_FILL_STROKEA possible text rendering valuestatic intTEXT_RENDER_MODE_FILL_STROKE_CLIPA possible text rendering valuestatic intTEXT_RENDER_MODE_INVISIBLEA possible text rendering valuestatic intTEXT_RENDER_MODE_STROKEA possible text rendering valuestatic intTEXT_RENDER_MODE_STROKE_CLIPA possible text rendering valueprivate static float[]unitRectprotected PdfWriterwriterThis is the writer
-
Constructor Summary
Constructors Constructor Description PdfContentByte(PdfWriter wr)Constructs a newPdfContentByte-object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(PdfContentByte other)Adds the content of anotherPdfContentByte-object to this object.(package private) voidaddAnnotation(PdfAnnotation annot)voidaddAnnotation(PdfAnnotation annot, boolean applyCTM)PdfNameaddFormXObj(PdfStream formXObj, PdfName name, double a, double b, double c, double d, double e, double f)Adds a form XObject to this content.PdfNameaddFormXObj(PdfStream formXObj, PdfName name, float a, float b, float c, float d, float e, float f)Adds a form XObject to this content.voidaddImage(Image image)Adds anImageto the page.voidaddImage(Image image, boolean inlineImage)Adds anImageto the page.voidaddImage(Image image, double a, double b, double c, double d, double e, double f)Adds anImageto the page.voidaddImage(Image image, double a, double b, double c, double d, double e, double f, boolean inlineImage)Adds anImageto the page.protected voidaddImage(Image image, double a, double b, double c, double d, double e, double f, boolean inlineImage, boolean isMCBlockOpened)Adds anImageto the page.voidaddImage(Image image, float a, float b, float c, float d, float e, float f)Adds anImageto the page.voidaddImage(Image image, float a, float b, float c, float d, float e, float f, boolean inlineImage)Adds anImageto the page.voidaddImage(Image image, AffineTransform transform)adds an image with the given matrix.voidaddImage(Image image, java.awt.geom.AffineTransform transform)Deprecated.use com.itextpdf.text.geom.AffineTransform as parametervoidaddOutline(PdfOutline outline, java.lang.String name)Adds a named outline to the document.voidaddPSXObject(PdfPSXObject psobject)Adds a PostScript XObject to this content.voidaddTemplate(PdfTemplate template, double x, double y)Adds a template to this content.voidaddTemplate(PdfTemplate template, double x, double y, boolean tagContent)voidaddTemplate(PdfTemplate template, double a, double b, double c, double d, double e, double f)Adds a template to this content.voidaddTemplate(PdfTemplate template, double a, double b, double c, double d, double e, double f, boolean tagContent)Adds a template to this content.private voidaddTemplate(PdfTemplate template, double a, double b, double c, double d, double e, double f, boolean tagTemplate, boolean tagContent)Adds a template to this content.voidaddTemplate(PdfTemplate template, float x, float y)Adds a template to this content.voidaddTemplate(PdfTemplate template, float x, float y, boolean tagContent)voidaddTemplate(PdfTemplate template, float a, float b, float c, float d, float e, float f)Adds a template to this content.voidaddTemplate(PdfTemplate template, float a, float b, float c, float d, float e, float f, boolean tagContent)Adds a template to this content.voidaddTemplate(PdfTemplate template, AffineTransform transform)adds a template with the given matrix.voidaddTemplate(PdfTemplate template, AffineTransform transform, boolean tagContent)adds a template with the given matrix.voidaddTemplate(PdfTemplate template, java.awt.geom.AffineTransform transform)Deprecated.use com.itextpdf.text.geom.AffineTransform as parameter(package private) voidaddTemplateReference(PdfIndirectReference template, PdfName name, double a, double b, double c, double d, double e, double f)(package private) voidaddTemplateReference(PdfIndirectReference template, PdfName name, float a, float b, float c, float d, float e, float f)voidarc(double x1, double y1, double x2, double y2, double startAng, double extent)Draws a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees.voidarc(float x1, float y1, float x2, float y2, float startAng, float extent)Draws a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees.voidbeginLayer(PdfOCG layer)Begins a graphic block whose visibility is controlled by thelayer.private voidbeginLayer2(PdfOCG layer)voidbeginMarkedContentSequence(PdfName tag)This is just a shorthand tobeginMarkedContentSequence(tag, null, false).voidbeginMarkedContentSequence(PdfName tag, PdfDictionary property, boolean inline)Begins a marked content sequence.voidbeginMarkedContentSequence(PdfStructureElement struc)Begins a marked content sequence.private voidbeginMarkedContentSequence(PdfStructureElement struc, java.lang.String expansion)Begins a marked content sequence.voidbeginText()Starts the writing of text.protected voidbeginText(boolean restoreTM)Starts the writing of text.static java.util.ArrayList<double[]>bezierArc(double x1, double y1, double x2, double y2, double startAng, double extent)Generates an array of bezier curves to draw an arc.static java.util.ArrayList<double[]>bezierArc(float x1, float y1, float x2, float y2, float startAng, float extent)Generates an array of bezier curves to draw an arc.(package private) voidcheckNoPattern(PdfTemplate t)Throws an error if it is a pattern.protected voidcheckState()protected voidcheckWriter()Check if we have a valid PdfWriter.voidcircle(double x, double y, double r)Draws a circle.voidcircle(float x, float y, float r)Draws a circle.voidclip()Modify the current clipping path by intersecting it with the current path, using the nonzero winding number rule to determine which regions lie inside the clipping path.voidcloseMCBlock(IAccessibleElement element)private voidcloseMCBlockInt(IAccessibleElement element)voidclosePath()Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath.voidclosePathEoFillStroke()Closes the path, fills it using the even-odd rule to determine the region to fill and strokes it.voidclosePathFillStroke()Closes the path, fills it using the non-zero winding number rule to determine the region to fill and strokes it.voidclosePathStroke()Closes the path and strokes it.private booleancompareColors(BaseColor c1, BaseColor c2)voidconcatCTM(double a, double b, double c, double d, double e, double f)Concatenate a matrix to the current transformation matrix.voidconcatCTM(float a, float b, float c, float d, float e, float f)Concatenate a matrix to the current transformation matrix.voidconcatCTM(AffineTransform transform)Concatenate a matrix to the current transformation matrix.voidconcatCTM(java.awt.geom.AffineTransform transform)Deprecated.use com.itextpdf.text.geom.AffineTransform as parameterPdfAppearancecreateAppearance(float width, float height)Creates a new appearance to be used with form fields.(package private) PdfAppearancecreateAppearance(float width, float height, PdfName forcedName)java.awt.Graphics2DcreateGraphics(float width, float height)Deprecated.use the constructor in PdfGraphics2Djava.awt.Graphics2DcreateGraphics(float width, float height, boolean convertImagesToJPEG, float quality)Deprecated.use the constructor in PdfGraphics2Djava.awt.Graphics2DcreateGraphics(float width, float height, FontMapper fontMapper)Deprecated.use the constructor in PdfPrinterGraphics2Djava.awt.Graphics2DcreateGraphics(float width, float height, FontMapper fontMapper, boolean convertImagesToJPEG, float quality)Deprecated.use the constructor in PdfPrinterGraphics2Djava.awt.Graphics2DcreateGraphicsShapes(float width, float height)Deprecated.use the constructor in PdfGraphics2Djava.awt.Graphics2DcreateGraphicsShapes(float width, float height, boolean convertImagesToJPEG, float quality)Deprecated.use the constructor in PdfPrinterGraphics2DPdfPatternPaintercreatePattern(float width, float height)Create a new colored tiling pattern.PdfPatternPaintercreatePattern(float width, float height, float xstep, float ystep)Create a new colored tiling pattern.PdfPatternPaintercreatePattern(float width, float height, float xstep, float ystep, BaseColor color)Create a new uncolored tiling pattern.PdfPatternPaintercreatePattern(float width, float height, BaseColor color)Create a new uncolored tiling pattern.java.awt.Graphics2DcreatePrinterGraphics(float width, float height, boolean convertImagesToJPEG, float quality, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfGraphics2Djava.awt.Graphics2DcreatePrinterGraphics(float width, float height, FontMapper fontMapper, boolean convertImagesToJPEG, float quality, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfPrinterGraphics2Djava.awt.Graphics2DcreatePrinterGraphics(float width, float height, FontMapper fontMapper, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfPrinterGraphics2Djava.awt.Graphics2DcreatePrinterGraphics(float width, float height, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfPrinterGraphics2Djava.awt.Graphics2DcreatePrinterGraphicsShapes(float width, float height, boolean convertImagesToJPEG, float quality, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfPrinterGraphics2Djava.awt.Graphics2DcreatePrinterGraphicsShapes(float width, float height, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfPrinterGraphics2DPdfTemplatecreateTemplate(float width, float height)Creates a new template.(package private) PdfTemplatecreateTemplate(float width, float height, PdfName forcedName)voidcurveFromTo(double x1, double y1, double x3, double y3)Appends a Bêzier curve to the path, starting from the current point.voidcurveFromTo(float x1, float y1, float x3, float y3)Appends a Bêzier curve to the path, starting from the current point.voidcurveTo(double x2, double y2, double x3, double y3)Appends a Bêzier curve to the path, starting from the current point.voidcurveTo(double x1, double y1, double x2, double y2, double x3, double y3)Appends a Bêzier curve to the path, starting from the current point.voidcurveTo(float x2, float y2, float x3, float y3)Appends a Bêzier curve to the path, starting from the current point.voidcurveTo(float x1, float y1, float x2, float y2, float x3, float y3)Appends a Bêzier curve to the path, starting from the current point.voiddrawButton(double llx, double lly, double urx, double ury, java.lang.String text, BaseFont bf, float size)Draws a button.voiddrawButton(float llx, float lly, float urx, float ury, java.lang.String text, BaseFont bf, float size)Draws a button.voiddrawRadioField(double llx, double lly, double urx, double ury, boolean on)Draws a TextField.voiddrawRadioField(float llx, float lly, float urx, float ury, boolean on)Draws a TextField.voiddrawTextField(double llx, double lly, double urx, double ury)Draws a TextField.voiddrawTextField(float llx, float lly, float urx, float ury)Draws a TextField.voidellipse(double x1, double y1, double x2, double y2)Draws an ellipse inscribed within the rectangle x1,y1,x2,y2.voidellipse(float x1, float y1, float x2, float y2)Draws an ellipse inscribed within the rectangle x1,y1,x2,y2.voidendLayer()Ends a layer controlled graphic block.voidendMarkedContentSequence()Ends a marked content sequencevoidendText()Ends the writing of text and makes the current font invalid.private voidensureDocumentTagIsOpen()voideoClip()Modify the current clipping path by intersecting it with the current path, using the even-odd rule to determine which regions lie inside the clipping path.voideoFill()Fills the path, using the even-odd rule to determine the region to fill.voideoFillStroke()Fills the path, using the even-odd rule to determine the region to fill and strokes it.voidfill()Fills the path, using the non-zero winding number rule to determine the region to fill.voidfillStroke()Fills the path using the non-zero winding number rule to determine the region to fill and strokes it.floatgetCharacterSpacing()Gets the current character spacing.protected PdfIndirectReferencegetCurrentPage()PdfContentBytegetDuplicate()Gets a duplicate of thisPdfContentByte.PdfContentBytegetDuplicate(boolean inheritGraphicState)floatgetEffectiveStringWidth(java.lang.String text, boolean kerned)Computes the width of the given string taking in account the current values of "Character spacing", "Word Spacing" and "Horizontal Scaling".private floatgetEffectiveStringWidth(java.lang.String text, boolean kerned, float kerning)Computes the width of the given string taking in account the current values of "Character spacing", "Word Spacing" and "Horizontal Scaling".floatgetHorizontalScaling()Gets the current character spacing.ByteBuffergetInternalBuffer()Gets the internal buffer.protected booleangetInText()static PdfTextArraygetKernArray(java.lang.String text, BaseFont font)Constructs a kern array for a text in a certain fontfloatgetLeading()Gets the current text leading.protected intgetMcDepth()protected java.util.ArrayList<IAccessibleElement>getMcElements()(package private) PageResourcesgetPageResources()private PdfDictionarygetParentStructureElement()PdfDocumentgetPdfDocument()Gets thePdfDocumentin use by this object.PdfWritergetPdfWriter()Gets thePdfWriterin use by this object.PdfOutlinegetRootOutline()Gets the root outline.floatgetWordSpacing()Gets the current word spacing.floatgetXTLM()Gets the x position of the text line matrix.floatgetYTLM()Gets the y position of the text line matrix.private voidHelperCMYK(float cyan, float magenta, float yellow, float black)Helper to validate and write the CMYK color components.private voidHelperRGB(float red, float green, float blue)Helper to validate and write the RGB color componentsvoidinheritGraphicState(PdfContentByte parentCanvas)booleanisTagged()Checks if the content needs to be tagged.booleanisTaggingSuppressed()[SUP-1395] If set, prevents iText from marking content and creating structure tags for items added to this content stream.voidlineTo(double x, double y)Appends a straight line segment from the current point (x, y).voidlineTo(float x, float y)Appends a straight line segment from the current point (x, y).booleanlocalDestination(java.lang.String name, PdfDestination destination)The local destination to where a local goto with the same name will jump.voidlocalGoto(java.lang.String name, float llx, float lly, float urx, float ury)Implements a link to other part of the document.voidmoveText(float x, float y)Moves to the start of the next line, offset from the start of the current line.voidmoveTextWithLeading(float x, float y)Moves to the start of the next line, offset from the start of the current line.voidmoveTo(double x, double y)Move the current point (x, y), omitting any connecting line segment.voidmoveTo(float x, float y)Move the current point (x, y), omitting any connecting line segment.voidnewlineShowText(float wordSpacing, float charSpacing, java.lang.String text)Moves to the next line and shows text string, using the given values of the character and word spacing parameters.voidnewlineShowText(java.lang.String text)Moves to the next line and showstext.voidnewlineText()Moves to the start of the next line.voidnewPath()Ends the path without filling or stroking it.voidopenMCBlock(IAccessibleElement element)private PdfStructureElementopenMCBlockInt(IAccessibleElement element)(package private) voidoutputColorNumbers(BaseColor color, float tint)Outputs the color values to the content.voidpaintShading(PdfShading shading)Paints using a shading object.voidpaintShading(PdfShadingPattern shading)Paints using a shading pattern.voidrectangle(double x, double y, double w, double h)Adds a rectangle to the current path.voidrectangle(float x, float y, float w, float h)Adds a rectangle to the current path.voidrectangle(Rectangle rectangle)Adds a border (complete or partially) to the current path..voidremoteGoto(java.lang.String filename, int page, float llx, float lly, float urx, float ury)Implements a link to another document.voidremoteGoto(java.lang.String filename, java.lang.String name, float llx, float lly, float urx, float ury)Implements a link to another document.voidreset()Makes thisPdfContentByteempty.voidreset(boolean validateContent)Makes thisPdfContentByteempty.voidresetCMYKColorFill()Changes the current color for filling paths to black.voidresetCMYKColorStroke()Changes the current color for stroking paths to black.voidresetGrayFill()Changes the current gray tint for filling paths to black.voidresetGrayStroke()Changes the current gray tint for stroking paths to black.voidresetRGBColorFill()Changes the current color for filling paths to black.voidresetRGBColorStroke()Changes the current color for stroking paths to black.protected voidrestoreMCBlocks(java.util.ArrayList<IAccessibleElement> mcElements)voidrestoreState()Restores the graphic state.voidroundRectangle(double x, double y, double w, double h, double r)Adds a round rectangle to the current path.voidroundRectangle(float x, float y, float w, float h, float r)Adds a round rectangle to the current path.voidsanityCheck()Checks for any dangling state: Mismatched save/restore state, begin/end text, begin/end layer, or begin/end marked content sequence.private voidsaveColor(BaseColor color, boolean fill)protected java.util.ArrayList<IAccessibleElement>saveMCBlocks()voidsaveState()Saves the graphic state.voidsetAction(PdfAction action, float llx, float lly, float urx, float ury)Implements an action in an area.voidsetCharacterSpacing(float charSpace)Sets the character spacing parameter.voidsetCMYKColorFill(int cyan, int magenta, int yellow, int black)Changes the current color for filling paths (device dependent colors!).voidsetCMYKColorFillF(float cyan, float magenta, float yellow, float black)Changes the current color for filling paths (device dependent colors!).voidsetCMYKColorStroke(int cyan, int magenta, int yellow, int black)Changes the current color for stroking paths (device dependent colors!).voidsetCMYKColorStrokeF(float cyan, float magenta, float yellow, float black)Changes the current color for stroking paths (device dependent colors!).voidsetColorFill(BaseColor color)Sets the fill color.voidsetColorFill(PdfDeviceNColor dn, float[] tints)voidsetColorFill(PdfLabColor lab, float l, float a, float b)voidsetColorFill(PdfSpotColor sp, float tint)Sets the fill color to a spot color.voidsetColorStroke(BaseColor color)Sets the stroke color.voidsetColorStroke(PdfDeviceNColor sp, float[] tints)voidsetColorStroke(PdfLabColor lab, float l, float a, float b)voidsetColorStroke(PdfSpotColor sp, float tint)Sets the stroke color to a spot color.voidsetDefaultColorspace(PdfName name, PdfObject obj)Sets the default colorspace.voidsetFlatness(double flatness)Changes the Flatness.voidsetFlatness(float flatness)Changes the Flatness.voidsetFontAndSize(BaseFont bf, float size)Set the font and the size for the subsequent text writing.voidsetGrayFill(float gray)Changes the currentgray tint for filling paths (device dependent colors!).voidsetGrayStroke(float gray)Changes the currentgray tint for stroking paths (device dependent colors!).voidsetGState(PdfGState gstate)Sets the graphic statevoidsetHorizontalScaling(float scale)Sets the horizontal scaling parameter.voidsetLeading(float leading)Sets the text leading parameter.voidsetLineCap(int style)Changes the Line cap style.voidsetLineDash(double phase)Changes the value of the line dash pattern.voidsetLineDash(double[] array, double phase)Changes the value of the line dash pattern.voidsetLineDash(double unitsOn, double phase)Changes the value of the line dash pattern.voidsetLineDash(double unitsOn, double unitsOff, double phase)Changes the value of the line dash pattern.voidsetLineDash(float phase)Changes the value of the line dash pattern.voidsetLineDash(float[] array, float phase)Changes the value of the line dash pattern.voidsetLineDash(float unitsOn, float phase)Changes the value of the line dash pattern.voidsetLineDash(float unitsOn, float unitsOff, float phase)Changes the value of the line dash pattern.voidsetLineJoin(int style)Changes the Line join style.voidsetLineWidth(double w)Changes the line width.voidsetLineWidth(float w)Changes the line width.voidsetLiteral(char c)Outputs achardirectly to the content.voidsetLiteral(float n)Outputs afloatdirectly to the content.voidsetLiteral(java.lang.String s)Outputs aStringdirectly to the content.protected voidsetMcDepth(int value)protected voidsetMcElements(java.util.ArrayList<IAccessibleElement> value)voidsetMiterLimit(double miterLimit)Changes the Miter limit.voidsetMiterLimit(float miterLimit)Changes the Miter limit.voidsetPatternFill(PdfPatternPainter p)Sets the fill color to a pattern.voidsetPatternFill(PdfPatternPainter p, BaseColor color)Sets the fill color to an uncolored pattern.voidsetPatternFill(PdfPatternPainter p, BaseColor color, float tint)Sets the fill color to an uncolored pattern.voidsetPatternStroke(PdfPatternPainter p)Sets the stroke color to a pattern.voidsetPatternStroke(PdfPatternPainter p, BaseColor color)Sets the stroke color to an uncolored pattern.voidsetPatternStroke(PdfPatternPainter p, BaseColor color, float tint)Sets the stroke color to an uncolored pattern.voidsetRenderingIntent(PdfName ri)Set the rendering intent, possible values are: PdfName.ABSOLUTECOLORIMETRIC, PdfName.RELATIVECOLORIMETRIC, PdfName.SATURATION, PdfName.PERCEPTUAL.voidsetRGBColorFill(int red, int green, int blue)Changes the current color for filling paths (device dependent colors!).voidsetRGBColorFillF(float red, float green, float blue)Changes the current color for filling paths (device dependent colors!).voidsetRGBColorStroke(int red, int green, int blue)Changes the current color for stroking paths (device dependent colors!).voidsetRGBColorStrokeF(float red, float green, float blue)Changes the current color for stroking paths (device dependent colors!).voidsetShadingFill(PdfShadingPattern shading)Sets the shading fill pattern.voidsetShadingStroke(PdfShadingPattern shading)Sets the shading stroke patternPdfContentBytesetSuppressTagging(boolean suppressTagging)[SUP-1395] If set, prevents iText from marking content and creating structure tags for items added to this content stream.voidsetTextMatrix(float x, float y)Changes the text matrix.voidsetTextMatrix(float a, float b, float c, float d, float x, float y)Changes the text matrix.voidsetTextMatrix(AffineTransform transform)Changes the text matrix.voidsetTextMatrix(java.awt.geom.AffineTransform transform)Deprecated.use com.itextpdf.text.geom.AffineTransform as parametervoidsetTextRenderingMode(int rendering)Sets the text rendering parameter.voidsetTextRise(double rise)Sets the text rise parameter.voidsetTextRise(float rise)Sets the text rise parameter.voidsetWordSpacing(float wordSpace)Sets the word spacing parameter.voidshowText(PdfTextArray text)Show an array of text.voidshowText(java.lang.String text)Shows thetext.private voidshowText2(java.lang.String text)A helper to insert into the content stream thetextconverted to bytes according to the font's encoding.voidshowTextAligned(int alignment, java.lang.String text, float x, float y, float rotation)Shows text right, left or center aligned with rotation.private voidshowTextAligned(int alignment, java.lang.String text, float x, float y, float rotation, boolean kerned)voidshowTextAlignedKerned(int alignment, java.lang.String text, float x, float y, float rotation)Shows text kerned right, left or center aligned with rotation.voidshowTextGid(java.lang.String gids)voidshowTextKerned(java.lang.String text)Shows thetextkerned.(package private) intsize()Gets the size of this content.(package private) intsize(boolean includeMarkedContentSize)voidstroke()Strokes the path.byte[]toPdf(PdfWriter writer)Returns the PDF representation of thisPdfContentByte-object.java.lang.StringtoString()Returns theStringrepresentation of thisPdfContentByte-object.voidtransform(AffineTransform af)Concatenates a transformation to the current transformation matrix.voidtransform(java.awt.geom.AffineTransform af)Deprecated.use com.itextpdf.text.geom.AffineTransform as parameterprotected voidupdateTx(java.lang.String text, float Tj)voidvariableRectangle(Rectangle rect)Adds a variable width border to the current path.
-
-
-
Field Detail
-
ALIGN_CENTER
public static final int ALIGN_CENTER
The alignment is center- See Also:
- Constant Field Values
-
ALIGN_LEFT
public static final int ALIGN_LEFT
The alignment is left- See Also:
- Constant Field Values
-
ALIGN_RIGHT
public static final int ALIGN_RIGHT
The alignment is right- See Also:
- Constant Field Values
-
LINE_CAP_BUTT
public static final int LINE_CAP_BUTT
A possible line cap value- See Also:
- Constant Field Values
-
LINE_CAP_ROUND
public static final int LINE_CAP_ROUND
A possible line cap value- See Also:
- Constant Field Values
-
LINE_CAP_PROJECTING_SQUARE
public static final int LINE_CAP_PROJECTING_SQUARE
A possible line cap value- See Also:
- Constant Field Values
-
LINE_JOIN_MITER
public static final int LINE_JOIN_MITER
A possible line join value- See Also:
- Constant Field Values
-
LINE_JOIN_ROUND
public static final int LINE_JOIN_ROUND
A possible line join value- See Also:
- Constant Field Values
-
LINE_JOIN_BEVEL
public static final int LINE_JOIN_BEVEL
A possible line join value- See Also:
- Constant Field Values
-
TEXT_RENDER_MODE_FILL
public static final int TEXT_RENDER_MODE_FILL
A possible text rendering value- See Also:
- Constant Field Values
-
TEXT_RENDER_MODE_STROKE
public static final int TEXT_RENDER_MODE_STROKE
A possible text rendering value- See Also:
- Constant Field Values
-
TEXT_RENDER_MODE_FILL_STROKE
public static final int TEXT_RENDER_MODE_FILL_STROKE
A possible text rendering value- See Also:
- Constant Field Values
-
TEXT_RENDER_MODE_INVISIBLE
public static final int TEXT_RENDER_MODE_INVISIBLE
A possible text rendering value- See Also:
- Constant Field Values
-
TEXT_RENDER_MODE_FILL_CLIP
public static final int TEXT_RENDER_MODE_FILL_CLIP
A possible text rendering value- See Also:
- Constant Field Values
-
TEXT_RENDER_MODE_STROKE_CLIP
public static final int TEXT_RENDER_MODE_STROKE_CLIP
A possible text rendering value- See Also:
- Constant Field Values
-
TEXT_RENDER_MODE_FILL_STROKE_CLIP
public static final int TEXT_RENDER_MODE_FILL_STROKE_CLIP
A possible text rendering value- See Also:
- Constant Field Values
-
TEXT_RENDER_MODE_CLIP
public static final int TEXT_RENDER_MODE_CLIP
A possible text rendering value- See Also:
- Constant Field Values
-
unitRect
private static final float[] unitRect
-
content
protected ByteBuffer content
This is the actual content
-
markedContentSize
protected int markedContentSize
-
writer
protected PdfWriter writer
This is the writer
-
pdf
protected PdfDocument pdf
This is the PdfDocument
-
state
protected PdfContentByte.GraphicState state
This is the GraphicState in use
-
stateList
protected java.util.ArrayList<PdfContentByte.GraphicState> stateList
The list were we save/restore the state
-
layerDepth
protected java.util.ArrayList<java.lang.Integer> layerDepth
The list were we save/restore the layer depth
-
separator
protected int separator
The separator between commands.
-
mcDepth
private int mcDepth
-
inText
private boolean inText
-
suppressTagging
private boolean suppressTagging
-
abrev
private static java.util.HashMap<PdfName,java.lang.String> abrev
-
mcElements
private java.util.ArrayList<IAccessibleElement> mcElements
-
duplicatedFrom
protected PdfContentByte duplicatedFrom
-
-
Constructor Detail
-
PdfContentByte
public PdfContentByte(PdfWriter wr)
Constructs a newPdfContentByte-object.- Parameters:
wr- the writer associated to this content
-
-
Method Detail
-
toString
public java.lang.String toString()
Returns theStringrepresentation of thisPdfContentByte-object.- Overrides:
toStringin classjava.lang.Object- Returns:
- a
String
-
isTaggingSuppressed
public boolean isTaggingSuppressed()
[SUP-1395] If set, prevents iText from marking content and creating structure tags for items added to this content stream. (By default, iText automatically marks content using BDC/EMC operators, and adds a structure tag for the new content at the end of the page.)
-
setSuppressTagging
public PdfContentByte setSuppressTagging(boolean suppressTagging)
[SUP-1395] If set, prevents iText from marking content and creating structure tags for items added to this content stream. (By default, iText automatically marks content using BDC/EMC operators, and adds a structure tag for the new content at the end of the page.)
-
isTagged
public boolean isTagged()
Checks if the content needs to be tagged.- Returns:
- false if no tags need to be added
-
getInternalBuffer
public ByteBuffer getInternalBuffer()
Gets the internal buffer.- Returns:
- the internal buffer
-
toPdf
public byte[] toPdf(PdfWriter writer)
Returns the PDF representation of thisPdfContentByte-object.- Parameters:
writer- thePdfWriter- Returns:
- a
bytearray with the representation
-
add
public void add(PdfContentByte other)
Adds the content of anotherPdfContentByte-object to this object.- Parameters:
other- anotherPdfByteContent-object
-
getXTLM
public float getXTLM()
Gets the x position of the text line matrix.- Returns:
- the x position of the text line matrix
-
getYTLM
public float getYTLM()
Gets the y position of the text line matrix.- Returns:
- the y position of the text line matrix
-
getLeading
public float getLeading()
Gets the current text leading.- Returns:
- the current text leading
-
getCharacterSpacing
public float getCharacterSpacing()
Gets the current character spacing.- Returns:
- the current character spacing
-
getWordSpacing
public float getWordSpacing()
Gets the current word spacing.- Returns:
- the current word spacing
-
getHorizontalScaling
public float getHorizontalScaling()
Gets the current character spacing.- Returns:
- the current character spacing
-
setFlatness
public void setFlatness(float flatness)
Changes the Flatness.Flatness sets the maximum permitted distance in device pixels between the mathematically correct path and an approximation constructed from straight line segments.
- Parameters:
flatness- a value
-
setFlatness
public void setFlatness(double flatness)
Changes the Flatness.Flatness sets the maximum permitted distance in device pixels between the mathematically correct path and an approximation constructed from straight line segments.
- Parameters:
flatness- a value
-
setLineCap
public void setLineCap(int style)
Changes the Line cap style.The line cap style specifies the shape to be used at the end of open subpaths when they are stroked.
Allowed values are LINE_CAP_BUTT, LINE_CAP_ROUND and LINE_CAP_PROJECTING_SQUARE.- Parameters:
style- a value
-
setRenderingIntent
public void setRenderingIntent(PdfName ri)
Set the rendering intent, possible values are: PdfName.ABSOLUTECOLORIMETRIC, PdfName.RELATIVECOLORIMETRIC, PdfName.SATURATION, PdfName.PERCEPTUAL.- Parameters:
ri-
-
setLineDash
public void setLineDash(float phase)
Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
phase- the value of the phase
-
setLineDash
public void setLineDash(double phase)
Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
phase- the value of the phase
-
setLineDash
public void setLineDash(float unitsOn, float phase)Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
phase- the value of the phaseunitsOn- the number of units that must be 'on' (equals the number of units that must be 'off').
-
setLineDash
public void setLineDash(double unitsOn, double phase)Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
phase- the value of the phaseunitsOn- the number of units that must be 'on' (equals the number of units that must be 'off').
-
setLineDash
public void setLineDash(float unitsOn, float unitsOff, float phase)Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
phase- the value of the phaseunitsOn- the number of units that must be 'on'unitsOff- the number of units that must be 'off'
-
setLineDash
public void setLineDash(double unitsOn, double unitsOff, double phase)Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
phase- the value of the phaseunitsOn- the number of units that must be 'on'unitsOff- the number of units that must be 'off'
-
setLineDash
public final void setLineDash(float[] array, float phase)Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
array- length of the alternating dashes and gapsphase- the value of the phase
-
setLineDash
public final void setLineDash(double[] array, double phase)Changes the value of the line dash pattern.The line dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by an array and a phase. The array specifies the length of the alternating dashes and gaps. The phase specifies the distance into the dash pattern to start the dash.
- Parameters:
array- length of the alternating dashes and gapsphase- the value of the phase
-
setLineJoin
public void setLineJoin(int style)
Changes the Line join style.The line join style specifies the shape to be used at the corners of paths that are stroked.
Allowed values are LINE_JOIN_MITER (Miter joins), LINE_JOIN_ROUND (Round joins) and LINE_JOIN_BEVEL (Bevel joins).- Parameters:
style- a value
-
setLineWidth
public void setLineWidth(float w)
Changes the line width.The line width specifies the thickness of the line used to stroke a path and is measured in user space units.
- Parameters:
w- a width
-
setLineWidth
public void setLineWidth(double w)
Changes the line width.The line width specifies the thickness of the line used to stroke a path and is measured in user space units.
- Parameters:
w- a width
-
setMiterLimit
public void setMiterLimit(float miterLimit)
Changes the Miter limit.When two line segments meet at a sharp angle and mitered joins have been specified as the line join style, it is possible for the miter to extend far beyond the thickness of the line stroking path. The miter limit imposes a maximum on the ratio of the miter length to the line witdh. When the limit is exceeded, the join is converted from a miter to a bevel.
- Parameters:
miterLimit- a miter limit
-
setMiterLimit
public void setMiterLimit(double miterLimit)
Changes the Miter limit.When two line segments meet at a sharp angle and mitered joins have been specified as the line join style, it is possible for the miter to extend far beyond the thickness of the line stroking path. The miter limit imposes a maximum on the ratio of the miter length to the line witdh. When the limit is exceeded, the join is converted from a miter to a bevel.
- Parameters:
miterLimit- a miter limit
-
clip
public void clip()
Modify the current clipping path by intersecting it with the current path, using the nonzero winding number rule to determine which regions lie inside the clipping path.
-
eoClip
public void eoClip()
Modify the current clipping path by intersecting it with the current path, using the even-odd rule to determine which regions lie inside the clipping path.
-
setGrayFill
public void setGrayFill(float gray)
Changes the currentgray tint for filling paths (device dependent colors!).Sets the color space to DeviceGray (or the DefaultGray color space), and sets the gray tint to use for filling paths.
- Parameters:
gray- a value between 0 (black) and 1 (white)
-
resetGrayFill
public void resetGrayFill()
Changes the current gray tint for filling paths to black.
-
setGrayStroke
public void setGrayStroke(float gray)
Changes the currentgray tint for stroking paths (device dependent colors!).Sets the color space to DeviceGray (or the DefaultGray color space), and sets the gray tint to use for stroking paths.
- Parameters:
gray- a value between 0 (black) and 1 (white)
-
resetGrayStroke
public void resetGrayStroke()
Changes the current gray tint for stroking paths to black.
-
HelperRGB
private void HelperRGB(float red, float green, float blue)Helper to validate and write the RGB color components- Parameters:
red- the intensity of red. A value between 0 and 1green- the intensity of green. A value between 0 and 1blue- the intensity of blue. A value between 0 and 1
-
setRGBColorFillF
public void setRGBColorFillF(float red, float green, float blue)Changes the current color for filling paths (device dependent colors!).Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for filling paths.
Following the PDF manual, each operand must be a number between 0 (minimum intensity) and 1 (maximum intensity).
- Parameters:
red- the intensity of red. A value between 0 and 1green- the intensity of green. A value between 0 and 1blue- the intensity of blue. A value between 0 and 1
-
resetRGBColorFill
public void resetRGBColorFill()
Changes the current color for filling paths to black.
-
setRGBColorStrokeF
public void setRGBColorStrokeF(float red, float green, float blue)Changes the current color for stroking paths (device dependent colors!).Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for stroking paths.
Following the PDF manual, each operand must be a number between 0 (miniumum intensity) and 1 (maximum intensity).
- Parameters:
red- the intensity of red. A value between 0 and 1green- the intensity of green. A value between 0 and 1blue- the intensity of blue. A value between 0 and 1
-
resetRGBColorStroke
public void resetRGBColorStroke()
Changes the current color for stroking paths to black.
-
HelperCMYK
private void HelperCMYK(float cyan, float magenta, float yellow, float black)Helper to validate and write the CMYK color components.- Parameters:
cyan- the intensity of cyan. A value between 0 and 1magenta- the intensity of magenta. A value between 0 and 1yellow- the intensity of yellow. A value between 0 and 1black- the intensity of black. A value between 0 and 1
-
setCMYKColorFillF
public void setCMYKColorFillF(float cyan, float magenta, float yellow, float black)Changes the current color for filling paths (device dependent colors!).Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for filling paths.
Following the PDF manual, each operand must be a number between 0 (no ink) and 1 (maximum ink).
- Parameters:
cyan- the intensity of cyan. A value between 0 and 1magenta- the intensity of magenta. A value between 0 and 1yellow- the intensity of yellow. A value between 0 and 1black- the intensity of black. A value between 0 and 1
-
resetCMYKColorFill
public void resetCMYKColorFill()
Changes the current color for filling paths to black.
-
setCMYKColorStrokeF
public void setCMYKColorStrokeF(float cyan, float magenta, float yellow, float black)Changes the current color for stroking paths (device dependent colors!).Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for stroking paths.
Following the PDF manual, each operand must be a number between 0 (miniumum intensity) and 1 (maximum intensity).
- Parameters:
cyan- the intensity of cyan. A value between 0 and 1magenta- the intensity of magenta. A value between 0 and 1yellow- the intensity of yellow. A value between 0 and 1black- the intensity of black. A value between 0 and 1
-
resetCMYKColorStroke
public void resetCMYKColorStroke()
Changes the current color for stroking paths to black.
-
moveTo
public void moveTo(float x, float y)Move the current point (x, y), omitting any connecting line segment.- Parameters:
x- new x-coordinatey- new y-coordinate
-
moveTo
public void moveTo(double x, double y)Move the current point (x, y), omitting any connecting line segment.- Parameters:
x- new x-coordinatey- new y-coordinate
-
lineTo
public void lineTo(float x, float y)Appends a straight line segment from the current point (x, y). The new current point is (x, y).- Parameters:
x- new x-coordinatey- new y-coordinate
-
lineTo
public void lineTo(double x, double y)Appends a straight line segment from the current point (x, y). The new current point is (x, y).- Parameters:
x- new x-coordinatey- new y-coordinate
-
curveTo
public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)Appends a Bêzier curve to the path, starting from the current point.- Parameters:
x1- x-coordinate of the first control pointy1- y-coordinate of the first control pointx2- x-coordinate of the second control pointy2- y-coordinate of the second control pointx3- x-coordinate of the ending point (= new current point)y3- y-coordinate of the ending point (= new current point)
-
curveTo
public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3)Appends a Bêzier curve to the path, starting from the current point.- Parameters:
x1- x-coordinate of the first control pointy1- y-coordinate of the first control pointx2- x-coordinate of the second control pointy2- y-coordinate of the second control pointx3- x-coordinate of the ending point (= new current point)y3- y-coordinate of the ending point (= new current point)
-
curveTo
public void curveTo(float x2, float y2, float x3, float y3)Appends a Bêzier curve to the path, starting from the current point.- Parameters:
x2- x-coordinate of the second control pointy2- y-coordinate of the second control pointx3- x-coordinate of the ending point (= new current point)y3- y-coordinate of the ending point (= new current point)
-
curveTo
public void curveTo(double x2, double y2, double x3, double y3)Appends a Bêzier curve to the path, starting from the current point.- Parameters:
x2- x-coordinate of the second control pointy2- y-coordinate of the second control pointx3- x-coordinate of the ending point (= new current point)y3- y-coordinate of the ending point (= new current point)
-
curveFromTo
public void curveFromTo(float x1, float y1, float x3, float y3)Appends a Bêzier curve to the path, starting from the current point.- Parameters:
x1- x-coordinate of the first control pointy1- y-coordinate of the first control pointx3- x-coordinate of the ending point (= new current point)y3- y-coordinate of the ending point (= new current point)
-
curveFromTo
public void curveFromTo(double x1, double y1, double x3, double y3)Appends a Bêzier curve to the path, starting from the current point.- Parameters:
x1- x-coordinate of the first control pointy1- y-coordinate of the first control pointx3- x-coordinate of the ending point (= new current point)y3- y-coordinate of the ending point (= new current point)
-
circle
public void circle(float x, float y, float r)Draws a circle. The endpoint will (x+r, y).- Parameters:
x- x center of circley- y center of circler- radius of circle
-
circle
public void circle(double x, double y, double r)Draws a circle. The endpoint will (x+r, y).- Parameters:
x- x center of circley- y center of circler- radius of circle
-
rectangle
public void rectangle(float x, float y, float w, float h)Adds a rectangle to the current path.- Parameters:
x- x-coordinate of the starting pointy- y-coordinate of the starting pointw- widthh- height
-
rectangle
public void rectangle(double x, double y, double w, double h)Adds a rectangle to the current path.- Parameters:
x- x-coordinate of the starting pointy- y-coordinate of the starting pointw- widthh- height
-
variableRectangle
public void variableRectangle(Rectangle rect)
Adds a variable width border to the current path. Only use ifRectangle.isUseVariableBorders= true.- Parameters:
rect- aRectangle
-
rectangle
public void rectangle(Rectangle rectangle)
Adds a border (complete or partially) to the current path..- Parameters:
rectangle- aRectangle
-
closePath
public void closePath()
Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath.
-
newPath
public void newPath()
Ends the path without filling or stroking it.
-
stroke
public void stroke()
Strokes the path.
-
closePathStroke
public void closePathStroke()
Closes the path and strokes it.
-
fill
public void fill()
Fills the path, using the non-zero winding number rule to determine the region to fill.
-
eoFill
public void eoFill()
Fills the path, using the even-odd rule to determine the region to fill.
-
fillStroke
public void fillStroke()
Fills the path using the non-zero winding number rule to determine the region to fill and strokes it.
-
closePathFillStroke
public void closePathFillStroke()
Closes the path, fills it using the non-zero winding number rule to determine the region to fill and strokes it.
-
eoFillStroke
public void eoFillStroke()
Fills the path, using the even-odd rule to determine the region to fill and strokes it.
-
closePathEoFillStroke
public void closePathEoFillStroke()
Closes the path, fills it using the even-odd rule to determine the region to fill and strokes it.
-
addImage
public void addImage(Image image) throws DocumentException
Adds anImageto the page. TheImagemust have absolute positioning.- Parameters:
image- theImageobject- Throws:
DocumentException- if theImagedoes not have absolute positioning
-
addImage
public void addImage(Image image, boolean inlineImage) throws DocumentException
Adds anImageto the page. TheImagemust have absolute positioning. The image can be placed inline.- Parameters:
image- theImageobjectinlineImage-trueto place this image inline,falseotherwise- Throws:
DocumentException- if theImagedoes not have absolute positioning
-
addImage
public void addImage(Image image, float a, float b, float c, float d, float e, float f) throws DocumentException
Adds anImageto the page. The positioning of theImageis done with the transformation matrix. To position animageat (x,y) use addImage(image, image_width, 0, 0, image_height, x, y).- Parameters:
image- theImageobjecta- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrix- Throws:
DocumentException- on error
-
addImage
public void addImage(Image image, double a, double b, double c, double d, double e, double f) throws DocumentException
Adds anImageto the page. The positioning of theImageis done with the transformation matrix. To position animageat (x,y) use addImage(image, image_width, 0, 0, image_height, x, y).- Parameters:
image- theImageobjecta- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrix- Throws:
DocumentException- on error
-
addImage
public void addImage(Image image, AffineTransform transform) throws DocumentException
adds an image with the given matrix.- Parameters:
image- image to addtransform- transform to apply to the template prior to adding it.- Throws:
DocumentException
-
addImage
public void addImage(Image image, float a, float b, float c, float d, float e, float f, boolean inlineImage) throws DocumentException
Adds anImageto the page. The positioning of theImageis done with the transformation matrix. To position animageat (x,y) use addImage(image, image_width, 0, 0, image_height, x, y). The image can be placed inline.- Parameters:
image- theImageobjecta- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrixinlineImage-trueto place this image inline,falseotherwise- Throws:
DocumentException- on error
-
addImage
public void addImage(Image image, double a, double b, double c, double d, double e, double f, boolean inlineImage) throws DocumentException
Adds anImageto the page. The positioning of theImageis done with the transformation matrix. To position animageat (x,y) use addImage(image, image_width, 0, 0, image_height, x, y). The image can be placed inline.- Parameters:
image- theImageobjecta- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrixinlineImage-trueto place this image inline,falseotherwise- Throws:
DocumentException- on error
-
addImage
protected void addImage(Image image, double a, double b, double c, double d, double e, double f, boolean inlineImage, boolean isMCBlockOpened) throws DocumentException
Adds anImageto the page. The positioning of theImageis done with the transformation matrix. To position animageat (x,y) The image can be placed inline.- Parameters:
image- theImageobjecta- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrixinlineImage-trueto place this image inline,falseotherwiseisMCBlockOpened-truenot to open MCBlock,falseotherwise- Throws:
DocumentException- on error
-
reset
public void reset()
Makes thisPdfContentByteempty. Callsreset( true )
-
reset
public void reset(boolean validateContent)
Makes thisPdfContentByteempty.- Parameters:
validateContent- will callsanityCheck()if true.- Since:
- 2.1.6
-
beginText
protected void beginText(boolean restoreTM)
Starts the writing of text.- Parameters:
restoreTM- indicates if to restore text matrix of the previous text block.
-
beginText
public void beginText()
Starts the writing of text.
-
endText
public void endText()
Ends the writing of text and makes the current font invalid.
-
saveState
public void saveState()
Saves the graphic state.saveStateandrestoreStatemust be balanced.
-
restoreState
public void restoreState()
Restores the graphic state.saveStateandrestoreStatemust be balanced.
-
setCharacterSpacing
public void setCharacterSpacing(float charSpace)
Sets the character spacing parameter.- Parameters:
charSpace- a parameter
-
setWordSpacing
public void setWordSpacing(float wordSpace)
Sets the word spacing parameter.- Parameters:
wordSpace- a parameter
-
setHorizontalScaling
public void setHorizontalScaling(float scale)
Sets the horizontal scaling parameter.- Parameters:
scale- a parameter
-
setLeading
public void setLeading(float leading)
Sets the text leading parameter.The leading parameter is measured in text space units. It specifies the vertical distance between the baselines of adjacent lines of text.
- Parameters:
leading- the new leading
-
setFontAndSize
public void setFontAndSize(BaseFont bf, float size)
Set the font and the size for the subsequent text writing.- Parameters:
bf- the fontsize- the font size in points
-
setTextRenderingMode
public void setTextRenderingMode(int rendering)
Sets the text rendering parameter.- Parameters:
rendering- a parameter
-
setTextRise
public void setTextRise(float rise)
Sets the text rise parameter.This allows to write text in subscript or superscript mode.
- Parameters:
rise- a parameter
-
setTextRise
public void setTextRise(double rise)
Sets the text rise parameter.This allows to write text in subscript or superscript mode.
- Parameters:
rise- a parameter
-
showText2
private void showText2(java.lang.String text)
A helper to insert into the content stream thetextconverted to bytes according to the font's encoding.- Parameters:
text- the text to write
-
showText
public void showText(java.lang.String text)
Shows thetext.- Parameters:
text- the text to write
-
showTextGid
public void showTextGid(java.lang.String gids)
-
getKernArray
public static PdfTextArray getKernArray(java.lang.String text, BaseFont font)
Constructs a kern array for a text in a certain font- Parameters:
text- the textfont- the font- Returns:
- a PdfTextArray
-
showTextKerned
public void showTextKerned(java.lang.String text)
Shows thetextkerned.- Parameters:
text- the text to write
-
newlineShowText
public void newlineShowText(java.lang.String text)
Moves to the next line and showstext.- Parameters:
text- the text to write
-
newlineShowText
public void newlineShowText(float wordSpacing, float charSpacing, java.lang.String text)Moves to the next line and shows text string, using the given values of the character and word spacing parameters.- Parameters:
wordSpacing- a parametercharSpacing- a parametertext- the text to write
-
setTextMatrix
public void setTextMatrix(float a, float b, float c, float d, float x, float y)Changes the text matrix.Remark: this operation also initializes the current point position.
- Parameters:
a- operand 1,1 in the matrixb- operand 1,2 in the matrixc- operand 2,1 in the matrixd- operand 2,2 in the matrixx- operand 3,1 in the matrixy- operand 3,2 in the matrix
-
setTextMatrix
public void setTextMatrix(AffineTransform transform)
Changes the text matrix.- Parameters:
transform- overwrite the current text matrix with this one
-
setTextMatrix
public void setTextMatrix(float x, float y)Changes the text matrix. The first four parameters are {1,0,0,1}.Remark: this operation also initializes the current point position.
- Parameters:
x- operand 3,1 in the matrixy- operand 3,2 in the matrix
-
moveText
public void moveText(float x, float y)Moves to the start of the next line, offset from the start of the current line.- Parameters:
x- x-coordinate of the new current pointy- y-coordinate of the new current point
-
moveTextWithLeading
public void moveTextWithLeading(float x, float y)Moves to the start of the next line, offset from the start of the current line.As a side effect, this sets the leading parameter in the text state.
- Parameters:
x- offset of the new current pointy- y-coordinate of the new current point
-
newlineText
public void newlineText()
Moves to the start of the next line.
-
size
int size()
Gets the size of this content.- Returns:
- the size of the content
-
size
int size(boolean includeMarkedContentSize)
-
addOutline
public void addOutline(PdfOutline outline, java.lang.String name)
Adds a named outline to the document.- Parameters:
outline- the outlinename- the name for the local destination
-
getRootOutline
public PdfOutline getRootOutline()
Gets the root outline.- Returns:
- the root outline
-
getEffectiveStringWidth
public float getEffectiveStringWidth(java.lang.String text, boolean kerned)Computes the width of the given string taking in account the current values of "Character spacing", "Word Spacing" and "Horizontal Scaling". The additional spacing is not computed for the last character of the string.- Parameters:
text- the string to get width ofkerned- the kerning option- Returns:
- the width
-
getEffectiveStringWidth
private float getEffectiveStringWidth(java.lang.String text, boolean kerned, float kerning)Computes the width of the given string taking in account the current values of "Character spacing", "Word Spacing" and "Horizontal Scaling". The spacing for the last character is also computed. It also takes into account kerning that can be specified within TJ operator (e.g. [(Hello) 123 (World)] TJ)- Parameters:
text- the string to get width ofkerned- the kerning optionkerning- the kerning option from TJ array- Returns:
- the width
-
showTextAligned
public void showTextAligned(int alignment, java.lang.String text, float x, float y, float rotation)Shows text right, left or center aligned with rotation.- Parameters:
alignment- the alignment can be ALIGN_CENTER, ALIGN_RIGHT or ALIGN_LEFTtext- the text to showx- the x pivot positiony- the y pivot positionrotation- the rotation to be applied in degrees counterclockwise
-
showTextAligned
private void showTextAligned(int alignment, java.lang.String text, float x, float y, float rotation, boolean kerned)
-
showTextAlignedKerned
public void showTextAlignedKerned(int alignment, java.lang.String text, float x, float y, float rotation)Shows text kerned right, left or center aligned with rotation.- Parameters:
alignment- the alignment can be ALIGN_CENTER, ALIGN_RIGHT or ALIGN_LEFTtext- the text to showx- the x pivot positiony- the y pivot positionrotation- the rotation to be applied in degrees counterclockwise
-
concatCTM
public void concatCTM(float a, float b, float c, float d, float e, float f)Concatenate a matrix to the current transformation matrix. Common transformations:- Translation: [1 0 0 1 tx ty]
- Scaling: [sx 0 0 sy 0 0] (if sx or sy is negative, it will flip the coordinate system)
- Rotation: [cos(q) sin(q) -sin(q) cos(q) 0 0] where q is angle of counter-clockwise rotation (rotated around positive z-axis - use Right Hand Rule)
- Rotate 90 degrees CCW: [0 1 -1 0 0 0]
- Rotate 180 degrees: [-1 0 0 -1 0 0]
- Rotate 270 degrees: [0 -1 1 0 0 0]
- Skew: [1 tan(a) tan(b) 1 0 0] where a is x-axis skew angle and b is y-axis skew angle
- Parameters:
a- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrix
-
concatCTM
public void concatCTM(double a, double b, double c, double d, double e, double f)Concatenate a matrix to the current transformation matrix. Common transformations:- Translation: [1 0 0 1 tx ty]
- Scaling: [sx 0 0 sy 0 0] (if sx or sy is negative, it will flip the coordinate system)
- Rotation: [cos(q) sin(q) -sin(q) cos(q) 0 0] where q is angle of counter-clockwise rotation (rotated around positive z-axis - use Right Hand Rule)
- Rotate 90 degrees CCW: [0 1 -1 0 0 0]
- Rotate 180 degrees: [-1 0 0 -1 0 0]
- Rotate 270 degrees: [0 -1 1 0 0 0]
- Skew: [1 tan(a) tan(b) 1 0 0] where a is x-axis skew angle and b is y-axis skew angle
- Parameters:
a- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrix
-
concatCTM
public void concatCTM(AffineTransform transform)
Concatenate a matrix to the current transformation matrix.- Parameters:
transform- added to the Current Transformation Matrix
-
bezierArc
public static java.util.ArrayList<double[]> bezierArc(float x1, float y1, float x2, float y2, float startAng, float extent)Generates an array of bezier curves to draw an arc.(x1, y1) and (x2, y2) are the corners of the enclosing rectangle. Angles, measured in degrees, start with 0 to the right (the positive X axis) and increase counter-clockwise. The arc extends from startAng to startAng+extent. I.e. startAng=0 and extent=180 yields an openside-down semi-circle.
The resulting coordinates are of the form float[]{x1,y1,x2,y2,x3,y3, x4,y4} such that the curve goes from (x1, y1) to (x4, y4) with (x2, y2) and (x3, y3) as their respective Bezier control points.
Note: this code was taken from ReportLab (www.reportlab.org), an excellent PDF generator for Python (BSD license: http://www.reportlab.org/devfaq.html#1.3 ).
- Parameters:
x1- a corner of the enclosing rectangley1- a corner of the enclosing rectanglex2- a corner of the enclosing rectangley2- a corner of the enclosing rectanglestartAng- starting angle in degreesextent- angle extent in degrees- Returns:
- a list of float[] with the bezier curves
-
bezierArc
public static java.util.ArrayList<double[]> bezierArc(double x1, double y1, double x2, double y2, double startAng, double extent)Generates an array of bezier curves to draw an arc.(x1, y1) and (x2, y2) are the corners of the enclosing rectangle. Angles, measured in degrees, start with 0 to the right (the positive X axis) and increase counter-clockwise. The arc extends from startAng to startAng+extent. I.e. startAng=0 and extent=180 yields an openside-down semi-circle.
The resulting coordinates are of the form float[]{x1,y1,x2,y2,x3,y3, x4,y4} such that the curve goes from (x1, y1) to (x4, y4) with (x2, y2) and (x3, y3) as their respective Bezier control points.
Note: this code was taken from ReportLab (www.reportlab.org), an excellent PDF generator for Python (BSD license: http://www.reportlab.org/devfaq.html#1.3 ).
- Parameters:
x1- a corner of the enclosing rectangley1- a corner of the enclosing rectanglex2- a corner of the enclosing rectangley2- a corner of the enclosing rectanglestartAng- starting angle in degreesextent- angle extent in degrees- Returns:
- a list of float[] with the bezier curves
-
arc
public void arc(float x1, float y1, float x2, float y2, float startAng, float extent)Draws a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees. Angles start with 0 to the right (+x) and increase counter-clockwise.- Parameters:
x1- a corner of the enclosing rectangley1- a corner of the enclosing rectanglex2- a corner of the enclosing rectangley2- a corner of the enclosing rectanglestartAng- starting angle in degreesextent- angle extent in degrees
-
arc
public void arc(double x1, double y1, double x2, double y2, double startAng, double extent)Draws a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees. Angles start with 0 to the right (+x) and increase counter-clockwise.- Parameters:
x1- a corner of the enclosing rectangley1- a corner of the enclosing rectanglex2- a corner of the enclosing rectangley2- a corner of the enclosing rectanglestartAng- starting angle in degreesextent- angle extent in degrees
-
ellipse
public void ellipse(float x1, float y1, float x2, float y2)Draws an ellipse inscribed within the rectangle x1,y1,x2,y2.- Parameters:
x1- a corner of the enclosing rectangley1- a corner of the enclosing rectanglex2- a corner of the enclosing rectangley2- a corner of the enclosing rectangle
-
ellipse
public void ellipse(double x1, double y1, double x2, double y2)Draws an ellipse inscribed within the rectangle x1,y1,x2,y2.- Parameters:
x1- a corner of the enclosing rectangley1- a corner of the enclosing rectanglex2- a corner of the enclosing rectangley2- a corner of the enclosing rectangle
-
createPattern
public PdfPatternPainter createPattern(float width, float height, float xstep, float ystep)
Create a new colored tiling pattern.- Parameters:
width- the width of the patternheight- the height of the patternxstep- the desired horizontal spacing between pattern cells. May be either positive or negative, but not zero.ystep- the desired vertical spacing between pattern cells. May be either positive or negative, but not zero.- Returns:
- the
PdfPatternPainterwhere the pattern will be created
-
createPattern
public PdfPatternPainter createPattern(float width, float height)
Create a new colored tiling pattern. Variables xstep and ystep are set to the same values of width and height.- Parameters:
width- the width of the patternheight- the height of the pattern- Returns:
- the
PdfPatternPainterwhere the pattern will be created
-
createPattern
public PdfPatternPainter createPattern(float width, float height, float xstep, float ystep, BaseColor color)
Create a new uncolored tiling pattern.- Parameters:
width- the width of the patternheight- the height of the patternxstep- the desired horizontal spacing between pattern cells. May be either positive or negative, but not zero.ystep- the desired vertical spacing between pattern cells. May be either positive or negative, but not zero.color- the default color. Can benull- Returns:
- the
PdfPatternPainterwhere the pattern will be created
-
createPattern
public PdfPatternPainter createPattern(float width, float height, BaseColor color)
Create a new uncolored tiling pattern. Variables xstep and ystep are set to the same values of width and height.- Parameters:
width- the width of the patternheight- the height of the patterncolor- the default color. Can benull- Returns:
- the
PdfPatternPainterwhere the pattern will be created
-
createTemplate
public PdfTemplate createTemplate(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
PdfContentByteor 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:
width- the bounding box widthheight- the bounding box height- Returns:
- the created template
-
createTemplate
PdfTemplate createTemplate(float width, float height, PdfName forcedName)
-
createAppearance
public PdfAppearance createAppearance(float width, float height)
Creates a new appearance to be used with form fields.- Parameters:
width- the bounding box widthheight- the bounding box height- Returns:
- the appearance created
-
createAppearance
PdfAppearance createAppearance(float width, float height, PdfName forcedName)
-
addPSXObject
public void addPSXObject(PdfPSXObject psobject)
Adds a PostScript XObject to this content.- Parameters:
psobject- the object
-
addTemplate
public void addTemplate(PdfTemplate template, float a, float b, float c, float d, float e, float f)
Adds a template to this content.- Parameters:
template- the templatea- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrix
-
addTemplate
public void addTemplate(PdfTemplate template, double a, double b, double c, double d, double e, double f)
Adds a template to this content.- Parameters:
template- the templatea- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrix
-
addTemplate
public void addTemplate(PdfTemplate template, float a, float b, float c, float d, float e, float f, boolean tagContent)
Adds a template to this content.- Parameters:
template- the templatea- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrixtagContent-true- template content will be tagged(all that will be added after),false- only a Do operator will be tagged. taken into account only ifisTagged()-true.
-
addTemplate
public void addTemplate(PdfTemplate template, double a, double b, double c, double d, double e, double f, boolean tagContent)
Adds a template to this content.- Parameters:
template- the templatea- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrixtagContent-true- template content will be tagged(all that will be added after),false- only a Do operator will be tagged. taken into account only ifisTagged()-true.
-
addTemplate
private void addTemplate(PdfTemplate template, double a, double b, double c, double d, double e, double f, boolean tagTemplate, boolean tagContent)
Adds a template to this content.- Parameters:
template- the templatea- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrixtagTemplate- defines if template is to be tagged;trueby default,falseused when template is a part ofImgTemplate.tagContent-true- template content will be tagged(all that will be added after),false- only a Do operator will be tagged. taken into account only ifisTagged()andtagTemplateparameter - bothtrue.
-
addFormXObj
public PdfName addFormXObj(PdfStream formXObj, PdfName name, float a, float b, float c, float d, float e, float f) throws java.io.IOException
Adds a form XObject to this content.- Parameters:
formXObj- the form XObjectname- the name of form XObject in content stream. The name is changed, if if it already exists in page resourcesa- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrix- Returns:
- Name under which XObject was stored in resources. See
nameparameter - Throws:
java.io.IOException
-
addFormXObj
public PdfName addFormXObj(PdfStream formXObj, PdfName name, double a, double b, double c, double d, double e, double f) throws java.io.IOException
Adds a form XObject to this content.- Parameters:
formXObj- the form XObjectname- the name of form XObject in content stream. The name is changed, if if it already exists in page resourcesa- an element of the transformation matrixb- an element of the transformation matrixc- an element of the transformation matrixd- an element of the transformation matrixe- an element of the transformation matrixf- an element of the transformation matrix- Returns:
- Name under which XObject was stored in resources. See
nameparameter - Throws:
java.io.IOException
-
addTemplate
public void addTemplate(PdfTemplate template, AffineTransform transform)
adds a template with the given matrix.- Parameters:
template- template to addtransform- transform to apply to the template prior to adding it.
-
addTemplate
public void addTemplate(PdfTemplate template, AffineTransform transform, boolean tagContent)
adds a template with the given matrix.- Parameters:
template- template to addtransform- transform to apply to the template prior to adding it.tagContent-true- template content will be tagged(all that will be added after),false- only a Do operator will be tagged. taken into account only ifisTagged()-true.
-
addTemplateReference
void addTemplateReference(PdfIndirectReference template, PdfName name, float a, float b, float c, float d, float e, float f)
-
addTemplateReference
void addTemplateReference(PdfIndirectReference template, PdfName name, double a, double b, double c, double d, double e, double f)
-
addTemplate
public void addTemplate(PdfTemplate template, float x, float y)
Adds a template to this content.- Parameters:
template- the templatex- the x location of this templatey- the y location of this template
-
addTemplate
public void addTemplate(PdfTemplate template, double x, double y)
Adds a template to this content.- Parameters:
template- the templatex- the x location of this templatey- the y location of this template
-
addTemplate
public void addTemplate(PdfTemplate template, float x, float y, boolean tagContent)
-
addTemplate
public void addTemplate(PdfTemplate template, double x, double y, boolean tagContent)
-
setCMYKColorFill
public void setCMYKColorFill(int cyan, int magenta, int yellow, int black)Changes the current color for filling paths (device dependent colors!).Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for filling paths.
This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).
Following the PDF manual, each operand must be a number between 0 (no ink) and 1 (maximum ink). This method however accepts only integers between 0x00 and 0xFF.
- Parameters:
cyan- the intensity of cyanmagenta- the intensity of magentayellow- the intensity of yellowblack- the intensity of black
-
setCMYKColorStroke
public void setCMYKColorStroke(int cyan, int magenta, int yellow, int black)Changes the current color for stroking paths (device dependent colors!).Sets the color space to DeviceCMYK (or the DefaultCMYK color space), and sets the color to use for stroking paths.
This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).
Following the PDF manual, each operand must be a number between 0 (minimum intensity) and 1 (maximum intensity). This method however accepts only integers between 0x00 and 0xFF.- Parameters:
cyan- the intensity of redmagenta- the intensity of greenyellow- the intensity of blueblack- the intensity of black
-
setRGBColorFill
public void setRGBColorFill(int red, int green, int blue)Changes the current color for filling paths (device dependent colors!).Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for filling paths.
This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).
Following the PDF manual, each operand must be a number between 0 (minimum intensity) and 1 (maximum intensity). This method however accepts only integers between 0x00 and 0xFF.
- Parameters:
red- the intensity of redgreen- the intensity of greenblue- the intensity of blue
-
setRGBColorStroke
public void setRGBColorStroke(int red, int green, int blue)Changes the current color for stroking paths (device dependent colors!).Sets the color space to DeviceRGB (or the DefaultRGB color space), and sets the color to use for stroking paths.
This method is described in the 'Portable Document Format Reference Manual version 1.3' section 8.5.2.1 (page 331).
Following the PDF manual, each operand must be a number between 0 (minimum intensity) and 1 (maximum intensity). This method however accepts only integers between 0x00 and 0xFF.- Parameters:
red- the intensity of redgreen- the intensity of greenblue- the intensity of blue
-
setColorStroke
public void setColorStroke(BaseColor color)
Sets the stroke color.colorcan be anExtendedColor.- Parameters:
color- the color
-
setColorFill
public void setColorFill(BaseColor color)
Sets the fill color.colorcan be anExtendedColor.- Parameters:
color- the color
-
setColorFill
public void setColorFill(PdfSpotColor sp, float tint)
Sets the fill color to a spot color.- Parameters:
sp- the spot colortint- the tint for the spot color. 0 is no color and 1 is 100% color
-
setColorFill
public void setColorFill(PdfDeviceNColor dn, float[] tints)
-
setColorFill
public void setColorFill(PdfLabColor lab, float l, float a, float b)
-
setColorStroke
public void setColorStroke(PdfSpotColor sp, float tint)
Sets the stroke color to a spot color.- Parameters:
sp- the spot colortint- the tint for the spot color. 0 is no color and 1 is 100% color
-
setColorStroke
public void setColorStroke(PdfDeviceNColor sp, float[] tints)
-
setColorStroke
public void setColorStroke(PdfLabColor lab, float l, float a, float b)
-
setPatternFill
public void setPatternFill(PdfPatternPainter p)
Sets the fill color to a pattern. The pattern can be colored or uncolored.- Parameters:
p- the pattern
-
outputColorNumbers
void outputColorNumbers(BaseColor color, float tint)
Outputs the color values to the content.- Parameters:
color- The colortint- the tint if it is a spot color, ignored otherwise
-
setPatternFill
public void setPatternFill(PdfPatternPainter p, BaseColor color)
Sets the fill color to an uncolored pattern.- Parameters:
p- the patterncolor- the color of the pattern
-
setPatternFill
public void setPatternFill(PdfPatternPainter p, BaseColor color, float tint)
Sets the fill color to an uncolored pattern.- Parameters:
p- the patterncolor- the color of the patterntint- the tint if the color is a spot color, ignored otherwise
-
setPatternStroke
public void setPatternStroke(PdfPatternPainter p, BaseColor color)
Sets the stroke color to an uncolored pattern.- Parameters:
p- the patterncolor- the color of the pattern
-
setPatternStroke
public void setPatternStroke(PdfPatternPainter p, BaseColor color, float tint)
Sets the stroke color to an uncolored pattern.- Parameters:
p- the patterncolor- the color of the patterntint- the tint if the color is a spot color, ignored otherwise
-
setPatternStroke
public void setPatternStroke(PdfPatternPainter p)
Sets the stroke color to a pattern. The pattern can be colored or uncolored.- Parameters:
p- the pattern
-
paintShading
public void paintShading(PdfShading shading)
Paints using a shading object.- Parameters:
shading- the shading object
-
paintShading
public void paintShading(PdfShadingPattern shading)
Paints using a shading pattern.- Parameters:
shading- the shading pattern
-
setShadingFill
public void setShadingFill(PdfShadingPattern shading)
Sets the shading fill pattern.- Parameters:
shading- the shading pattern
-
setShadingStroke
public void setShadingStroke(PdfShadingPattern shading)
Sets the shading stroke pattern- Parameters:
shading- the shading pattern
-
checkWriter
protected void checkWriter()
Check if we have a valid PdfWriter.
-
showText
public void showText(PdfTextArray text)
Show an array of text.- Parameters:
text- array of text
-
getPdfWriter
public PdfWriter getPdfWriter()
Gets thePdfWriterin use by this object.- Returns:
- the
PdfWriterin use by this object
-
getPdfDocument
public PdfDocument getPdfDocument()
Gets thePdfDocumentin use by this object.- Returns:
- the
PdfDocumentin use by this object
-
localGoto
public void localGoto(java.lang.String name, float llx, float lly, float urx, float ury)Implements a link to other part of the document. The jump will be made to a local destination with the same name, that must exist.- Parameters:
name- the name for this linkllx- the lower left x corner of the activation areally- the lower left y corner of the activation areaurx- the upper right x corner of the activation areaury- the upper right y corner of the activation area
-
localDestination
public boolean localDestination(java.lang.String name, PdfDestination destination)The local destination to where a local goto with the same name will jump.- Parameters:
name- the name of this local destinationdestination- thePdfDestinationwith the jump coordinates- Returns:
trueif the local destination was added,falseif a local destination with the same name already exists
-
getDuplicate
public PdfContentByte getDuplicate()
Gets a duplicate of thisPdfContentByte. All the members are copied by reference but the buffer stays different.- Returns:
- a copy of this
PdfContentByte
-
getDuplicate
public PdfContentByte getDuplicate(boolean inheritGraphicState)
-
inheritGraphicState
public void inheritGraphicState(PdfContentByte parentCanvas)
-
remoteGoto
public void remoteGoto(java.lang.String filename, java.lang.String name, float llx, float lly, float urx, float ury)Implements a link to another document.- Parameters:
filename- the filename for the remote documentname- the name to jump tollx- the lower left x corner of the activation areally- the lower left y corner of the activation areaurx- the upper right x corner of the activation areaury- the upper right y corner of the activation area
-
remoteGoto
public void remoteGoto(java.lang.String filename, int page, float llx, float lly, float urx, float ury)Implements a link to another document.- Parameters:
filename- the filename for the remote documentpage- the page to jump tollx- the lower left x corner of the activation areally- the lower left y corner of the activation areaurx- the upper right x corner of the activation areaury- the upper right y corner of the activation area
-
roundRectangle
public void roundRectangle(float x, float y, float w, float h, float r)Adds a round rectangle to the current path.- Parameters:
x- x-coordinate of the starting pointy- y-coordinate of the starting pointw- widthh- heightr- radius of the arc corner
-
roundRectangle
public void roundRectangle(double x, double y, double w, double h, double r)Adds a round rectangle to the current path.- Parameters:
x- x-coordinate of the starting pointy- y-coordinate of the starting pointw- widthh- heightr- radius of the arc corner
-
setAction
public void setAction(PdfAction action, float llx, float lly, float urx, float ury)
Implements an action in an area.- Parameters:
action- thePdfActionllx- the lower left x corner of the activation areally- the lower left y corner of the activation areaurx- the upper right x corner of the activation areaury- the upper right y corner of the activation area
-
setLiteral
public void setLiteral(java.lang.String s)
Outputs aStringdirectly to the content.- Parameters:
s- theString
-
setLiteral
public void setLiteral(char c)
Outputs achardirectly to the content.- Parameters:
c- thechar
-
setLiteral
public void setLiteral(float n)
Outputs afloatdirectly to the content.- Parameters:
n- thefloat
-
checkNoPattern
void checkNoPattern(PdfTemplate t)
Throws an error if it is a pattern.- Parameters:
t- the object to check
-
drawRadioField
public void drawRadioField(float llx, float lly, float urx, float ury, boolean on)Draws a TextField.- Parameters:
llx-lly-urx-ury-on-
-
drawRadioField
public void drawRadioField(double llx, double lly, double urx, double ury, boolean on)Draws a TextField.- Parameters:
llx-lly-urx-ury-on-
-
drawTextField
public void drawTextField(float llx, float lly, float urx, float ury)Draws a TextField.- Parameters:
llx-lly-urx-ury-
-
drawTextField
public void drawTextField(double llx, double lly, double urx, double ury)Draws a TextField.- Parameters:
llx-lly-urx-ury-
-
drawButton
public void drawButton(float llx, float lly, float urx, float ury, java.lang.String text, BaseFont bf, float size)Draws a button.- Parameters:
llx-lly-urx-ury-text-bf-size-
-
drawButton
public void drawButton(double llx, double lly, double urx, double ury, java.lang.String text, BaseFont bf, float size)Draws a button.- Parameters:
llx-lly-urx-ury-text-bf-size-
-
getPageResources
PageResources getPageResources()
-
setGState
public void setGState(PdfGState gstate)
Sets the graphic state- Parameters:
gstate- the graphic state
-
beginLayer
public void beginLayer(PdfOCG layer)
Begins a graphic block whose visibility is controlled by thelayer. Blocks can be nested. Each block must be terminated by anendLayer().Note that nested layers with
PdfLayer.addChild(PdfLayer)only require a single call to this method and a single call toendLayer(); all the nesting control is built in.- Parameters:
layer- the layer
-
beginLayer2
private void beginLayer2(PdfOCG layer)
-
endLayer
public void endLayer()
Ends a layer controlled graphic block. It will end the most recent open block.
-
transform
public void transform(AffineTransform af)
Concatenates a transformation to the current transformation matrix.- Parameters:
af- the transformation
-
addAnnotation
void addAnnotation(PdfAnnotation annot)
-
addAnnotation
public void addAnnotation(PdfAnnotation annot, boolean applyCTM)
-
setDefaultColorspace
public void setDefaultColorspace(PdfName name, PdfObject obj)
Sets the default colorspace.- Parameters:
name- the name of the colorspace. It can bePdfName.DEFAULTGRAY,PdfName.DEFAULTRGBorPdfName.DEFAULTCMYKobj- the colorspace. AnullorPdfNullremoves any colorspace with the same name
-
beginMarkedContentSequence
public void beginMarkedContentSequence(PdfStructureElement struc)
Begins a marked content sequence. This sequence will be tagged with the structurestruc. The same structure can be used several times to connect text that belongs to the same logical segment but is in a different location, like the same paragraph crossing to another page, for example.- Parameters:
struc- the tagging structure
-
beginMarkedContentSequence
private void beginMarkedContentSequence(PdfStructureElement struc, java.lang.String expansion)
Begins a marked content sequence. This sequence will be tagged with the structurestruc. The same structure can be used several times to connect text that belongs to the same logical segment but is in a different location, like the same paragraph crossing to another page, for example.expansionis token's expansion.- Parameters:
struc- the tagging structureexpansion- the expansion
-
getCurrentPage
protected PdfIndirectReference getCurrentPage()
-
endMarkedContentSequence
public void endMarkedContentSequence()
Ends a marked content sequence
-
beginMarkedContentSequence
public void beginMarkedContentSequence(PdfName tag, PdfDictionary property, boolean inline)
Begins a marked content sequence. If property isnullthe mark will be of the typeBMCotherwise it will beBDC.- Parameters:
tag- the tagproperty- the propertyinline-trueto include the property in the content orfalseto include the property in the resource dictionary with the possibility of reusing
-
beginMarkedContentSequence
public void beginMarkedContentSequence(PdfName tag)
This is just a shorthand tobeginMarkedContentSequence(tag, null, false).- Parameters:
tag- the tag
-
sanityCheck
public void sanityCheck()
Checks for any dangling state: Mismatched save/restore state, begin/end text, begin/end layer, or begin/end marked content sequence. If found, this function will throw. This function is called automatically during a reset() (from Document.newPage() for example), and before writing itself out in toPdf(). One possible cause: not calling myPdfGraphics2D.dispose() will leave dangling saveState() calls.- Throws:
IllegalPdfSyntaxException- (a runtime exception)- Since:
- 2.1.6
-
openMCBlock
public void openMCBlock(IAccessibleElement element)
-
getParentStructureElement
private PdfDictionary getParentStructureElement()
-
openMCBlockInt
private PdfStructureElement openMCBlockInt(IAccessibleElement element)
-
closeMCBlock
public void closeMCBlock(IAccessibleElement element)
-
closeMCBlockInt
private void closeMCBlockInt(IAccessibleElement element)
-
ensureDocumentTagIsOpen
private void ensureDocumentTagIsOpen()
-
saveMCBlocks
protected java.util.ArrayList<IAccessibleElement> saveMCBlocks()
-
restoreMCBlocks
protected void restoreMCBlocks(java.util.ArrayList<IAccessibleElement> mcElements)
-
getMcDepth
protected int getMcDepth()
-
setMcDepth
protected void setMcDepth(int value)
-
getMcElements
protected java.util.ArrayList<IAccessibleElement> getMcElements()
-
setMcElements
protected void setMcElements(java.util.ArrayList<IAccessibleElement> value)
-
updateTx
protected void updateTx(java.lang.String text, float Tj)
-
saveColor
private void saveColor(BaseColor color, boolean fill)
-
getInText
protected boolean getInText()
-
checkState
protected void checkState()
-
createGraphicsShapes
public java.awt.Graphics2D createGraphicsShapes(float width, float height)Deprecated.use the constructor in PdfGraphics2DGets aGraphics2Dto write on. The graphics are translated to PDF commands as shapes. No PDF fonts will appear.- Parameters:
width- the width of the panelheight- the height of the panel- Returns:
- a
Graphics2D
-
createPrinterGraphicsShapes
public java.awt.Graphics2D createPrinterGraphicsShapes(float width, float height, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfPrinterGraphics2DGets aGraphics2Dto print on. The graphics are translated to PDF commands as shapes. No PDF fonts will appear.- Parameters:
width- the width of the panelheight- the height of the panelprinterJob- a printer job- Returns:
- a
Graphics2D
-
createGraphics
public java.awt.Graphics2D createGraphics(float width, float height)Deprecated.use the constructor in PdfGraphics2DGets aGraphics2Dto write on. The graphics are translated to PDF commands.- Parameters:
width- the width of the panelheight- the height of the panel- Returns:
- a
Graphics2D
-
createPrinterGraphics
public java.awt.Graphics2D createPrinterGraphics(float width, float height, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfPrinterGraphics2DGets aGraphics2Dto print on. The graphics are translated to PDF commands.- Parameters:
width- the width of the panelheight- the height of the panelprinterJob-- Returns:
- a
Graphics2D
-
createGraphics
public java.awt.Graphics2D createGraphics(float width, float height, boolean convertImagesToJPEG, float quality)Deprecated.use the constructor in PdfGraphics2DGets aGraphics2Dto write on. The graphics are translated to PDF commands.- Parameters:
width- the width of the panelheight- the height of the panelconvertImagesToJPEG-quality-- Returns:
- a
Graphics2D
-
createPrinterGraphics
public java.awt.Graphics2D createPrinterGraphics(float width, float height, boolean convertImagesToJPEG, float quality, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfGraphics2DGets aGraphics2Dto print on. The graphics are translated to PDF commands.- Parameters:
width- the width of the panelheight- the height of the panelconvertImagesToJPEG-quality-printerJob-- Returns:
- a
Graphics2D
-
createGraphicsShapes
public java.awt.Graphics2D createGraphicsShapes(float width, float height, boolean convertImagesToJPEG, float quality)Deprecated.use the constructor in PdfPrinterGraphics2DGets aGraphics2Dto print on. The graphics are translated to PDF commands.- Parameters:
width-height-convertImagesToJPEG-quality-- Returns:
- A Graphics2D object
-
createPrinterGraphicsShapes
public java.awt.Graphics2D createPrinterGraphicsShapes(float width, float height, boolean convertImagesToJPEG, float quality, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfPrinterGraphics2DGets aGraphics2Dto print on. The graphics are translated to PDF commands.- Parameters:
width-height-convertImagesToJPEG-quality-printerJob-- Returns:
- a Graphics2D object
-
createGraphics
public java.awt.Graphics2D createGraphics(float width, float height, FontMapper fontMapper)Deprecated.use the constructor in PdfPrinterGraphics2DGets aGraphics2Dto write on. The graphics are translated to PDF commands.- Parameters:
width- the width of the panelheight- the height of the panelfontMapper- the mapping from awt fonts toBaseFont- Returns:
- a
Graphics2D
-
createPrinterGraphics
public java.awt.Graphics2D createPrinterGraphics(float width, float height, FontMapper fontMapper, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfPrinterGraphics2DGets aGraphics2Dto print on. The graphics are translated to PDF commands.- Parameters:
width- the width of the panelheight- the height of the panelfontMapper- the mapping from awt fonts toBaseFontprinterJob- a printer job- Returns:
- a
Graphics2D
-
createGraphics
public java.awt.Graphics2D createGraphics(float width, float height, FontMapper fontMapper, boolean convertImagesToJPEG, float quality)Deprecated.use the constructor in PdfPrinterGraphics2DGets aGraphics2Dto write on. The graphics are translated to PDF commands.- Parameters:
width- the width of the panelheight- the height of the panelfontMapper- the mapping from awt fonts toBaseFontconvertImagesToJPEG- converts awt images to jpeg before inserting in pdfquality- the quality of the jpeg- Returns:
- a
Graphics2D
-
createPrinterGraphics
public java.awt.Graphics2D createPrinterGraphics(float width, float height, FontMapper fontMapper, boolean convertImagesToJPEG, float quality, java.awt.print.PrinterJob printerJob)Deprecated.use the constructor in PdfPrinterGraphics2DGets aGraphics2Dto print on. The graphics are translated to PDF commands.- Parameters:
width- the width of the panelheight- the height of the panelfontMapper- the mapping from awt fonts toBaseFontconvertImagesToJPEG- converts awt images to jpeg before inserting in pdfquality- the quality of the jpegprinterJob- a printer job- Returns:
- a
Graphics2D
-
addImage
public void addImage(Image image, java.awt.geom.AffineTransform transform) throws DocumentException
Deprecated.use com.itextpdf.text.geom.AffineTransform as parameteradds an image with the given matrix.- Parameters:
image- image to addtransform- transform to apply to the template prior to adding it.- Throws:
DocumentException- Since:
- 5.0.1
-
addTemplate
public void addTemplate(PdfTemplate template, java.awt.geom.AffineTransform transform)
Deprecated.use com.itextpdf.text.geom.AffineTransform as parameteradds a template with the given matrix.- Parameters:
template- template to addtransform- transform to apply to the template prior to adding it.
-
concatCTM
public void concatCTM(java.awt.geom.AffineTransform transform)
Deprecated.use com.itextpdf.text.geom.AffineTransform as parameterConcatenate a matrix to the current transformation matrix.- Parameters:
transform- added to the Current Transformation Matrix
-
setTextMatrix
public void setTextMatrix(java.awt.geom.AffineTransform transform)
Deprecated.use com.itextpdf.text.geom.AffineTransform as parameterChanges the text matrix.- Parameters:
transform- overwrite the current text matrix with this one
-
transform
public void transform(java.awt.geom.AffineTransform af)
Deprecated.use com.itextpdf.text.geom.AffineTransform as parameterConcatenates a transformation to the current transformation matrix.- Parameters:
af- the transformation
-
-