Package com.itextpdf.kernel.pdf.xobject
Class PdfFormXObject
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfStream>
-
- com.itextpdf.kernel.pdf.xobject.PdfXObject
-
- com.itextpdf.kernel.pdf.xobject.PdfFormXObject
-
- Direct Known Subclasses:
SvgImageXObject
public class PdfFormXObject extends PdfXObject
A wrapper for Form XObject. ISO 32000-1, 8.10 FormXObjects.
-
-
Field Summary
Fields Modifier and Type Field Description protected PdfResources
resources
-
Constructor Summary
Constructors Constructor Description PdfFormXObject(Rectangle bBox)
Creates a new instance of Form XObject.PdfFormXObject(WmfImageData image, PdfDocument pdfDocument)
Creates a form XObject fromWmfImageData
.PdfFormXObject(PdfPage page)
Creates form XObject from page content.PdfFormXObject(PdfStream pdfStream)
CreatePdfFormXObject
instance byPdfStream
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Rectangle
calculateBBoxMultipliedByMatrix(PdfFormXObject form)
Calculates the coordinates of the xObject BBox multiplied by the Matrix field.void
flush()
To manually flush aPdfObject
behind this wrapper, you have to ensure that this object is added to the document, i.e.PdfArray
getBBox()
Gets Form XObject's BBox,PdfName.BBox
key.float
getHeight()
Gets height based on XObject's BBox.PdfString
getMarkStyle()
Gets a text string representing the printer’s mark in human-readable form.PdfName
getProcessColorModel()
Gets process color model of trap network appearance,PdfName.PCM
key.PdfResources
getResources()
GetsPdfResources
of the Form XObject.PdfArray
getSeparationColorNames()
Gets separation color names of trap network appearance,PdfName.SeparationColorNames
key.PdfArray
getTrapRegions()
Gets an array of TrapRegion objects defining the page’s trapping zones and the associated trapping parameters, as described in Adobe Technical Note #5620, Portable Job Ticket Format.PdfString
getTrapStyles()
Gets a human-readable text string that described this trap network to the user.float
getWidth()
Gets width based on XObject's BBox.boolean
isRelativeSized()
If the form xobject is relative sized.PdfFormXObject
put(PdfName key, PdfObject value)
Puts the value into Image XObject dictionary and associates it with the specified key.PdfFormXObject
setBBox(PdfArray bBox)
Sets Form XObject's BBox,PdfName.BBox
key.PdfFormXObject
setGroup(PdfTransparencyGroup transparency)
Sets a group attributes dictionary indicating that the contents of the form XObject shall be treated as a group and specifying the attributes of that group.PdfFormXObject
setMarkStyle(PdfString markStyle)
Sets a text string representing the printer’s mark in human-readable form.PdfFormXObject
setProcessColorModel(PdfName model)
Sets process color model for trap network appearance,PdfName.PCM
key.PdfFormXObject
setSeparationColorNames(PdfArray colorNames)
Sets separation color names for the trap network appearance,PdfName.SeparationColorNames
key.PdfFormXObject
setTrapRegions(PdfArray regions)
Sets an array of TrapRegion objects defining the page’s trapping zones and the associated trapping parameters, as described in Adobe Technical Note #5620, Portable Job Ticket Format.PdfFormXObject
setTrapStyles(PdfString trapStyles)
Sets a human-readable text string that described this trap network to the user.-
Methods inherited from class com.itextpdf.kernel.pdf.xobject.PdfXObject
addAssociatedFile, calculateProportionallyFitRectangleWithHeight, calculateProportionallyFitRectangleWithWidth, getAssociatedFiles, isWrappedObjectMustBeIndirect, makeXObject, setLayer
-
Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
-
-
-
Field Detail
-
resources
protected PdfResources resources
-
-
Constructor Detail
-
PdfFormXObject
public PdfFormXObject(Rectangle bBox)
Creates a new instance of Form XObject.- Parameters:
bBox
- the form XObject’s bounding box.
-
PdfFormXObject
public PdfFormXObject(PdfStream pdfStream)
CreatePdfFormXObject
instance byPdfStream
. Note, this constructor doesn't perform any additional checks- Parameters:
pdfStream
-PdfStream
with Form XObject.- See Also:
PdfXObject.makeXObject(PdfStream)
-
PdfFormXObject
public PdfFormXObject(PdfPage page)
Creates form XObject from page content. The page shall be from the document, to which FormXObject will be added.- Parameters:
page
- an instance ofPdfPage
-
PdfFormXObject
public PdfFormXObject(WmfImageData image, PdfDocument pdfDocument)
Creates a form XObject fromWmfImageData
. Unlike other images,WmfImageData
images are represented asPdfFormXObject
, not asPdfImageXObject
.- Parameters:
image
- image to create form object frompdfDocument
- document instance which is needed for writing form stream contents
-
-
Method Detail
-
calculateBBoxMultipliedByMatrix
public static Rectangle calculateBBoxMultipliedByMatrix(PdfFormXObject form)
Calculates the coordinates of the xObject BBox multiplied by the Matrix field.For mor information see paragraph 8.10.1 in ISO-32000-1.
- Parameters:
form
- the object for which calculate the coordinates of the bBox- Returns:
- the bBox
Rectangle
-
getResources
public PdfResources getResources()
GetsPdfResources
of the Form XObject. Note, if there is no resources, a new instance will be created.- Returns:
- not null instance of
PdfResources
.
-
getBBox
public PdfArray getBBox()
Gets Form XObject's BBox,PdfName.BBox
key.
-
setBBox
public PdfFormXObject setBBox(PdfArray bBox)
Sets Form XObject's BBox,PdfName.BBox
key.
-
setGroup
public PdfFormXObject setGroup(PdfTransparencyGroup transparency)
Sets a group attributes dictionary indicating that the contents of the form XObject shall be treated as a group and specifying the attributes of that group.PdfName.Group
key.- Parameters:
transparency
- instance ofPdfTransparencyGroup
.- Returns:
- object itself.
- See Also:
PdfTransparencyGroup
-
getWidth
public float getWidth()
Gets width based on XObject's BBox.- Overrides:
getWidth
in classPdfXObject
- Returns:
- float value.
-
getHeight
public float getHeight()
Gets height based on XObject's BBox.- Overrides:
getHeight
in classPdfXObject
- Returns:
- float value.
-
flush
public void flush()
To manually flush aPdfObject
behind this wrapper, you have to ensure that this object is added to the document, i.e. it has an indirect reference. Basically this means that before flushing you need to explicitly callPdfObjectWrapper.makeIndirect(PdfDocument)
. For example: wrapperInstance.makeIndirect(document).flush(); Note that not every wrapper require this, only those that have such warning in documentation.- Overrides:
flush
in classPdfObjectWrapper<PdfStream>
-
setProcessColorModel
public PdfFormXObject setProcessColorModel(PdfName model)
Sets process color model for trap network appearance,PdfName.PCM
key.- Parameters:
model
- shall be one of the valid values:PdfName.DeviceGray
,PdfName.DeviceRGB
,PdfName.DeviceCMYK
,PdfName.DeviceCMY
,PdfName.DeviceRGBK
, andPdfName.DeviceN
.- Returns:
- object itself.
-
getProcessColorModel
public PdfName getProcessColorModel()
Gets process color model of trap network appearance,PdfName.PCM
key.- Returns:
- a
PdfName
instance, possible values:PdfName.DeviceGray
,PdfName.DeviceRGB
,PdfName.DeviceCMYK
,PdfName.DeviceCMY
,PdfName.DeviceRGBK
, andPdfName.DeviceN
.
-
setSeparationColorNames
public PdfFormXObject setSeparationColorNames(PdfArray colorNames)
Sets separation color names for the trap network appearance,PdfName.SeparationColorNames
key.- Parameters:
colorNames
- an array of names identifying the colorants that were assumed when the trap network appearance was created.- Returns:
- object itself.
-
getSeparationColorNames
public PdfArray getSeparationColorNames()
Gets separation color names of trap network appearance,PdfName.SeparationColorNames
key.- Returns:
- an
PdfArray
of names identifying the colorants.
-
setTrapRegions
public PdfFormXObject setTrapRegions(PdfArray regions)
Sets an array of TrapRegion objects defining the page’s trapping zones and the associated trapping parameters, as described in Adobe Technical Note #5620, Portable Job Ticket Format.PdfName.TrapRegions
key.- Parameters:
regions
- APdfArray
of indirect references to TrapRegion objects.- Returns:
- object itself.
-
getTrapRegions
public PdfArray getTrapRegions()
Gets an array of TrapRegion objects defining the page’s trapping zones and the associated trapping parameters, as described in Adobe Technical Note #5620, Portable Job Ticket Format.PdfName.TrapRegions
key.- Returns:
- A
PdfArray
of indirect references to TrapRegion objects.
-
setTrapStyles
public PdfFormXObject setTrapStyles(PdfString trapStyles)
Sets a human-readable text string that described this trap network to the user.PdfName.TrapStyles
key.- Parameters:
trapStyles
- aPdfString
value.- Returns:
- object itself.
-
getTrapStyles
public PdfString getTrapStyles()
Gets a human-readable text string that described this trap network to the user.PdfName.TrapStyles
key.- Returns:
- a
PdfString
value.
-
setMarkStyle
public PdfFormXObject setMarkStyle(PdfString markStyle)
Sets a text string representing the printer’s mark in human-readable form.- Parameters:
markStyle
- a string value.- Returns:
- object itself.
-
getMarkStyle
public PdfString getMarkStyle()
Gets a text string representing the printer’s mark in human-readable form.- Returns:
- a string value.
-
put
public PdfFormXObject put(PdfName key, PdfObject value)
Puts the value into Image XObject dictionary and associates it with the specified key. If the key is already present, it will override the old value with the specified one.- Parameters:
key
- key to insert or to overridevalue
- the value to associate with the specified key- Returns:
- object itself.
-
isRelativeSized
public boolean isRelativeSized()
If the form xobject is relative sized. This information is used during xobject layout to resolve it's relative size.- Returns:
true
if the xobject is relative sized,false
otherwise
-
-