Package org.apache.pdfbox.pdmodel

Examples of org.apache.pdfbox.pdmodel.PDResources


        }

        PDOptionalContentGroup layer = new PDOptionalContentGroup(layerName);
        ocprops.addGroup(layer);

        PDResources resources = targetPage.findResources();
        PDPropertyList props = resources.getProperties();
        if (props == null)
        {
            props = new PDPropertyList();
            resources.setProperties(props);
        }

        //Find first free resource name with the pattern "MC<index>"
        int index = 0;
        PDOptionalContentGroup ocg;
View Full Code Here


                    List pages = document.getDocumentCatalog().getAllPages();
                    Iterator iter = pages.iterator();
                    while( iter.hasNext() )
                    {
                        PDPage page = (PDPage)iter.next();
                        PDResources resources = page.getResources();
                        // extract all XObjectImages which are part of the page resources
                        processResources(resources, prefix, addKey);
                    }
                }
                finally
View Full Code Here

                }
                // maybe there are more images embedded in a form object
                else if (xobject instanceof PDXObjectForm)
                {
                    PDXObjectForm xObjectForm = (PDXObjectForm)xobject;
                    PDResources formResources = xObjectForm.getResources();
                    processResources(formResources, prefix, addKey);
                }
            }
        }
    }
View Full Code Here

       
        page = sourcePage;
        resources = page.getResources();
        if( resources == null )
        {
            resources = new PDResources();
            page.setResources( resources );
        }

        // Get the pdstream from the source page instead of creating a new one
        PDStream contents = sourcePage.getContents();
View Full Code Here

        Iterator pagesIter = pages.iterator();
        while( pagesIter.hasNext() )
        {
            PDPage page = (PDPage)pagesIter.next();
            COSBase contents = page.getCOSDictionary().getDictionaryObject( COSName.CONTENTS );
            PDResources resources = page.findResources();
            if( resources == null )
            {
                resources = new PDResources();
                page.setResources( resources );
            }
            COSDictionary res = resources.getCOSDictionary();

            if( contents instanceof COSStream )
            {
                COSStream stream = (COSStream) contents;
                Map objectNameMap = new TreeMap();
View Full Code Here

     *
     * @return The resources for this pattern.
     */
    public PDResources getResources()
    {
        PDResources retval = null;
        COSDictionary resources = (COSDictionary)getCOSDictionary().getDictionaryObject( COSName.RESOURCES );
        if( resources != null )
        {
            retval = new PDResources( resources );
        }
        return retval;
    }
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.getFonts().put( fontName, retval );
            }
        }
        return retval;
    }
View Full Code Here

            // save the graphics state
            context.getGraphicsStack().push( (PDGraphicsState)context.getGraphicsState().clone() );
           
            PDXObjectForm form = (PDXObjectForm)xobject;
            COSStream invoke = (COSStream)form.getCOSObject();
            PDResources pdResources = form.getResources();
            if(pdResources == null)
            {
                pdResources = page.findResources();
            }
            // if there is an optional form matrix, we have to
View Full Code Here

   * @return true is the ExtGState is missing or valid, false otherwise.
   * @throws ValidationException
   */
  protected boolean checkExtGraphicState(List<ValidationError> error)
      throws ValidationException {
    PDResources resources = this.pdXObj.getResources();
    if (resources != null) {
      ExtGStateContainer extContainer = new ExtGStateContainer(resources
          .getCOSDictionary(), this.cosDocument);
      return extContainer.validateTransparencyRules(error);
    }
    return true;
  }
View Full Code Here

   * @return true if the validation succeed, false otherwise.
   * @throws ValidationException
   */
  protected boolean validateShadingPattern(List<ValidationError> result)
      throws ValidationException {
    PDResources resources = this.pdXObj.getResources();
    boolean res = true;
    if (resources != null) {
      COSDictionary shadings = (COSDictionary) resources.getCOSDictionary()
          .getDictionaryObject(PATTERN_KEY_SHADING);
      if (shadings != null) {
        for (Object key : shadings.keySet()) {
          COSDictionary aShading = (COSDictionary) shadings
              .getDictionaryObject((COSName) key);
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.