Package com.datalogics.PDFL
Class Content
java.lang.Object
com.datalogics.PDFL.Content
Class that represents the collection of elements on a PDF page. A content object represents a collection of elements that make up a page in a PDF file. A content object is more convenient to use than directly parsing or working with a page content stream. This is because a page can include a large collection of individual stream objects. Working with a content object, you can avoid focusing on this level of detail. The content converts individual stream items to a structured form, making it unnecessary to parse the individual syntax for each one. A content object can be associated with a large amount of unmanaged memory in APDFL and should be deleted when the object is no longer in use.
The index associated with Content is 0-based, so 0 is the first element.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPosition for inserting an element before the first element. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddElement(Element NewElem) Adds an existing Element at the end of the content object.voidaddElement(Element NewElem, int addAfterIndex) Adds an existing Element at the given index of the content object.voidaddPage(int insertAfterIndex, Document containerDoc, Page srcPage, Matrix dstMatrix, List<String> annotTypes, EnumSet<AddPageFlags> flags, Rect bbox) Adds the specfied Page to the Content as a Form.voiddelete()booleanFlattens optional content within this Content object.The bounding box for this content.getDefaultColorSpace(String name) Get a default color space from a Content object.getElement(int index) Get the element specified by index.intThe number of elements in the Content object.voidremoveElement(int index) Removes the Element at the specified index.voidsetDefaultColorSpace(String name, ColorSpace colorSpace) Set a default color space from a Content object.toString()
-
Field Details
-
BEFORE_FIRST
public static final int BEFORE_FIRSTPosition for inserting an element before the first element.- See Also:
-
-
Constructor Details
-
Content
public Content()Create content -
Content
Create content with a first Element.- Parameters:
firstElem- The Element which is to be added to the beginning of the new Content object.
-
-
Method Details
-
delete
public void delete() -
toString
-
getNumElements
public int getNumElements()The number of elements in the Content object. -
getElement
Get the element specified by index. -
addElement
Adds an existing Element at the end of the content object.- Parameters:
NewElem- The Element which is to be added to the end of the existing Content object.
-
addElement
Adds an existing Element at the given index of the content object.- Parameters:
NewElem- The Element which is to be added to the end of the existing Content object.addAfterIndex- The position after which to insert the new Element, the index is 0-based so 0 is the first element. To insert a new element as the first element use the Content.BeforeFirst constant.
-
addPage
public void addPage(int insertAfterIndex, Document containerDoc, Page srcPage, Matrix dstMatrix, List<String> annotTypes, EnumSet<AddPageFlags> flags, Rect bbox) Adds the specfied Page to the Content as a Form. It adds a reference to the Xobject form at the indicated index in the Content; the index may be less than 0, which indicates the object is to be appended to the content.- Parameters:
insertAfterIndex- The index indicates the location after which the specified element is to be added. The index should be BeforeFirst to add to the beginning of the display list.containerDoc- The Document in which the page is contained.srcPage- The page that will be inserted at insertAfterIndex in theContent.dstMatrix- (May be NULL) The matrix applied to the default matrix of the Page that is inserted into the Document.annotTypes- If the page contains annotations, the annotTypes list is used to determine which annotation types are pumped into the page contents of the CosDoc.flags- (May be 0) AllAnnotations specifies all annotation types. If this is not set, then the annotTypes list will be consulted.bbox- (May be NULL) specifies the destination BBox for the page being inserted. If it is NULL, the new page's media box is used.
-
removeElement
public void removeElement(int index) Removes the Element at the specified index.- Parameters:
index- The position at which to remove the Element
-
getBoundingBox
The bounding box for this content.The bounding box is a rectangle that is at least large enough to contain the bounding boxes for all the elements in the Content.
-
getDefaultColorSpace
Get a default color space from a Content object.- Parameters:
name- The name of the color space to get. It must be one of DefaultRGB, DefaultCMYK, or DefaultGray.- Returns:
- The color space used as the default. May return null if no default is set.
-
setDefaultColorSpace
Set a default color space from a Content object.- Parameters:
name- The name of the color space to set. It must be one of DefaultRGB, DefaultCMYK, or DefaultGray.colorSpace- The color space to set. It may not be a Lab, Indexed or Pattern color space.
-
flattenOptionalContent
Flattens optional content within this Content object.Removes elements that are not visible in the given optional content context and removes optional content information from any visible elements.
The optional content information formerly associated with this Content object will NOT be deleted from the document, as it is possible that content elsewhere in the document may be using the information.
- Parameters:
occ- The optional content context in which content is checked for visibility.- Returns:
- true if the content was successfully flattened, false otherwise.
-