Interface PDFDrawable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
beginTag(java.lang.String tag, java.util.Map<java.lang.String,java.lang.Object> atts)
Open a structural tag on this page.void
clipCircle(float x, float y, float radius)
Set the clipping area to a circle centered onx
,y
with a radius ofradius
.void
clipEllipse(float x1, float y1, float x2, float y2)
Set the clipping area to the ellipse inside the specified rectangle.void
clipPolygon(float[] x, float[] y)
Set the clipping area to a polygon.void
clipRectangle(float x1, float y1, float x2, float y2)
Set the clipping area to the rectangle which runs through the two cornersx1,y1
andx2,y2
.void
clipRoundedRectangle(float x1, float y1, float x2, float y2, float r)
Set the clipping area to a rectangle with rounded corners which runs through the two cornersx1,y1
andx2,y2
.void
clipShape(java.awt.Shape shape)
Clip aShape
void
drawCanvas(PDFCanvas canvas, float x1, float y1, float x2, float y2)
Draw aPDFCanvas
at the specified position on the page.void
drawCircle(float x, float y, float radius)
Draw a circle centered onx
,y
with a radius ofradius
.void
drawCircleArc(float x, float y, float radius, float start, float end)
Draw an arc of the circle centered onx,y
with the specified radius.void
drawEllipse(float x1, float y1, float x2, float y2)
Draw an ellipse inside the specified rectangle.void
drawEllipseArc(float x1, float y1, float x2, float y2, float start, float end)
Draw an ellipse arc inside the specified rectangle.void
drawGlyphVector(PDFGlyphVector gv, float x, float y)
Draw aPDFGlyphVector
onto the drawable.void
drawImage(PDFImage image, float x1, float y1, float x2, float y2)
Draw aPDFImage
at the specified position on the pagevoid
drawLayoutBox(LayoutBox box, float x, float y)
Draw aLayoutBox
at the specified position on the pagevoid
drawLine(float x1, float y1, float x2, float y2)
Draw a line fromx1,y1
tox2,y2
.void
drawPolygon(float[] x, float[] y)
Draw a polygon.void
drawRectangle(float x1, float y1, float x2, float y2)
Draw a rectangle through the two cornersx1,y1
andx2,y2
.void
drawRoundedRectangle(float x1, float y1, float x2, float y2, float r)
Draw a rectangle with rounded corners through the two cornersx1,y1
andx2,y2
.void
drawShape(java.awt.Shape shape)
Draw aShape
.void
endTag()
Close a structural tag on this page.void
flush()
This method flushes any operations that have been written to the drawable object.java.awt.color.ColorSpace
getDefaultColorSpace(int components)
Return the ColorSpace used by this Drawable to anchor device-dependent colors to a profile.boolean
pathArc(float width, float height, float start, float end)
Continue the open path in an arc to the specified position.boolean
pathBezier(float cx1, float cy1, float cx2, float cy2, float x, float y)
Continue the open path in a bezier curve to the specified position.void
pathCancel()
Cancel the current pathvoid
pathClip()
Close the path and set the "clipping area" of the page to be the intersection of the current clipping area and the shape defined by this path.void
pathClipAndPaint()
Close and paint the path as described inpathPaint()
, then set the clipping area to the same are as described inpathClip()
void
pathClose()
Close the path by drawing a straight line back to its beginning.boolean
pathLine(float x, float y)
Continue the open path in a straight line to the specified position.void
pathMove(float x, float y)
Start a new path at the specified position.void
pathPaint()
Close and paint the path.boolean
pathShape(java.awt.Shape shape)
Add the path specified by aShape
to the Canvasvoid
rawWrite(java.lang.String data)
Write raw PDF commands to the drawable.void
restore()
Restore the state that was saved with the last call tosave()
void
rotate(float x, float y, double ang)
Rotate the drawable around the specified point by the specified number of degrees.void
save()
Save the state of this page.void
setDefaultColorSpace(int components, java.awt.color.ColorSpace cs)
Set the ColorSpace to use to anchor device-dependent colors on this Drawable, as described bygetDefaultColorSpace(int)
.void
setMetaData(java.lang.String xmldata)
Set the XML metadata associated with this object.void
setStyle(PDFStyle style)
Set the style for this Canvasvoid
transform(double m00, double m10, double m01, double m11, double m02, double m12)
Apply an Affine Transformation to the drawable.void
transform(java.awt.geom.AffineTransform transform)
Apply an Affine Transformation to the drawable.
-
-
-
Method Detail
-
flush
void flush()
This method flushes any operations that have been written to the drawable object.
-
rawWrite
void rawWrite(java.lang.String data)
Write raw PDF commands to the drawable. This is for advanced users only, but does allow those intimately familiar with the PDF specification to perform some of the more esoteric actions that aren't directly supported by the PDF library. Using this method it is easy to create invalid PDF documents, so use with caution.- Parameters:
data
- the PDF operations to write to the stream, for instance "/Perceptual ri" to set the RenderingIntent. Line breaks will be added before and after the specified string.
-
setStyle
void setStyle(PDFStyle style)
Set the style for this Canvas
-
drawLine
void drawLine(float x1, float y1, float x2, float y2)
Draw a line fromx1,y1
tox2,y2
.- Parameters:
x1
- the X co-ordinate of the start of the liney1
- the Y co-ordinate of the start of the linex2
- the X co-ordinate of the end of the liney2
- the Y co-ordinate of the end of the line
-
drawRectangle
void drawRectangle(float x1, float y1, float x2, float y2)
Draw a rectangle through the two corners
x1,y1
andx2,y2
. Whether the rectangle is drawn as an outline or filled depends on theLineColor
andFillColor
of the current style (see thepathPaint()
method for more information).- Parameters:
x1
- the X co-ordinate of the first corner of the rectangley1
- the Y co-ordinate of the first corner of the rectanglex2
- the X co-ordinate of the second corner of the rectangley2
- the Y co-ordinate of the second corner of the rectangle
-
drawRoundedRectangle
void drawRoundedRectangle(float x1, float y1, float x2, float y2, float r)
Draw a rectangle with rounded corners through the two corners
x1,y1
andx2,y2
. Whether the rectangle is drawn as an outline or filled depends on theLineColor
andFillColor
of the current style (see thepathPaint()
method for more information).- Parameters:
x1
- the X co-ordinate of the first corner of the rectangley1
- the Y co-ordinate of the first corner of the rectanglex2
- the X co-ordinate of the second corner of the rectangley2
- the Y co-ordinate of the second corner of the rectangler
- The radius of the circle that is used to round the corners. A value of zero give identical results todrawRectangle(float, float, float, float)
-
drawPolygon
void drawPolygon(float[] x, float[] y)
Draw a polygon. The X and Y co-ordinates of the vertices are in the supplied arrays. Whether the polygon is drawn as an outline or filled depends on the
LineColor
andFillColor
of the current style (see thepathPaint()
method for more information).If the fill color is specified the polygon will be closed automatically if it isn't already.
- Parameters:
x
- the X co-ordinates of the verticesy
- the Y co-ordinates of the vertices
-
drawCircle
void drawCircle(float x, float y, float radius)
Draw a circle centered onx
,y
with a radius ofradius
. A more convenient way to draw circles thandrawEllipse
- Parameters:
x
- the X co-ordinate of the center of the circley
- the Y co-ordinate of the center of the circleradius
- the radius of the circle
-
drawEllipse
void drawEllipse(float x1, float y1, float x2, float y2)
Draw an ellipse inside the specified rectangle. The top and sides of the ellipse will touch the edges of the rectangle drawn between
x1,y1
andx2,y2
.Whether the ellipse is drawn as an outline or filled depends on the
LineColor
andFillColor
of the current style (see thepathPaint()
method for more information).- Parameters:
x1
- the X co-ordinate of the first corner of the rectangley1
- the Y co-ordinate of the first corner of the rectanglex2
- the X co-ordinate of the second corner of the rectangley2
- the Y co-ordinate of the second corner of the rectangle
-
drawEllipseArc
void drawEllipseArc(float x1, float y1, float x2, float y2, float start, float end)
Draw an ellipse arc inside the specified rectangle. The same as
drawEllipse
, but allows you to specify a start and end angle. If a FillColor is specified, the arc will be closed with a straight line.- Parameters:
x1
- the X co-ordinate of the first corner of the rectangley1
- the Y co-ordinate of the first corner of the rectanglex2
- the X co-ordinate of the second corner of the rectangley2
- the Y co-ordinate of the second corner of the rectanglestart
- the start angle of the arc, in degrees clockwise from 12 o'clockend
- the end angle of the arc, in degrees clockwise from 12 o'clock
-
drawCircleArc
void drawCircleArc(float x, float y, float radius, float start, float end)
Draw an arc of the circle centered onx,y
with the specified radius. A more convenient way to draw circular arcs thandrawEllipseArc
If a FillColor is specified, the arc will be closed with a straight line.- Parameters:
x
- the X co-ordinate of the center of the circley
- the Y co-ordinate of the center of the circleradius
- the radius of the circlestart
- the start angle of the arc, in degrees clockwise from 12 o'clockend
- the end angle of the arc, in degrees clockwise from 12 o'clock
-
drawShape
void drawShape(java.awt.Shape shape)
Draw aShape
. If the fill color is specified the Shape will be closed automatically if it isn't already.
-
drawGlyphVector
void drawGlyphVector(PDFGlyphVector gv, float x, float y)
Draw aPDFGlyphVector
onto the drawable. See that class for an example of how to use this method.- Parameters:
gv
- the PDFGlyphVector to drawx
- the X co-ordinate to position the left edge of the PDFGlyphVectory
- the Y co-ordinate to position the baseline of the PDFGlyphVector- See Also:
PDFGlyphVector
,PDFStyle.createGlyphVector(java.lang.String, java.util.Locale)
-
clipRectangle
void clipRectangle(float x1, float y1, float x2, float y2)
Set the clipping area to the rectangle which runs through the two corners
x1,y1
andx2,y2
.- Parameters:
x1
- the X co-ordinate of the first corner of the rectangley1
- the Y co-ordinate of the first corner of the rectanglex2
- the X co-ordinate of the second corner of the rectangley2
- the Y co-ordinate of the second corner of the rectangle
-
clipRoundedRectangle
void clipRoundedRectangle(float x1, float y1, float x2, float y2, float r)
Set the clipping area to a rectangle with rounded corners which runs through the two corners
x1,y1
andx2,y2
.- Parameters:
x1
- the X co-ordinate of the first corner of the rectangley1
- the Y co-ordinate of the first corner of the rectanglex2
- the X co-ordinate of the second corner of the rectangley2
- the Y co-ordinate of the second corner of the rectangler
- The radius of the circle that is used to round the corners. A value of zero give identical results todrawRectangle(float, float, float, float)
-
clipPolygon
void clipPolygon(float[] x, float[] y)
Set the clipping area to a polygon. The X and Y co-ordinates of the vertices are in the supplied arrays.
- Parameters:
x
- the X co-ordinates of the verticesy
- the Y co-ordinates of the vertices
-
clipEllipse
void clipEllipse(float x1, float y1, float x2, float y2)
Set the clipping area to the ellipse inside the specified rectangle. The top and sides of the ellipse will touch the edges of the rectangle drawn between
x1,y1
andx2,y2
.- Parameters:
x1
- the X co-ordinate of the first corner of the rectangley1
- the Y co-ordinate of the first corner of the rectanglex2
- the X co-ordinate of the second corner of the rectangley2
- the Y co-ordinate of the second corner of the rectangle
-
clipCircle
void clipCircle(float x, float y, float radius)
Set the clipping area to a circle centered onx
,y
with a radius ofradius
.- Parameters:
x
- the X co-ordinate of the center of the circley
- the Y co-ordinate of the center of the circleradius
- the radius of the circle
-
clipShape
void clipShape(java.awt.Shape shape)
Clip aShape
-
pathMove
void pathMove(float x, float y)
Start a new path at the specified position. If a path has already been started, move the cursor without drawing a line.- Parameters:
x
- the X co-ordinate to move toy
- the Y co-ordinate to move to
-
pathLine
boolean pathLine(float x, float y)
Continue the open path in a straight line to the specified position.- Parameters:
x
- the X co-ordinate to move toy
- the Y co-ordinate to move to- Returns:
- true if any sections were drawn in the path
- Throws:
java.lang.IllegalStateException
- if a path hasn't been started withpathMove(float, float)
-
pathBezier
boolean pathBezier(float cx1, float cy1, float cx2, float cy2, float x, float y)
Continue the open path in a bezier curve to the specified position.- Parameters:
cx1
- the X co-ordinate of the first control point for the curvecy1
- the Y co-ordinate of the first control point for the curvecx2
- the X co-ordinate of the second control point for the curvecy2
- the Y co-ordinate of the second control point for the curvex
- the X co-ordinate to move toy
- the Y co-ordinate to move to- Returns:
- true if any sections were drawn in the path
- Throws:
java.lang.IllegalStateException
- if a path hasn't been started withpathMove(float, float)
-
pathArc
boolean pathArc(float width, float height, float start, float end)
Continue the open path in an arc to the specified position.- Parameters:
width
- the width of the ellipse to take the arc fromheight
- the height of the ellipse to take the arc fromstart
- the start angle of the arc, in degrees clockwise from 12 o'clockend
- the end angle of the arc, in degrees clockwise from 12 o'clock- Returns:
- true if any sections were drawn in the path
- Throws:
java.lang.IllegalStateException
- if a path hasn't been started withpathMove(float, float)
-
pathShape
boolean pathShape(java.awt.Shape shape)
Add the path specified by aShape
to the Canvas- Parameters:
shape
- the shape- Returns:
- true if any sections were drawn on the path
-
pathClose
void pathClose()
Close the path by drawing a straight line back to its beginning. This does not complete the path, you still need to complete it withpathPaint()
orpathCancel()
- Throws:
java.lang.IllegalStateException
- if a path hasn't been started withpathMove(float, float)
-
pathCancel
void pathCancel()
Cancel the current path- Throws:
java.lang.IllegalStateException
- if a path hasn't been started withpathMove(float, float)
-
pathPaint
void pathPaint()
Close and paint the path. What this actually does depends on the currently appliedPDFStyle
- If the style has a LineColor specified but no FillColor, "stroke" the path by drawing it as an outline in the current line color
- If the style has a FillColor specified but no LineColor, call
pathClose()
and "fill" the path with the current fill color - If the style has both a FillColor and a LineColor, call
pathClose()
, "fill" the path with the current fill color then "stroke" the path with the current line color.
- Throws:
java.lang.IllegalStateException
- if a path hasn't been started withpathMove(float, float)
, or if neither a fill nor line color has been specified.
-
pathClipAndPaint
void pathClipAndPaint()
Close and paint the path as described inpathPaint()
, then set the clipping area to the same are as described inpathClip()
-
pathClip
void pathClip()
Close the path and set the "clipping area" of the page to be the intersection of the current clipping area and the shape defined by this path. Any future graphics or text operations on the page are only applied within this area.
There is no way to enlarge the current clipping area, or to set a new clipping area without reference to the current one. However, as the current clipping area is part of the graphics state, it can and should be nested inside calls to
save()
andrestore()
to limit its effect.- Throws:
java.lang.IllegalStateException
- if a path hasn't been started withpathMove(float, float)
-
save
void save()
Save the state of this page. This takes a snapshot of the currently applied style, position, clipping area and any rotation/translation/scaling that has been applied, which can be later restored with a call to
restore()
Calls to
save
can be nested, but note that for most PDF viewers it is an error to save the page state but not restore it.- Throws:
java.lang.IllegalStateException
- if a save is performed with an open path or if saves are nested more than 28 deep.
-
restore
void restore()
Restore the state that was saved with the last call tosave()
- Throws:
java.lang.IllegalStateException
- if there is no previously saved state
-
rotate
void rotate(float x, float y, double ang)
Rotate the drawable around the specified point by the specified number of degrees. All further draw/path/clip actions on this drawable will be adjusted accordingly. The best way to get back to normal after a rotate is to wrap the rotate inside asave()
/restore()
block, eg.canvas.save(); canvas.rotate(100,100,45); canvas.drawLayoutBox(rotatedtext, 100, 100); canvas.restore();
-
transform
void transform(java.awt.geom.AffineTransform transform)
Apply an Affine Transformation to the drawable.
-
transform
void transform(double m00, double m10, double m01, double m11, double m02, double m12)
Apply an Affine Transformation to the drawable. The six arguments are the same 6 arguments passed in to theAffineTransform
constructor, in the same same order.
-
drawImage
void drawImage(PDFImage image, float x1, float y1, float x2, float y2)
Draw aPDFImage
at the specified position on the page- Parameters:
image
- the image to drawx1
- the X co-ordinate of the left hand side of the imagey1
- the Y co-ordinate of the bottom side of the imagex2
- the X co-ordinate of the right hand side of the imagey2
- the Y co-ordinate of the top side of the image
-
drawCanvas
void drawCanvas(PDFCanvas canvas, float x1, float y1, float x2, float y2)
Draw aPDFCanvas
at the specified position on the page.- Parameters:
canvas
- the canvas to drawx1
- the X co-ordinate of the left hand side of the imagey1
- the Y co-ordinate of the bottom side of the imagex2
- the X co-ordinate of the right hand side of the imagey2
- the Y co-ordinate of the top side of the image- Throws:
java.lang.IllegalArgumentException
- if the canvas being drawn is this canvas - recursion is not allowed.
-
beginTag
void beginTag(java.lang.String tag, java.util.Map<java.lang.String,java.lang.Object> atts)
Open a structural tag on this page. This call must be matched by a later call to
endTag()
.Structural tags add a tree structure on top of the otherwise flat structure of a PDF. They are primarily used to meet accesibility requirements, and so may be required for certain subsets of PDF such as PDF/A-1a. Using the
beginTag
andendtag
methods is fairly simple and should be familiar to anytone that has used SAX or HTML:PDFCanvas canvas = new PDFCanvas(width, height); canvas.beginTag("Sect", null); LayoutBox box = new LayoutBox(600); box.addText("He said '", style, null); Map<String,Object> atts = new HashMap<String,Object>(); atts.put("id", "quote1"); box.beginTag("Quote", atts); box.addText("This is a contrived example", boldstyle, null); box.endTag(); canvas.drawLayoutBox(box, x, y); canvas.endTag();
Calls to beginTag must be matched to calls to endTag for each object - the methods exist in
PDFPage
,PDFCanvas
andLayoutBox
.While in general any values for tag are allowed, the following are suggested by the PDF specification
Part Part - A large-scale division of a document. This type of element is appropriate for grouping articles or sections. Art Article - A relatively self-contained body of text constituting a single narrative or exposition. Articles should be disjoint; that is, they should not contain other articles as constituent elements. Sect Section - A container for grouping related content elements. For example, a section might contain a heading, several introductory paragraphs, and two or more other sections nested within it as subsections. Div Division A generic block-level element or group of elements. BlockQuote Block quotation - A portion of text consisting of one or more paragraphs attributed to someone other than the author of the surrounding text. Caption Caption - A brief portion of text describing a table or figure. TOC Table Of Contents - A list made up of table of contents item entries (structure type TOCI) and/or other nested table of contents entries (TOC).
A TOC entry that includes only TOCI entries represents a flat hierarchy. A TOC entry that includes other nested TOC entries (and possibly TOCI entries) represents a more complex hierarchy. Ideally, the hierarchy of a top level TOC entry reflects the structure of the main body of the document.
Lists of figures and tables, as well as bibliographies, can be treated as tables of contents for purposes of the standard structure types.TOCI Table of Contents Item - This entry’s children may be any of the following structure types: Lbl, Reference, NonStruct, P or TOC Index A sequence of entries containing identifying text accompanied by Reference elements that point out occurrences of the specified text in the main body of a document. NonStruct Nonstructural element - A grouping element having no inherent structural significance; it serves solely for grouping purposes. This type of element differs from a Div in that it shall not be interpreted or exported to other document formats; however, its descendants shall be processed normally. Private Private Element - A grouping element containing private content belonging to the application producing it. The structural significance of this type of element is unspecified and shall be determined entirely by the conforming writer. Neither the Private element nor any of its descendants shall be interpreted or exported to other document formats. H Heading - A label for a subdivision of a document’s content. It should be the first child of the Div that it heads. H1, H2, H3, H4, H5, H6 Heading with specific levels - For use in conforming writers that cannot hierarchically nest their sections and thus cannot determine the level of a heading from its level of nesting. P Paragraph - A low-level division of text. L List - A sequence of items of like meaning and importance. Its immediate children should be an optional Caption followed by one or more LI LI List Item - An individual member of a list. Its children may be one or more combinations of Lbl or LBody Lbl Label - A name or number that distinguishes a given item from others in the same list or other group of like items. In a dictionary list, for example, it contains the term being defined; in a bulleted or numbered list, it contains the bullet character or the number of the list item and associated punctuation. LBody List Body - The descriptive content of a list item. In a dictionary list, for example, it contains the definition of the term. It may either contain the content directly or have other block-level items, perhaps including nested lists, as children. Table Table - A two-dimensional layout of rectangular data cells, possibly having a complex substructure. It contains either one or more TR as children; or an optional THead followed by one or more TBody and an optional TFoot. In addition, a table may have a Caption as its first or last child. TR Table Row - A row of headings or data in a table. It may contain TH and TD TH Table Header Cell - A table cell containing header text describing one or more rows or columns of the table. TD Table Data Cell - A table cell containing data that is part of the table’s content. THead Table header row group - A group of rows that constitute the header of a table. If the table is split across multiple pages, these rows may be redrawn at the top of each table fragment (although there is only one THead element). TBody Table body row group - A group of rows that constitute the main body portion of a table. If the table is split across multiple pages, the body area may be broken apart on a row boundary. A table may have multiple TBody elements to allow for the drawing of a border or background for a set of rows. TFoot Table footer row group - A group of rows that constitute the footer of a table. If the table is split across multiple pages, these rows may be redrawn at the bottom of each table fragment (although there is only one TFoot element.) Span Span - A generic inline portion of text having no particular inherent characteristics. It can be used, for example, to delimit a range of text with a given set of styling attributes, although it's not necessary to identify italic or bold text with a Span (as in HTML), as this can be derived from the text. Quote Quotation - An inline portion of text attributed to someone other than the author of the surrounding text. The quoted text should be contained inline within a single paragraph. This differs from the block-level element BlockQuote, which consists of one or more complete paragraphs (or other elements presented as if they were complete paragraphs). Note Note - An item of explanatory text, such as a footnote or an endnote, that is referred to from within the body of the document. It may have a Lbl as a child. The note may be included as a child of the structure element in the body text that refers to it, or it may be included elsewhere (such as in an endnotes section) and accessed by means of a Reference. Reference Reference - A citation to content elsewhere in the document. BibEntry Bibliographic entry - A reference identifying the external source of some cited content. It may contain a Lbl as a child.
Although a bibliography entry is likely to include component parts identifying the cited content’s author, work, publisher, and so forth, no standard structure types are defined at this level of detail.Code Code entry - A fragment of computer program text Link Link - An association between a portion of the inline items’s content and a corresponding AnnotationLink
. Its children should be one or more content items or child inline items and one or more object references identifying the associated annotations.Annot Annotation - An association between a portion of the inline items’s content and a corresponding PDFAnnotation
. Its children should be one or more content items or child inline items and one or more object references identifying the associated annotations.Artifact Artifact - Used to mark a section of text as a rendering artifact only. Artifacts are not considered part of the logical document structure. They take no attributes. Attributes for structural tags are unfortunately somewhat overengineered in the specification. For now we will recognise and handle appropriately the following attributes.
id The ID for this node - should be unique across the PDF (the "ID" attribute) class or C One or more class names for this node, separated by spaces (the "C" attribute) title or T The optional human-readable description for the tag, eg "Chapter 1" (the "T" attribute) lang The optional language code for the tag and its childen, can be a String or a Locale
. An alternative to setting aLocale
on the text, it is recommended not to mix the two approaches - if you're usingbeginTag/endTag
, leave the locale in any calls toLayoutBox.addText()
asnull
(the "Lang" attribute)alt The alternate description for the structure element and its childen in human readable form (the "Alt" attribute). text or ActualText Text that is an exact replacement for the structure element and its children. This can be used when the actual PDF text is being added in a font without a correct Unicode mapping, when text is being added as an image, or when text is known to be broken over several lines (for example) (the "ActualText" attribute) abbr or E When an abbreviation is used, this attribute can be set to the unabbreviated version (the "E" attribute) annotation For Link or Annot tags, the PDFAnnotation
they refer tobfo:key Optional, representing the document-wide unique ID of this node. Duplicate nodes with the same bfo:key will be merged in the tree bfo:pdf Required if bfo:key is set - this must be the PDF this object will be added to bfo:pos Optional. If set to "end", all items in the tree with the same bfo:key as this one will be merged with this element Any attribute not described here will be stored in the document structure. Attributes may optionally be prefixed by an "owner" - the PDF Structure Tree version of an XML Namespace. For PDF/UA compliance this is a requirement for certain tags, and the attribute owners are described in section 14.8.5.2 of ISO/IEC 32000 (version 1). For example, a "TH" tag is supposed to specify a "Scope" attribute, which you could do as follows:
Map<String,Object> atts = new HashMap<String,Object>(); atts.put("Table:Scope", "Both");
- Parameters:
tag
- name of the tagatts
- user defined attributes for this tag, ornull
- See Also:
PDFPage.beginTag(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>)
,LayoutBox.beginTag(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>)
,endTag()
,PDFPage.endTag()
,LayoutBox.endTag()
,PDFParser.getStructureTree()
,PDF.rebuildStructureTree()
-
endTag
void endTag()
Close a structural tag on this page. This call must match an earlier call tobeginTag()
-
drawLayoutBox
void drawLayoutBox(LayoutBox box, float x, float y)
Draw aLayoutBox
at the specified position on the page- Parameters:
box
- the LayoutBox to drawx
- the X co-ordinate of the left hand side of the boxy
- the Y co-ordinate of the top side of the box
-
setMetaData
void setMetaData(java.lang.String xmldata)
Set the XML metadata associated with this object. SeePDF.setMetaData(java.lang.String)
for more information.- Parameters:
xmldata
- the XML data to embed into the document, or null to clear any existing metadata. No validation is performed on this input.
-
getDefaultColorSpace
java.awt.color.ColorSpace getDefaultColorSpace(int components)
Return the ColorSpace used by this Drawable to anchor device-dependent colors to a profile. For example, the ColorSpace returned by
getDefaultColorSpace(3)
is used by all "Device RGB" colors on the page, effectively turning them into calibrated colors.The PDF API automatically sets a calibrated sRGB ColorSpace as the ColorSpace for all DeviceRGB content on the page. Unlike the use of "Output Intents" on the
OutputProfile
class, multiple ColorSpaces can be set, one each for Gray, RGB, and CMYK. This is a cheap way to convert pages containing both DeviceRGB and DeviceCMYK to using calibrated colors.- Parameters:
components
- identifies the Default ColorSpace we're requesting - valid values are 1 for Gray, 3 for RGB or 4 for CMYK.- Returns:
- the Default ColorSpace requested, or null if none is set.
- Since:
- 2.25
-
setDefaultColorSpace
void setDefaultColorSpace(int components, java.awt.color.ColorSpace cs)
Set the ColorSpace to use to anchor device-dependent colors on this Drawable, as described bygetDefaultColorSpace(int)
.- Parameters:
components
- identifies the Default ColorSpace to set - valid values are 1 for Gray, 3 for RGB or 4 for CMYK.cs
- the ColorSpace to set, which must be either null (to delete the existing value) or a ColorSpace of a type that matches the "components" parameter.
-
-