COS Object Model
COS Layer
The COS (Carousel Object System) layer represents the raw PDF object model as defined in ISO 32000-1:2008, §7.3. All high-level PDF structures are built on these primitives.
Core Types
| Class | PDF type |
|---|---|
COSDictionary | Dictionary (<< >>) |
COSArray | Array ([ ]) |
COSStream | Stream with dictionary header |
COSName | Name object (/Name) |
COSString | String (literal or hex) |
COSInteger | Integer |
COSBoolean | Boolean |
COSDictionary
COSDictionary maps COSName keys to COS values. Use set(name, value) to add
entries and get(name) to retrieve them:
COSDictionary dict = new COSDictionary();
dict.set(COSName.of("Author"), new COSString("Jane Smith"));
COSString author = (COSString) dict.get(COSName.of("Author"));COSArray
COSArray holds an ordered list of COS objects:
COSArray array = new COSArray();
array.add(COSInteger.valueOf(1));
array.add(COSInteger.valueOf(2));
int len = array.size(); // 2Accessing the Document Catalog
The PDF catalog is accessible via Document.getCatalog(), which returns a
COSDictionary representing the root catalog object.