Example usage for org.apache.pdfbox.cos COSName MCID

List of usage examples for org.apache.pdfbox.cos COSName MCID

Introduction

In this page you can find the example usage for org.apache.pdfbox.cos COSName MCID.

Prototype

COSName MCID

To view the source code for org.apache.pdfbox.cos COSName MCID.

Click Source Link

Usage

From source file:org.apache.fop.render.pdf.pdfbox.StructureTreeMerger.java

License:Apache License

private void createKidFromCOSDictionary(COSDictionary mcrDict, PDFStructElem parent, COSDictionary baseDict)
        throws IOException {
    Collection<COSName> exclude = Arrays.asList(COSName.PG);
    PDFReference referenceObj;/* w  ww  . j  av a2 s .  com*/
    if (isElementFromSourcePage(mcrDict, baseDict)) {
        PDFDictionary contentItem = (PDFDictionary) adapter.cloneForNewDocument(mcrDict, mcrDict, exclude);
        if (mcrDict.keySet().contains(COSName.TYPE)) {
            String type = ((COSName) mcrDict.getDictionaryObject(COSName.TYPE)).getName();
            if (type.equals("OBJR")) {
                COSObject obj = (COSObject) mcrDict.getItem(COSName.OBJ);
                if (adapter.getCachedClone(obj) == null) {
                    referenceObj = null;
                } else {
                    referenceObj = ((PDFObject) adapter.getCachedClone(obj)).makeReference();
                }
                contentItem.put(COSName.OBJ.getName(), referenceObj);
                updateStructParentAndAddToPageParentTree(referenceObj, parent);
            } else if (type.equals("MCR")) {
                updateMCIDEntry(contentItem);
                markedContentMap.put(
                        (((PDFNumber) contentItem.get(COSName.MCID.getName())).getNumber()).intValue(), parent);
            }
        }
        if (mcrDict.keySet().contains(COSName.PG)) {
            contentItem.put(COSName.PG.getName(), targetPage.makeReference());
        } else {
            parent.put(COSName.PG.getName(), targetPage.makeReference());
        }
        parent.addKid(contentItem);
    } else {
        parent.addKid(null);
    }
}

From source file:org.apache.fop.render.pdf.pdfbox.StructureTreeMerger.java

License:Apache License

private void updateMCIDEntry(PDFDictionary mcrDictionary) {
    if (currentMCID > 0) {
        int oldMCID = (((PDFNumber) mcrDictionary.get(COSName.MCID.getName())).getNumber()).intValue();
        PDFNumber number = new PDFNumber();
        number.setNumber(oldMCID + currentMCID);
        mcrDictionary.put(COSName.MCID.getName(), number);
    }//  www.ja  va 2 s. com
}