List of usage examples for org.apache.pdfbox.cos COSObject COSObject
public COSObject(COSBase object)
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);//from 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"); }
From source file:org.apache.padaf.preflight.utils.TestCOSUtils.java
License:Apache License
@Test public void testIsInteger() { try {//from w ww. j a va2 s . co 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 {//from w ww .java2 s . c om 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()); } }
From source file:org.apache.padaf.preflight.utils.TestCOSUtils.java
License:Apache License
@Test public void testIsString() { try {/* ww w .j a va2 s. co m*/ COSObject co = new COSObject(new COSString("")); co.setGenerationNumber(COSInteger.ZERO); co.setObjectNumber(new COSInteger(10)); assertFalse(COSUtils.isString(co, new IOCOSDocument())); COSDocument doc = new COSDocument(); addToXref(doc, new COSObjectKey(co), 1000); COSUtils.isString(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 testIsStream() { try {/*from w w w . j a v a 2 s . c om*/ COSObject co = new COSObject(new COSStream(null)); co.setGenerationNumber(COSInteger.ZERO); co.setObjectNumber(new COSInteger(10)); assertFalse(COSUtils.isStream(co, new IOCOSDocument())); COSDocument doc = new COSDocument(); addToXref(doc, new COSObjectKey(co), 1000); COSUtils.isStream(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 testIsDictionary() { try {//from w w w . j ava 2 s . c o m COSObject co = new COSObject(new COSDictionary()); co.setGenerationNumber(COSInteger.ZERO); co.setObjectNumber(new COSInteger(10)); assertFalse(COSUtils.isDictionary(co, new IOCOSDocument())); COSDocument doc = new COSDocument(); addToXref(doc, new COSObjectKey(co), 1000); COSUtils.isDictionary(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 testIsArray() { try {/*from w w w . j ava 2s. co m*/ COSObject co = new COSObject(new COSArray()); co.setGenerationNumber(COSInteger.ZERO); co.setObjectNumber(new COSInteger(10)); assertFalse(COSUtils.isArray(co, new IOCOSDocument())); COSDocument doc = new COSDocument(); addToXref(doc, new COSObjectKey(co), 1000); COSUtils.isArray(co, doc); doc.close(); } catch (IOException e) { fail(e.getMessage()); } }
From source file:org.lockss.pdf.pdfbox.PdfBoxTokens.java
License:Open Source License
/** * <p>// w w w.j ava2 s. co m * Converts from a PDF token to a {@link COSObject}. * </p> * @param operator An operator. * @return A {@link PDFOperator} instance. * @since 1.56.3 */ protected static COSObject upgradeToCOSObject(PdfToken value) { try { return new COSObject(asCOSBase(value)); } catch (IOException ioe) { /* * IMPLEMENTATION NOTE * * As it turns out, IOException can never be thrown even though * the signatures of COSObject.COSObject() (PDFBox 1.6.0: * COSObject line 42) COSObject.setObject() (line 99) say it * might. */ logger.warning("Error while converting to COSObject", ioe); return null; } }