Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSDocument


            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());
        }
View Full Code Here


            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());
        }
View Full Code Here

        createContext();
    }

    protected void createPdfADocument(Format format, PreflightConfiguration config) throws IOException
    {
        COSDocument cosDocument = getDocument();
        this.preflightDocument = new PreflightDocument(cosDocument, format, config);
    }
View Full Code Here

{

    public void validate(PreflightContext ctx) throws ValidationException
    {
        PDDocument pdfDoc = ctx.getDocument();
        COSDocument cDoc = pdfDoc.getDocument();

        List<?> lCOSObj = cDoc.getObjects();
        for (Object o : lCOSObj)
        {
            COSBase cBase = ((COSObject) o).getObject();
            if (cBase instanceof COSDictionary)
            {
View Full Code Here

    protected void checkEncoding()
    {
        COSBase encoding = ((COSDictionary) font.getCOSObject()).getItem(COSName.ENCODING);
        if (encoding != null)
        {
            COSDocument cosDocument = context.getDocument().getDocument();
            if (COSUtils.isString(encoding, cosDocument))
            {
                String encodingName = COSUtils.getAsString(encoding, cosDocument);
                if (!(encodingName.equals(FONT_DICTIONARY_VALUE_ENCODING_MAC)
                        || encodingName.equals(FONT_DICTIONARY_VALUE_ENCODING_MAC_EXP)
View Full Code Here

     * @throws ValidationException
     */
    protected void validateExtGStates(PreflightContext context, PDResources resources) throws ValidationException
    {
        COSBase egsEntry = resources.getCOSDictionary().getItem(TRANPARENCY_DICTIONARY_KEY_EXTGSTATE);
        COSDocument cosDocument = context.getDocument().getDocument();
        COSDictionary extGState = COSUtils.getAsDictionary(egsEntry, cosDocument);
        if (egsEntry != null)
        {
            ContextHelper.validateElement(context, extGState, EXTGSTATE_PROCESS);
        }
View Full Code Here

        }
    }

    protected void validateXObjects(PreflightContext context, PDResources resources) throws ValidationException
    {
        COSDocument cosDocument = context.getDocument().getDocument();
        COSDictionary mapOfXObj = COSUtils.getAsDictionary(resources.getCOSDictionary().getItem(COSName.XOBJECT),
                cosDocument);
        if (mapOfXObj != null)
        {
            for (Entry<COSName, COSBase> entry : mapOfXObj.entrySet())
View Full Code Here

     *
     * @throws IOException If there is an error creating this document.
     */
    public PDDocument() throws IOException
    {
        document = new COSDocument();

        //First we need a trailer
        COSDictionary trailer = new COSDictionary();
        document.setTrailer( trailer );

View Full Code Here

        {
            acroFormFields.add(signatureField);
        }
       
        // Get the object from the visual signature
        COSDocument visualSignature = options.getVisualSignature();

        // Distinction of case for visual and non-visual signature
        if (visualSignature == null) // non-visual signature
        {
            // Set rectangle for non-visual signature to 0 0 0 0
            signatureField.getWidget().setRectangle(new PDRectangle())// rectangle array [ 0 0 0 0 ]
            // Clear AcroForm / Set DefaultRessource
            acroFormDict.setItem(COSName.DR, null);
            // Set empty Appearance-Dictionary
            PDAppearanceDictionary ap = new PDAppearanceDictionary();
            COSStream apsStream = getDocument().createCOSStream();
            apsStream.createUnfilteredStream();
            PDAppearanceStream aps = new PDAppearanceStream(apsStream);
            COSDictionary cosObject = (COSDictionary)aps.getCOSObject();
            cosObject.setItem(COSName.SUBTYPE, COSName.FORM);
            cosObject.setItem(COSName.BBOX, new PDRectangle());
           
            ap.setNormalAppearance(aps);
            ap.getDictionary().setDirect(true);
            signatureField.getWidget().setAppearance(ap);
        }
        else // visual signature
        {
            // Obtain visual signature object
            List<COSObject> cosObjects = visualSignature.getObjects();
   
            boolean annotNotFound = true;
            boolean sigFieldNotFound = true;

            for ( COSObject cosObject : cosObjects )
View Full Code Here

    * @throws IOException
    * @throws COSVisitorException
    */
    public ByteArrayInputStream getTemplateAppearanceStream() throws IOException, COSVisitorException
    {
        COSDocument visualSignature = getVisualSignature();
        ByteArrayOutputStream memoryOut = new ByteArrayOutputStream();
        COSWriter memoryWriter = new COSWriter(memoryOut);
        memoryWriter.write(visualSignature);

        ByteArrayInputStream input = new ByteArrayInputStream(memoryOut.toByteArray());
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.cos.COSDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.