Example usage for org.apache.pdfbox.cos COSObject setObjectNumber

List of usage examples for org.apache.pdfbox.cos COSObject setObjectNumber

Introduction

In this page you can find the example usage for org.apache.pdfbox.cos COSObject setObjectNumber.

Prototype

public void setObjectNumber(long objectNum) 

Source Link

Document

Setter for property objectNumber.

Usage

From source file:net.padaf.preflight.utils.TestCOSUtils.java

License:Apache License

@Test
public void testIsInteger() {
    try {/*from ww w. j  av  a 2 s  .  c  o  m*/
        COSObject co = new COSObject(new COSInteger(10));
        co.setGenerationNumber(new COSInteger(0));
        co.setObjectNumber(new COSInteger(10));

        assertFalse(COSUtils.isInteger(co, new IOCOSDocument()));

        COSDocument doc = new COSDocument();
        doc.setXRef(new COSObjectKey(co), 1000);
        COSUtils.isInteger(co, doc);
        doc.close();
    } catch (IOException e) {
        fail(e.getMessage());
    }
}

From source file:net.padaf.preflight.utils.TestCOSUtils.java

License:Apache License

@Test
public void testIsFloat() {
    try {// w  w w  .  ja  v  a2  s.  c  o m
        COSObject co = new COSObject(new COSFloat(10.0f));
        co.setGenerationNumber(new COSInteger(0));
        co.setObjectNumber(new COSInteger(10));

        assertFalse(COSUtils.isFloat(co, new IOCOSDocument()));

        COSDocument doc = new COSDocument();
        doc.setXRef(new COSObjectKey(co), 1000);
        COSUtils.isFloat(co, doc);
        doc.close();
    } catch (IOException e) {
        fail(e.getMessage());
    }
}

From source file:net.padaf.preflight.utils.TestCOSUtils.java

License:Apache License

@Test
public void testIsString() {
    try {// w  ww  .  j a v  a  2  s .c om
        COSObject co = new COSObject(new COSString(""));
        co.setGenerationNumber(new COSInteger(0));
        co.setObjectNumber(new COSInteger(10));

        assertFalse(COSUtils.isString(co, new IOCOSDocument()));

        COSDocument doc = new COSDocument();
        doc.setXRef(new COSObjectKey(co), 1000);
        COSUtils.isString(co, doc);
        doc.close();
    } catch (IOException e) {
        fail(e.getMessage());
    }
}

From source file:net.padaf.preflight.utils.TestCOSUtils.java

License:Apache License

@Test
public void testIsStream() {
    try {// ww w. ja  v a 2  s.c om
        COSObject co = new COSObject(new COSStream(null));
        co.setGenerationNumber(new COSInteger(0));
        co.setObjectNumber(new COSInteger(10));

        assertFalse(COSUtils.isStream(co, new IOCOSDocument()));

        COSDocument doc = new COSDocument();
        doc.setXRef(new COSObjectKey(co), 1000);
        COSUtils.isStream(co, doc);
        doc.close();
    } catch (IOException e) {
        fail(e.getMessage());
    }
}

From source file:net.padaf.preflight.utils.TestCOSUtils.java

License:Apache License

@Test
public void testIsDictionary() {
    try {/*from   ww  w.j a v a 2 s .  co  m*/
        COSObject co = new COSObject(new COSDictionary());
        co.setGenerationNumber(new COSInteger(0));
        co.setObjectNumber(new COSInteger(10));

        assertFalse(COSUtils.isDictionary(co, new IOCOSDocument()));

        COSDocument doc = new COSDocument();
        doc.setXRef(new COSObjectKey(co), 1000);
        COSUtils.isDictionary(co, doc);
        doc.close();
    } catch (IOException e) {
        fail(e.getMessage());
    }
}

From source file:net.padaf.preflight.utils.TestCOSUtils.java

License:Apache License

@Test
public void testIsArray() {
    try {/*  ww w.j av a2  s .c  om*/
        COSObject co = new COSObject(new COSArray());
        co.setGenerationNumber(new COSInteger(0));
        co.setObjectNumber(new COSInteger(10));

        assertFalse(COSUtils.isArray(co, new IOCOSDocument()));

        COSDocument doc = new COSDocument();
        doc.setXRef(new COSObjectKey(co), 1000);
        COSUtils.isArray(co, doc);
        doc.close();
    } catch (IOException e) {
        fail(e.getMessage());
    }
}

From source file:org.apache.fop.render.pdf.StructureTreeMergerTestCase.java

License:Apache License

@Test
public void testCheckNullCOSObject() throws IOException {
    setUp();//from ww  w  .  j  a v  a  2 s. c  om
    PDDocument doc = PDDocument.load(new File(getClass().getResource(BrokenLink).getFile()));
    PDPage srcPage = doc.getPage(0);
    PageParentTreeFinder finder = new PageParentTreeFinder(srcPage);
    COSArray markedContentParents = finder.getPageParentTreeArray(doc);
    COSObject nullObj = new COSObject(null);
    nullObj.setObjectNumber(100);
    nullObj.setGenerationNumber(0);
    PDFStructElem elem = new PDFStructElem();
    elem.setObjectNumber(2);
    COSObject parent = (COSObject) markedContentParents.get(1);
    COSArray kids = (COSArray) parent.getDictionaryObject(COSName.K);
    COSDictionary kid = (COSDictionary) kids.get(1);
    kid.setItem(COSName.OBJ, nullObj);
    adapter = new PDFBoxAdapter(pdfPage, new HashMap(), new HashMap<Integer, PDFArray>());
    PDFLogicalStructureHandler handler = setUpPDFLogicalStructureHandler();
    StructureTreeMerger merger = new StructureTreeMerger(elem, handler, adapter, srcPage);
    merger.copyStructure(markedContentParents);
    PDFArray array = handler.getPageParentTree();
    PDFStructElem parentElem = (PDFStructElem) array.get(1);
    PDFDictionary objrDict = (PDFDictionary) parentElem.getKids().get(1);
    Assert.assertNull(objrDict.get("Obj"));
}

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  . ja v  a2s  .c o 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");
}

From source file:org.apache.padaf.preflight.utils.TestCOSUtils.java

License:Apache License

@Test
public void testIsInteger() {
    try {/*from w  w w .ja  v  a 2s  .c  o  m*/
        COSObject co = new COSObject(new COSInteger(10));
        co.setGenerationNumber(COSInteger.ZERO);
        co.setObjectNumber(new COSInteger(10));

        assertFalse(COSUtils.isInteger(co, new IOCOSDocument()));

        COSDocument doc = new COSDocument();
        addToXref(doc, new COSObjectKey(co), 1000);
        COSUtils.isInteger(co, doc);
        doc.close();
    } catch (IOException e) {
        fail(e.getMessage());
    }
}

From source file:org.apache.padaf.preflight.utils.TestCOSUtils.java

License:Apache License

@Test
public void testIsFloat() {
    try {/* w  w w. jav a  2s  .c o m*/
        COSObject co = new COSObject(new COSFloat(10.0f));
        co.setGenerationNumber(COSInteger.ZERO);
        co.setObjectNumber(new COSInteger(10));

        assertFalse(COSUtils.isFloat(co, new IOCOSDocument()));

        COSDocument doc = new COSDocument();
        addToXref(doc, new COSObjectKey(co), 1000);
        COSUtils.isFloat(co, doc);
        doc.close();
    } catch (IOException e) {
        fail(e.getMessage());
    }
}