@GetPrintedObjAttribute Function Documentation
@GetPrintedObjAttribute Function
1. Overview
The @GetPrintedObjAttribute function returns the finally (printed) attributes of an output object, such as its position on the page and page number.
2. Parameters
| Parameter | Type | Description |
|---|---|---|
PageNumber |
INT | Specifies the page number to search in. Use -1 to search in all generated pages. |
FieldName |
STRING | The name of the output field. |
Attrib |
STRING | The type of object attribute to return: – "x1" – Left object coordinate on the page – "x2" – Right object coordinate on the page – "y1" – Top object coordinate on the page – "y2" – Bottom object coordinate on the page – "page" – Page number |
FirstOrLastFlag |
INT | Determines which occurrence to return: – 0 – Return Attribute of First found object – 1 – Return Attribute of Last found object |
3. Return Value
The function returns an INT value representing the requested object attribute.
4. Usage Examples
4.1 Returns the Y2 coordinate of the first found object
@GetPrintedObjAttribute(job.page, "Footer_Header", "y2", 0)
This returns the Y2 coordinate of the first found Footer_Header object on the current page.
4.2 Returns the Y1 coordinate of the last found object across all pages
@GetPrintedObjAttribute(-1, "Text2", "y1", 1)
This returns the Y1 coordinate of the last found Text2 object across all pages.
4.3 Returns the page number of the last found object
@GetPrintedObjAttribute(-1, "Footer_Footer", "page", 1)
This returns the page number where the last occurrence of Footer_Footer was found.
5. Important Notes
WARNING: This function is applicable ONLY for iText destination files.
Note: The function searches in the **generated output**, not in the design-time template.
6. Common Use Cases
- Determining the exact position of dynamically generated objects.
- Checking which page an object appears on.
- Aligning objects based on their final placement.
7. Summary
The @GetPrintedObjAttribute function is a powerful tool for retrieving the actual printed attributes of objects in iText destination files. It enables precise control over object positioning and page placement.