Check box

Discussion in 'Java' started by ChinoKhan, Apr 16, 2008.

  1. ChinoKhan

    ChinoKhan Guest

    I am writing an application in Java which submits data to MYSQL
    database. I am using PDF fill able form to collect my data. Collecting
    part of data is working fine. Problem comes in when I try to
    repopulate data to the PDF form from MYSQL. The two types of objects I
    have on my form are text field and check boxes. Text fields I can
    repopulate without any problem. I need help in check boxes. I am using
    Jar itext-2.0.6. Any help or code example will be appreciated.
     
    ChinoKhan, Apr 16, 2008
    #1
    1. Advertising

  2. ChinoKhan

    Roedy Green Guest

    On Wed, 16 Apr 2008 07:38:20 -0700 (PDT), ChinoKhan
    <> wrote, quoted or indirectly quoted someone
    who said :

    >I am writing an application in Java which submits data to MYSQL
    >database. I am using PDF fill able form to collect my data. Collecting
    >part of data is working fine. Problem comes in when I try to
    >repopulate data to the PDF form from MYSQL. The two types of objects I
    >have on my form are text field and check boxes. Text fields I can
    >repopulate without any problem. I need help in check boxes. I am using
    >Jar itext-2.0.6. Any help or code example will be appreciated.


    You are the first person I have encountered who has used PDF this way.
    I would try some sort of PDF newsgroup. Most people here will be
    familiar only with doing that only with AWT, Swing or HTTP and
    Servlets.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Apr 16, 2008
    #2
    1. Advertising

  3. ChinoKhan

    Mark Space Guest

    Roedy Green wrote:
    > On Wed, 16 Apr 2008 07:38:20 -0700 (PDT), ChinoKhan
    > <> wrote, quoted or indirectly quoted someone
    > who said :
    >
    >> I am writing an application in Java which submits data to MYSQL
    >> database. I am using PDF fill able form to collect my data. Collecting
    >> part of data is working fine. Problem comes in when I try to
    >> repopulate data to the PDF form from MYSQL. The two types of objects I
    >> have on my form are text field and check boxes. Text fields I can
    >> repopulate without any problem. I need help in check boxes. I am using
    >> Jar itext-2.0.6. Any help or code example will be appreciated.

    >
    > You are the first person I have encountered who has used PDF this way.
    > I would try some sort of PDF newsgroup. Most people here will be
    > familiar only with doing that only with AWT, Swing or HTTP and
    > Servlets.


    I think there's some PDF technology that turns PDFs into a Flash
    website. Adobe has been pushing Flex, I bet it's related to that.

    I'm not sure at all though, and I've never worked with Flex.
     
    Mark Space, Apr 17, 2008
    #3
  4. ChinoKhan wrote:
    > I am writing an application in Java which submits data to MYSQL
    > database. I am using PDF fill able form to collect my data. Collecting
    > part of data is working fine. Problem comes in when I try to
    > repopulate data to the PDF form from MYSQL. The two types of objects I
    > have on my form are text field and check boxes. Text fields I can
    > repopulate without any problem. I need help in check boxes. I am using
    > Jar itext-2.0.6. Any help or code example will be appreciated.

    Could you post the relevant source code? It also helps if you post a
    simple program to reproduce the problem . Did you do a google search at
    all? What did you find out? I see several discussions related to
    checkboxes, itext and PDF but unless I see your code, it difficult to help.
     
    Abhijat Vatsyayan, Apr 17, 2008
    #4
  5. ChinoKhan

    ChinoKhan Guest

    On Apr 16, 6:33 pm, Abhijat Vatsyayan <> wrote:
    > ChinoKhan wrote:
    > > I am writing an application in Java which submits data to MYSQL
    > > database. I am using PDF fill able form to collect my data. Collecting
    > > part of data is working fine. Problem comes in when I try to
    > > repopulate data to the PDF form from MYSQL. The two types of objects I
    > > have on my form are text field and check boxes. Text fields I can
    > > repopulate without any problem. I need help in check boxes. I am using
    > > Jaritext-2.0.6. Any help or code example will be appreciated.

    >
    > Could you post the relevant source code? It also helps if you post a
    > simple program to  reproduce the problem . Did you do a google search at
    > all? What did you find out? I see several discussions related to
    > checkboxes,itextand PDF but unless I see your code, it difficult to help.



    Here is the code that works for textbox, The last field in key and
    value is checkbox. Value comming out of it is Corp. I hope you can
    help me.



    package Ola.src;
    import java.io.ByteArrayOutputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;

    import com.lowagie.text.Document;
    import com.lowagie.text.DocumentException;
    import com.lowagie.text.Element;
    import com.lowagie.text.Font;
    import com.lowagie.text.FontFactory;
    import com.lowagie.text.Paragraph;
    import com.lowagie.text.pdf.AcroFields;
    import com.lowagie.text.pdf.BaseFont;
    import com.lowagie.text.pdf.PdfContentByte;
    import com.lowagie.text.pdf.PdfCopy;
    import com.lowagie.text.pdf.PdfPCell;
    import com.lowagie.text.pdf.PdfPTable;
    import com.lowagie.text.pdf.PdfPTableEvent;
    import com.lowagie.text.pdf.PdfReader;
    import com.lowagie.text.pdf.PdfStamper;
    import com.lowagie.text.pdf.PdfWriter;
    import com.lowagie.text.pdf.events.FieldPositioningEvents;
    import util.src.StrTran;
    import sun.jdbc.rowset.CachedRowSet;


    import java.sql.*;


    /**
    *
    * @author kkhan
    */

    public class PDFFiller implements PdfPTableEvent {
    MySqlNativeDriver nativeDrive = new MySqlNativeDriver();
    MYSQLInsertUpdate insetupdate = new MYSQLInsertUpdate();
    StrTran st = new StrTran();
    static CachedRowSet crs;

    /* public static final String BusinessName = "BusinessName"; //
    Field Names
    public static final String BusinessAddress = "BusinessAddress";
    public static final String City = "City";
    public static final String State = "State";*/


    public static final String Session = "Session";
    public static final String Agent_id= "Agent_id";
    public static final String Status = "Status";
    public static final String referral_id= "BankNameNumber";
    public static final String AssociationNumber=
    "AssociationNumber";
    public static final String OfficeName=
    "OfficeNameNumber";
    public static final String RepName= "RepNameNumber";
    public static final String BusinessName= "BusinessName";
    public static final String BusinessAddress= "BusinessAddress";
    public static final String City = "City";
    public static final String State = "State";
    public static final String Zip = "Zip";
    public static final String LocationPhone= "LocationPhone";
    public static final String Ext = "Ext";
    public static final String LocationFax= "LocationFax";
    public static final String WebSite = "Website";
    public static final String CardholderName = "CardholderName";
    public static final String CorporateName= "CorporateName";
    public static final String BillingAddress = "BillingAddress";
    public static final String BillingCity= "BillingCity";
    public static final String BillingState = "BillingState";
    public static final String BillingZip = "BillingZip";
    public static final String ContactName = "ContactName";
    //public static final String //" OwnerName";
    public static final String
    BusinessContactPhone="BusinessContactPhone";
    public static final String BusinessEmail= "BusinessEmail";
    public static final String CorporateEmail = "ContactEmail";
    public static final String SendStatementTo =
    "SendStatementTo"; // This is checkbox





    String vreferral_id="";
    String vRepName="";
    String vBusinessName ="";
    String vBusinessAddress = "";
    String vOfficeName ="";
    String vCity = "";
    String vstate = "";
    String vZip = "";
    String vLocationPhone="";
    String vExt="";
    String vLocationFax="";
    String vBusinessEmail="";
    String vBusinessWebsite="";
    String vCorporateName="";


    String vCorporateAddress="";
    String vCorporateCity="";
    String vCorporateState="";
    String vCorporateZip="";
    String vCorporateContactName="";
    String vCorporateContactPhone="";
    String vCorporateEmail="";
    String vSendMonthlyStatementsTo=""; // This is checkbox


    String queryString ="";


    /** Creates a new instance of olatemplet */
    public PDFFiller() {
    }

    /**
    * @param args the command line arguments
    */
    public void FillTemplet(String name) {
    try {
    queryString = "Select * from app where app_id ='"+name
    +"'";
    crs=nativeDrive.query(queryString);

    while(crs.next()){

    vreferral_id = crs.getString("referral_id").trim();
    vRepName = crs.getString("RepName").trim();
    vBusinessName =crs.getString("BusinessName").trim();
    vBusinessAddress =
    crs.getString("BusinessAddress").trim();
    vOfficeName=crs.getString("OfficeName").trim();
    vCity = crs.getString("BusinessCity").trim();
    vstate = crs.getString("Businessstate").trim();
    vZip = crs.getString("BusinessZip").trim();
    vLocationPhone =crs.getString("BusinessPhone").trim();
    //vExt =crs.getString("Ext").trim();
    vLocationFax =crs.getString("BusinessFax").trim();
    vBusinessEmail=crs.getString("BusinessEmail").trim();

    vBusinessWebsite=crs.getString("BusinessWebSite").trim();
    vCorporateName=crs.getString("CorporateName").trim();

    vCorporateAddress=crs.getString("CorporateAddress").trim();
    vCorporateCity =crs.getString("CorporateCity").trim();

    vCorporateState=crs.getString("CorporateState").trim();
    vCorporateZip=crs.getString("CorporateZip").trim();

    vCorporateContactName=crs.getString("CorporateContactName").trim();

    vCorporateContactPhone=crs.getString("BusinessContactPhone").trim();

    vCorporateEmail=crs.getString("CorporateEmail").trim();
    //
    vSendMonthlyStatementsTo=crs.getString("SendStatementTo").trim();
    vSendMonthlyStatementsTo="Corp"; // This is checkbox

    System.out.println("lllllllllllllllllllllll"+
    crs.getString("SendStatementTo"));





    }
    crs.close();


    }
    catch (Exception e){
    System.out.println(e.toString());
    }

    Document document = new Document();
    String state ="CA";
    System.out.println("988888888888888888888888"+State);
    String[] keys =
    { referral_id,
    RepName,
    BusinessName,
    BusinessAddress,
    OfficeName,
    City,
    State,
    Zip,
    LocationPhone,
    //Ext,
    LocationFax,
    BusinessEmail,
    WebSite,
    CorporateName,
    BillingAddress,
    BillingCity,
    BillingState,
    BillingZip,
    ContactName,
    BusinessContactPhone,
    CorporateEmail,
    SendStatementTo,// This is checkbox

    };


    String[][] values = {
    { vreferral_id,
    vRepName,
    vBusinessName ,
    vBusinessAddress,
    vOfficeName,
    vCity,
    vstate,
    vZip,
    vLocationPhone,
    //vExt,
    vLocationFax,
    vBusinessEmail,
    vBusinessWebsite,
    vCorporateName,
    vCorporateAddress,
    vCorporateCity,
    vCorporateState,
    vCorporateZip,
    vCorporateContactName,
    vCorporateContactPhone,
    vCorporateEmail,
    vSendMonthlyStatementsTo,// This is checkbox

    },

    };

    PdfReader reader;
    ByteArrayOutputStream baos;
    PdfStamper stamper;
    AcroFields form;
    document = new Document();

    System.out.println("999999999999999999999999");
    try {
    PdfCopy copy = new PdfCopy(document, new
    FileOutputStream("f:\\Kalim\\InProgress\\"+name+".pdf"));
    document.open();
    for (int i = 0; i < values.length; i++) {
    // set fields
    //reader = new PdfReader("K:\\KALIM\\online\\Newtek
    Application1 PDF.pdf");
    reader = new PdfReader("C:\\Tomcat 4.1\\webapps\
    \Templet\\App.pdf");
    baos = new ByteArrayOutputStream();
    stamper = new PdfStamper(reader, baos);
    form = stamper.getAcroFields();
    form.setExtraMargin(0, 1);
    for (int j = 0; j < keys.length; j++) {
    form.setField(keys[j], values[j]);
    System.out.println(keys[j]+" "+values[j]);
    }
    stamper.setFormFlattening(false);
    stamper.close();
    // add page
    reader = new PdfReader(baos.toByteArray());
    copy.addPage(copy.getImportedPage(reader, 1));
    copy.addPage(copy.getImportedPage(reader, 2));
    copy.addPage(copy.getImportedPage(reader, 3));

    }
    } catch (DocumentException de) {
    System.err.println(de.getMessage());
    } catch (IOException ioe) {
    System.err.println(ioe.getMessage());
    }
    document.close();
    }






    public void tableLayout(PdfPTable table, float[][] width, float[]
    heights, int headerRows, int rowStart, PdfContentByte[] canvases) {
    float widths[] = width[0];
    PdfContentByte cb = canvases[PdfPTable.TEXTCANVAS];
    cb.rectangle(widths[0] - 5, heights[heights.length - 1] - 5,
    widths[widths.length - 1] - widths[0] + 10, heights[0] -
    heights[heights.length - 1] + 10);
    cb.stroke();
    }

    }
     
    ChinoKhan, Apr 22, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mit
    Replies:
    1
    Views:
    818
    Ramu Pulipati
    Jan 25, 2006
  2. =?Utf-8?B?QW5nZWw=?=

    COMBO BOX INSTEAD OF DROP DOWN BOX

    =?Utf-8?B?QW5nZWw=?=, Jun 29, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    620
    Ken Cox [Microsoft MVP]
    Jun 29, 2004
  3. Gnarlodious
    Replies:
    4
    Views:
    17,623
    elizas
    May 5, 2010
  4. Jim

    Check box and text box disable

    Jim, Jun 3, 2004, in forum: Javascript
    Replies:
    3
    Views:
    123
    Randy Webb
    Jun 4, 2004
  5. babu17
    Replies:
    1
    Views:
    139
Loading...

Share This Page