Package org.apache.pdfbox.pdmodel

Examples of org.apache.pdfbox.pdmodel.PDResources


    }

    private PDResources getPDResources()
    {
        COSBase res = this.fontDictionary.getItem(COSName.RESOURCES);
        PDResources pResources = null;
        COSDictionary resAsDict = COSUtils.getAsDictionary(res, cosDocument);
        if (resAsDict != null)
        {
            pResources = new PDResources(resAsDict);
        }
        return pResources;
    }
View Full Code Here


                        "The Resources element isn't a dictionary"));
                return;
            }

            // process Fonts and XObjects
            ContextHelper.validateElement(context, new PDResources(dictionary), RESOURCES_PROCESS);
            COSBase cbFont = dictionary.getItem(COSName.FONT);

            if (cbFont != null)
            {
                /*
 
View Full Code Here

        }
    }

    protected void validateXObjectResources() throws ValidationException
    {
        PDResources resources = this.pdXObj.getResources();
        if (resources != null)
        {
            ContextHelper.validateElement(context, resources, RESOURCES_PROCESS);
        }
    }
View Full Code Here

        graphics.setRenderingHint( RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON );
        // Only if there is some content, we have to process it.
        // Otherwise we are done here and we will produce an empty page
        if ( page.getContents() != null)
        {
            PDResources resources = page.findResources();
            processStream( page, resources, page.getContents().getStream() );
        }
        List<PDAnnotation> annotations = page.getAnnotations();
        for( int i=0; i<annotations.size(); i++ )
        {
View Full Code Here

        // create form stream, form and  resource.
        this.pdfBuilder.createHolderFormStream(template);
        PDStream holderFormStream = pdfStructure.getHolderFormStream();
        this.pdfBuilder.createHolderFormResources();
        PDResources holderFormResources = pdfStructure.getHolderFormResources();
        this.pdfBuilder.createHolderForm(holderFormResources, holderFormStream, formater);
       
        // that is /AP entry the appearance dictionary.
        this.pdfBuilder.createAppearanceDictionary(pdfStructure.getHolderForm(), pdSignatureField);
       
        // inner formstream, form and resource (hlder form containts inner form)
        this.pdfBuilder.createInnerFormStream(template);
        this.pdfBuilder.createInnerFormResource();
        PDResources innerFormResource = pdfStructure.getInnerFormResources();
        this.pdfBuilder.createInnerForm(innerFormResource, pdfStructure.getInnterFormStream(), formater);
        PDXObjectForm innerForm = pdfStructure.getInnerForm();
      
        // inner form must be in the holder form as we wrote
        this.pdfBuilder.insertInnerFormToHolerResources(innerForm, holderFormResources);
       
        //  Image form is in this structure: /AcroForm/DR/FRM0/Resources/XObject/n0
        this.pdfBuilder.createImageFormStream(template);
        PDStream imageFormStream = pdfStructure.getImageFormStream();
        this.pdfBuilder.createImageFormResources();
        PDResources imageFormResources = pdfStructure.getImageFormResources();
        this.pdfBuilder.createImageForm(imageFormResources, innerFormResource, imageFormStream, formater, transform,
                pdfStructure.getJpedImage());
      
        // now inject procSetArray
        this.pdfBuilder.injectProcSetArray(innerForm, page, innerFormResource, imageFormResources, holderFormResources,
View Full Code Here

    private PDFont getFontAndUpdateResources( List tokens, PDAppearanceStream appearanceStream ) throws IOException
    {

        PDFont retval = null;
        PDResources streamResources = appearanceStream.getResources();
        PDResources formResources = acroForm.getDefaultResources();
        if( formResources != null )
        {
            if( streamResources == null )
            {
                streamResources = new PDResources();
                appearanceStream.setResources( streamResources );
            }

            COSString da = getDefaultAppearance();
            if( da != null )
            {
                String data = da.getString();
                PDFStreamParser streamParser = new PDFStreamParser(
                        new ByteArrayInputStream( data.getBytes("ISO-8859-1") ), null );
                streamParser.parse();
                tokens = streamParser.getTokens();
            }

            int setFontIndex = tokens.indexOf( PDFOperator.getOperator( "Tf" ));
            COSName cosFontName = (COSName)tokens.get( setFontIndex-2 );
            String fontName = cosFontName.getName();
            retval = (PDFont)streamResources.getFonts().get( fontName );
            if( retval == null )
            {
                retval = (PDFont)formResources.getFonts().get( fontName );
                streamResources.addFont(retval, fontName);
            }
        }
        return retval;
    }
View Full Code Here

     *
     * @return The appearance stream resources.
     */
    public PDResources getResources()
    {
        PDResources retval = null;
        COSDictionary dict = (COSDictionary)stream.getDictionaryObject( COSName.RESOURCES );
        if( dict != null )
        {
            retval = new PDResources( dict );
        }
        return retval;
    }
View Full Code Here

     * @param context
     * @param page
     */
    protected void validateColorSpaces(PreflightContext context, PDPage page) throws ValidationException
    {
        PDResources resources = page.getResources();
        if (resources != null)
        {
            Map<String, PDColorSpace> colorSpaces = resources.getColorSpaces();
            if (colorSpaces != null)
            {
                PreflightConfiguration config = context.getConfig();
                ColorSpaceHelperFactory colorSpaceFactory = config.getColorSpaceHelperFact();
                for (PDColorSpace pdCS : colorSpaces.values())
View Full Code Here

    }

    protected void parseResources(PreflightContext context, PDPage page, PDTilingPatternResources pattern)
            throws ValidationException
            {
        PDResources resources = pattern.getResources();
        if (resources != null)
        {
            ContextHelper.validateElement(context, resources, RESOURCES_PROCESS);
        }
            }
View Full Code Here

            addValidationError(ctx, new ValidationError(PreflightConstants.ERROR_PDF_PROCESSING_MISSING, "Resources validation process needs at least one PDResources object"));
        }
        else
        {

            PDResources resources = (PDResources) vPath.peek();

            validateFonts(ctx, resources);
            validateExtGStates(ctx, resources);
            validateShadingPattern(ctx, resources);
            validateTilingPattern(ctx, resources);
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.pdmodel.PDResources

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.