List of usage examples for org.apache.pdfbox.cos COSName P
COSName P
To view the source code for org.apache.pdfbox.cos COSName P.
Click Source Link
From source file:org.apache.fop.render.pdf.pdfbox.StructureTreeMerger.java
License:Apache License
private boolean checkPageEntryInAncestorsRecursively(COSDictionary elem) { if (elem.containsKey(COSName.PG)) { COSDictionary pageDict = (COSDictionary) elem.getDictionaryObject(COSName.PG); return srcPage.getCOSObject() == pageDict; } else if (elem.containsKey(COSName.P)) { COSDictionary parent = (COSDictionary) elem.getDictionaryObject(COSName.P); return checkPageEntryInAncestorsRecursively(parent); } else {// ww w. j av a 2s . c o m return true; } }
From source file:org.apache.fop.render.pdf.pdfbox.StructureTreeMergerUtil.java
License:Apache License
public static int findObjectPositionInKidsArray(COSObject kid) { COSObject parent = (COSObject) kid.getItem(COSName.P); COSBase kids = parent.getItem(COSName.K); if (kids instanceof COSArray) { COSArray kidsArray = (COSArray) kids; return kidsArray.indexOfObject(kid); } else {//from w w w. j a v a 2s. co m return 0; } }
From source file:org.apache.fop.render.pdf.StructureTreeMergerTestCase.java
License:Apache License
@Test public void testDirectDescedants() throws IOException { PDFStructElem elem = new PDFStructElem(); elem.setObjectNumber(100);/* w w w. j a v a 2 s . co m*/ setUp(); adapter = new PDFBoxAdapter(pdfPage, new HashMap(), new HashMap<Integer, PDFArray>()); PDFLogicalStructureHandler handler = setUpPDFLogicalStructureHandler(); PDPage srcPage = new PDPage(); StructureTreeMerger merger = new StructureTreeMerger(elem, handler, adapter, srcPage); COSArray array = new COSArray(); COSDictionary dict = new COSDictionary(); dict.setItem(COSName.S, COSName.P); COSObject obj = new COSObject(dict); obj.setObjectNumber(200); obj.setGenerationNumber(0); array.add(0, obj); merger.createDirectDescendants(array, elem); List<PDFObject> list = elem.getKids(); PDFStructElem kid = (PDFStructElem) list.get(0); PDFName name = (PDFName) kid.get("S"); String test = name.getName(); Assert.assertEquals(test, "P"); }