Package com.lowagie.text.pdf

Examples of com.lowagie.text.pdf.AcroFields


            Map acroFieldMap = (Map)context.get("acroFieldMap");
            ByteBuffer byteBuffer = getInputByteBuffer(context, delegator);
            PdfReader r = new PdfReader(byteBuffer.array());
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PdfStamper s = new PdfStamper(r, baos);
            AcroFields fs = s.getAcroFields();
            Map map = fs.getFields();
           
            s.setFormFlattening(true);
           
            // Debug code to get the values for setting TDP
    //      String[] sa = fs.getAppearanceStates("TDP");
    //      for (int i=0;i<sa.length;i++)
    //          Debug.log("Appearance="+sa[i]);
           
            Iterator iter = map.keySet().iterator();
            while (iter.hasNext()) {
                String fieldName=(String)iter.next();
                String fieldValue = fs.getField(fieldName);
                Object obj = acroFieldMap.get(fieldName);
                if (obj instanceof Date) {
                    Date d=(Date)obj;
                    fieldValue=UtilDateTime.toDateString(d);
                } else if (obj instanceof Long) {
                    Long lg=(Long)obj;
                    fieldValue=lg.toString();
                } else if (obj instanceof Integer) {
                    Integer ii=(Integer)obj;
                    fieldValue=ii.toString();
                }   else {
                    fieldValue=(String)obj;
                }
           
                if (UtilValidate.isNotEmpty(fieldValue))
                    fs.setField(fieldName, fieldValue);
            }     
                
            s.close();
            baos.close();
            ByteBuffer outByteBuffer = ByteBuffer.wrap(baos.toByteArray());
View Full Code Here


        try {
            // merging the FDF file
            PdfReader pdfreader = new PdfReader("SimpleRegistrationForm.pdf");
            PdfStamper stamp = new PdfStamper(pdfreader, new FileOutputStream("registered_xfdf.pdf"));
            XfdfReader fdfreader = new XfdfReader("register.xfdf");
            AcroFields form = stamp.getAcroFields();
            form.setFields(fdfreader);
            stamp.close();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

        try {
            // we create a reader for a certain document
            PdfReader reader = new PdfReader("SimpleRegistrationForm.pdf");
            // filling in the form
            PdfStamper stamp1 = new PdfStamper(reader, new FileOutputStream("registered.pdf"));
            AcroFields form1 = stamp1.getAcroFields();
            form1.setField("name", "Bruno Lowagie");
            form1.setField("address", "Baeyensstraat 121, Sint-Amandsberg");
            form1.setField("postal_code", "BE-9040");
            form1.setField("email", "bruno@lowagie.com");
            stamp1.close();
            // filling in the form and flatten
            reader = new PdfReader("SimpleRegistrationForm.pdf");
            PdfStamper stamp2 = new PdfStamper(reader, new FileOutputStream("registered_flat.pdf"));
            AcroFields form2 = stamp2.getAcroFields();
            form2.setField("name", "Bruno Lowagie");
            form2.setField("address", "Baeyensstraat 121, Sint-Amandsberg");
            form2.setField("postal_code", "BE-9040");
            form2.setField("email", "bruno@lowagie.com");
            stamp2.setFormFlattening(true);
            stamp2.close();
        }
        catch (Exception de) {
            de.printStackTrace();
View Full Code Here

            // merging the FDF file
            PdfReader pdfreader = new PdfReader("SimpleRegistrationForm.pdf");
            PdfStamper stamp = new PdfStamper(pdfreader, new FileOutputStream("registered_fdf.pdf"));
            FdfReader fdfreader = new FdfReader("SimpleRegistrationForm.fdf");
            AcroFields form = stamp.getAcroFields();
            form.setFields(fdfreader);
            stamp.close();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

        try {
            // we create a reader for a certain document
            PdfReader reader = new PdfReader("SimpleRegistrationForm.pdf");
            // filling in the form
            PdfStamper stamp1 = new PdfStamper(reader, new FileOutputStream("registered.pdf"));
            AcroFields form1 = stamp1.getAcroFields();
            form1.setField("name", "Bruno Lowagie");
            form1.setField("address", "Baeyensstraat 121, Sint-Amandsberg");
            form1.setField("postal_code", "BE-9040");
            form1.setField("email", "bruno@lowagie.com");
            stamp1.close();
            // filling in the form and flatten
            reader = new PdfReader("SimpleRegistrationForm.pdf");
            PdfStamper stamp2 = new PdfStamper(reader, new FileOutputStream("registered_flat.pdf"));
            AcroFields form2 = stamp2.getAcroFields();
            form2.setField("name", "Bruno Lowagie");
            form2.setField("address", "Baeyensstraat 121, Sint-Amandsberg");
            form2.setField("postal_code", "BE-9040");
            form2.setField("email", "bruno@lowagie.com");
            stamp2.setFormFlattening(true);
            stamp2.close();
        }
        catch (Exception de) {
            de.printStackTrace();
View Full Code Here

        try {
            // merging the FDF file
            PdfReader pdfreader = new PdfReader("SimpleRegistrationForm.pdf");
            PdfStamper stamp = new PdfStamper(pdfreader, new FileOutputStream("registered_xfdf.pdf"));
            XfdfReader fdfreader = new XfdfReader("register.xfdf");
            AcroFields form = stamp.getAcroFields();
            form.setFields(fdfreader);
            stamp.close();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

        try {
            // we create a reader for a certain document
            PdfReader reader = new PdfReader("SimpleRegistrationForm.pdf");
            // filling in the form
            PdfStamper stamp1 = new PdfStamper(reader, new FileOutputStream("registered.pdf"));
            AcroFields form1 = stamp1.getAcroFields();
            form1.setField("name", "Bruno Lowagie");
            form1.setField("address", "Baeyensstraat 121, Sint-Amandsberg");
            form1.setField("postal_code", "BE-9040");
            form1.setField("email", "bruno@lowagie.com");
            stamp1.close();
            // filling in the form and flatten
            reader = new PdfReader("SimpleRegistrationForm.pdf");
            PdfStamper stamp2 = new PdfStamper(reader, new FileOutputStream("registered_flat.pdf"));
            AcroFields form2 = stamp2.getAcroFields();
            form2.setField("name", "Bruno Lowagie");
            form2.setField("address", "Baeyensstraat 121, Sint-Amandsberg");
            form2.setField("postal_code", "BE-9040");
            form2.setField("email", "bruno@lowagie.com");
            stamp2.setFormFlattening(true);
            stamp2.close();
        }
        catch (Exception de) {
            de.printStackTrace();
View Full Code Here

            // merging the FDF file
            PdfReader pdfreader = new PdfReader("SimpleRegistrationForm.pdf");
            PdfStamper stamp = new PdfStamper(pdfreader, new FileOutputStream("registered_fdf.pdf"));
            FdfReader fdfreader = new FdfReader("SimpleRegistrationForm.fdf");
            AcroFields form = stamp.getAcroFields();
            form.setFields(fdfreader);
            stamp.close();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

        try {
            // we create a reader for a certain document
            PdfReader reader = new PdfReader("SimpleRegistrationForm.pdf");
            // filling in the form
            PdfStamper stamp1 = new PdfStamper(reader, new FileOutputStream("registered.pdf"));
            AcroFields form1 = stamp1.getAcroFields();
            form1.setField("name", "Bruno Lowagie");
            form1.setField("address", "Baeyensstraat 121, Sint-Amandsberg");
            form1.setField("postal_code", "BE-9040");
            form1.setField("email", "bruno@lowagie.com");
            stamp1.close();
            // filling in the form and flatten
            reader = new PdfReader("SimpleRegistrationForm.pdf");
            PdfStamper stamp2 = new PdfStamper(reader, new FileOutputStream("registered_flat.pdf"));
            AcroFields form2 = stamp2.getAcroFields();
            form2.setField("name", "Bruno Lowagie");
            form2.setField("address", "Baeyensstraat 121, Sint-Amandsberg");
            form2.setField("postal_code", "BE-9040");
            form2.setField("email", "bruno@lowagie.com");
            stamp2.setFormFlattening(true);
            stamp2.close();
        }
        catch (Exception de) {
            de.printStackTrace();
View Full Code Here

   private Boolean readOnly = Boolean.TRUE;

   @Override
   public void encodeBegin(FacesContext facesContext) throws IOException
   {
      AcroFields fields = (AcroFields) Contexts.getEventContext().get(FIELDS_KEY);
      String theName = getName();
      Object theValue = getValue();
      if (theValue == null) {
          return;
      }
      Boolean readOnly = getReadOnly();
      try
      {
         log.debug("Setting field '#0' to value '#1'", theName, theValue);
         boolean success = false;
         if (theValue instanceof String) {
             success = fields.setField(theName, (String) theValue);
         } else if (theValue instanceof String[]){
       String[] stringValue = (String[])theValue;
       if (stringValue.length>0) {
                 success = fields.setField(theName, stringValue[0]);
       } else {
     success = true;
       }
         } else {
             String message = Interpolator.instance().interpolate("Field #0 expected String or String[] but got #0", getName(), theValue.getClass().getName());
View Full Code Here

TOP

Related Classes of com.lowagie.text.pdf.AcroFields

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.