Examples of PDAppearanceDictionary


Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary

                //when it is opened.  See FreedomExpressions.pdf for an example of this.
            }
            else
            {

                PDAppearanceDictionary appearance = widget.getAppearance();
                if( appearance == null )
                {
                    appearance = new PDAppearanceDictionary();
                    widget.setAppearance( appearance );
                }

                Map normalAppearance = appearance.getNormalAppearance();
                PDAppearanceStream appearanceStream = (PDAppearanceStream)normalAppearance.get( "default" );
                if( appearanceStream == null )
                {
                    COSStream cosStream = new COSStream( acroForm.getDocument().getDocument().getScratchFile() );
                    appearanceStream = new PDAppearanceStream( cosStream );
                    appearanceStream.setBoundingBox( widget.getRectangle().createRetranslatedRectangle() );
                    appearance.setNormalAppearance( appearanceStream );
                }

                List tokens = getStreamTokens( appearanceStream );
                List daTokens = getStreamTokens( getDefaultAppearance() );
                PDFont pdFont = getFontAndUpdateResources( tokens, appearanceStream );
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary

   * @param errors
   *          list of errors which is updated if validation fails
   * @return
   */
  protected boolean checkAP(List<ValidationError> errors) {
    PDAppearanceDictionary ap = this.pdAnnot.getAppearance();
    if (ap != null) {
      COSDictionary apDict = ap.getDictionary();
      // ---- Only N entry is authorized
      if (apDict.getItem(COSName.getPDFName(ANNOT_DICTIONARY_KEY_D)) != null
          || apDict.getItem(
              COSName.getPDFName(ANNOT_DICTIONARY_KEY_R)) != null) {
        errors.add(new ValidationResult.ValidationError(
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary

        for( int i=0; i<annotations.size(); i++ )
        {
            PDAnnotation annot = (PDAnnotation)annotations.get( i );
            PDRectangle rect = annot.getRectangle();
            String appearanceName = annot.getAppearanceStream();
            PDAppearanceDictionary appearDictionary = annot.getAppearance();
            if( appearDictionary != null )
            {
                if( appearanceName == null )
                {
                    appearanceName = "default";
                }
                Map appearanceMap = appearDictionary.getNormalAppearance();
                if (appearanceMap != null) {
                    PDAppearanceStream appearance =
                        (PDAppearanceStream)appearanceMap.get( appearanceName );
                    if( appearance != null )
                    {
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary

        for( int i=0; i<annotations.size(); i++ )
        {
            PDAnnotation annot = (PDAnnotation)annotations.get( i );
            PDRectangle rect = annot.getRectangle();
            String appearanceName = annot.getAppearanceStream();
            PDAppearanceDictionary appearDictionary = annot.getAppearance();
            if( appearDictionary != null )
            {
                if( appearanceName == null )
                {
                    appearanceName = "default";
                }
                Map appearanceMap = appearDictionary.getNormalAppearance();
                if (appearanceMap != null)
                {
                    PDAppearanceStream appearance =
                        (PDAppearanceStream)appearanceMap.get( appearanceName );
                    if( appearance != null )
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary

            // 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 = new COSStream(getDocument().getScratchFile());
            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 )
            {
                COSBase base = cosObject.getObject();
                if (base != null && base instanceof COSDictionary)
                {
                    COSBase ft = ((COSDictionary)base).getItem(COSName.FT);
                    COSBase type = ((COSDictionary)base).getItem(COSName.TYPE);
                    COSBase apDict = ((COSDictionary)base).getItem(COSName.AP);
           
                    // Search for signature annotation
                    if (annotNotFound && COSName.ANNOT.equals(type))
                    {
                        COSDictionary cosBaseDict = (COSDictionary)base;
             
                        // Read and set the Rectangle for visual signature
                        COSArray rectAry = (COSArray)cosBaseDict.getItem(COSName.RECT);
                        PDRectangle rect = new PDRectangle(rectAry);
                        signatureField.getWidget().setRectangle(rect);
                        annotNotFound = false;
                    }
           
                    // Search for Signature-Field
                    if (sigFieldNotFound && COSName.SIG.equals(ft) && apDict != null)
                    {
                        COSDictionary cosBaseDict = (COSDictionary)base;
             
                        // Appearance Dictionary auslesen und setzen
                        PDAppearanceDictionary ap =
                                new PDAppearanceDictionary((COSDictionary)cosBaseDict.getItem(COSName.AP));
                        ap.getDictionary().setDirect(true);
                        signatureField.getWidget().setAppearance(ap);
             
                        // AcroForm DefaultRessource auslesen und setzen
                        COSBase dr = cosBaseDict.getItem(COSName.DR);
                        dr.setDirect(true);
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary

                //when it is opened.  See FreedomExpressions.pdf for an example of this.
            }
            else
            {

                PDAppearanceDictionary appearance = widget.getAppearance();
                if( appearance == null )
                {
                    appearance = new PDAppearanceDictionary();
                    widget.setAppearance( appearance );
                }

                Map normalAppearance = appearance.getNormalAppearance();
                PDAppearanceStream appearanceStream = (PDAppearanceStream)normalAppearance.get( "default" );
                if( appearanceStream == null )
                {
                    COSStream cosStream = new COSStream( acroForm.getDocument().getDocument().getScratchFile() );
                    appearanceStream = new PDAppearanceStream( cosStream );
                    appearanceStream.setBoundingBox( widget.getRectangle().createRetranslatedRectangle() );
                    appearance.setNormalAppearance( appearanceStream );
                }

                List tokens = getStreamTokens( appearanceStream );
                List daTokens = getStreamTokens( getDefaultAppearance() );
                PDFont pdFont = getFontAndUpdateResources( tokens, appearanceStream );
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary

                    // adjust the image to the target rectangle and add it to the stream
                    drawXObject(ximage, form.getResources(), os, lowerLeftX, lowerLeftY, imgWidth, imgHeight);
                    os.close();

                    PDAppearanceStream myDic = new PDAppearanceStream(form.getCOSStream());
                    PDAppearanceDictionary appearance = new PDAppearanceDictionary(new COSDictionary());
                    appearance.setNormalAppearance(myDic);
                    rubberStamp.setAppearance(appearance);
                    rubberStamp.setRectangle(rect);

                    //Add the new RubberStamp to the document
                    annotations.add(rubberStamp);
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary

            // 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 )
            {
                if (!annotNotFound && !sigFieldNotFound)
                {
                    break;
                }
               
                COSBase base = cosObject.getObject();
                if (base != null && base instanceof COSDictionary)
                {
                    COSBase ft = ((COSDictionary)base).getItem(COSName.FT);
                    COSBase type = ((COSDictionary)base).getItem(COSName.TYPE);
                    COSBase apDict = ((COSDictionary)base).getItem(COSName.AP);
           
                    // Search for signature annotation
                    if (annotNotFound && COSName.ANNOT.equals(type))
                    {
                        COSDictionary cosBaseDict = (COSDictionary)base;
             
                        // Read and set the Rectangle for visual signature
                        COSArray rectAry = (COSArray)cosBaseDict.getItem(COSName.RECT);
                        PDRectangle rect = new PDRectangle(rectAry);
                        signatureField.getWidget().setRectangle(rect);
                        annotNotFound = false;
                    }
           
                    // Search for Signature-Field
                    if (sigFieldNotFound && COSName.SIG.equals(ft) && apDict != null)
                    {
                        COSDictionary cosBaseDict = (COSDictionary)base;
             
                        // Appearance Dictionary auslesen und setzen
                        PDAppearanceDictionary ap =
                                new PDAppearanceDictionary((COSDictionary)cosBaseDict.getItem(COSName.AP));
                        ap.getDictionary().setDirect(true);
                        signatureField.getWidget().setAppearance(ap);
             
                        // AcroForm DefaultRessource auslesen und setzen
                        COSBase dr = cosBaseDict.getItem(COSName.DR);
                        dr.setDirect(true);
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary

        for( int i=0; i<annotations.size(); i++ )
        {
            PDAnnotation annot = (PDAnnotation)annotations.get( i );
            PDRectangle rect = annot.getRectangle();
            String appearanceName = annot.getAppearanceStream();
            PDAppearanceDictionary appearDictionary = annot.getAppearance();
            if( appearDictionary != null )
            {
                if( appearanceName == null )
                {
                    appearanceName = "default";
                }
                Map<String, PDAppearanceStream> appearanceMap = appearDictionary.getNormalAppearance();
                if (appearanceMap != null)
                {
                    PDAppearanceStream appearance =
                        (PDAppearanceStream)appearanceMap.get( appearanceName );
                    if( appearance != null )
View Full Code Here

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary

        for( int i=0; i<annotations.size(); i++ )
        {
            PDAnnotation annot = (PDAnnotation)annotations.get( i );
            PDRectangle rect = annot.getRectangle();
            String appearanceName = annot.getAppearanceStream();
            PDAppearanceDictionary appearDictionary = annot.getAppearance();
            if( appearDictionary != null )
            {
                if( appearanceName == null )
                {
                    appearanceName = "default";
                }
                Map<String, PDAppearanceStream> appearanceMap = appearDictionary.getNormalAppearance();
                if (appearanceMap != null)
                {
                    PDAppearanceStream appearance =
                        (PDAppearanceStream)appearanceMap.get( appearanceName );
                    if( appearance != null )
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.