Package com.itextpdf.kernel.pdf.xobject
Class PdfXObject
- Direct Known Subclasses:
-
PdfFormXObject,PdfImageXObject
An abstract wrapper for supported types of XObject.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds file associated with PDF XObject and identifies the relationship between them.static RectanglecalculateProportionallyFitRectangleWithHeight(PdfXObject xObject, float x, float y, float height) Calculates a rectangle with the specified coordinates and height, and the width is calculated in such a way that the original proportions of the xObject do not change.static RectanglecalculateProportionallyFitRectangleWithWidth(PdfXObject xObject, float x, float y, float width) Calculates a rectangle with the specified coordinates and width, and the height is calculated in such a way that the original proportions of the xObject do not change.getAssociatedFiles(boolean create) Returns files associated with XObject.floatGets height of XObject.floatgetWidth()Gets width of XObject.protected booleanDefines if the object behind this wrapper must be an indirect object in the resultant document.static PdfXObjectmakeXObject(PdfStream stream) voidSets the layer this XObject belongs to.Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
Constructor Details
-
PdfXObject
-
-
Method Details
-
makeXObject
- Parameters:
-
stream-PdfStreamwith eitherPdfName.FormorPdfName.ImagePdfName.Subtype - Returns:
-
either
PdfFormXObjectorPdfImageXObject.
-
calculateProportionallyFitRectangleWithWidth
public static Rectangle calculateProportionallyFitRectangleWithWidth(PdfXObject xObject, float x, float y, float width) Calculates a rectangle with the specified coordinates and width, and the height is calculated in such a way that the original proportions of the xObject do not change.To calculate the original width and height of the xObject, the BBox and Matrix fields are used. For mor information see paragraph 8.10.1 in ISO-32000-1.
- Parameters:
-
xObject- the xObject for which we are calculating the rectangle -
x- the x-coordinate of the lower-left corner of the rectangle -
y- the y-coordinate of the lower-left corner of the rectangle -
width- the width of the rectangle - Returns:
- the rectangle with specified coordinates and width
-
calculateProportionallyFitRectangleWithHeight
public static Rectangle calculateProportionallyFitRectangleWithHeight(PdfXObject xObject, float x, float y, float height) Calculates a rectangle with the specified coordinates and height, and the width is calculated in such a way that the original proportions of the xObject do not change.To calculate the original width and height of the xObject, the BBox and Matrix fields are used. For mor information see paragraph 8.10.1 in ISO-32000-1.
- Parameters:
-
xObject- the xObject for which we are calculating the rectangle -
x- the x-coordinate of the lower-left corner of the rectangle -
y- the y-coordinate of the lower-left corner of the rectangle -
height- the height of the rectangle - Returns:
- the rectangle with specified coordinates and height
-
setLayer
Sets the layer this XObject belongs to.- Parameters:
-
layer- the layer this XObject belongs to.
-
getWidth
public float getWidth()Gets width of XObject.- Returns:
- float value.
-
getHeight
public float getHeight()Gets height of XObject.- Returns:
- float value.
-
addAssociatedFile
Adds file associated with PDF XObject and identifies the relationship between them. Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. The method adds file to array value of the AF key in the XObject dictionary.For associated files their associated file specification dictionaries shall include the AFRelationship key
- Parameters:
-
fs- file specification dictionary of associated file
-
getAssociatedFiles
Returns files associated with XObject.- Parameters:
-
create- defines whether AF arrays will be created if it doesn't exist - Returns:
- associated files array
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()Defines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
-
isWrappedObjectMustBeIndirectin classPdfObjectWrapper<PdfStream> - Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-