www.webdeveloper.com
Results 1 to 4 of 4

Thread: help me check this code please

  1. #1
    Join Date
    Jun 2013
    Posts
    2

    help me check this code please

    private void createPdf()
    {
    try {
    Document document = new Document (PageSize.A4, 0, 0, 0, 0) {};
    PdfWriter.getInstance(document, new FileOutputStream("report.pdf"));
    document.open();
    document.setMargins(0, 0, 0, 0);

    // Paragraph title1 = new Paragraph();
    // Chapter chapter1 = new Chapter(1);
    // Section section1 = chapter1.addSection(title1);
    // chapter1.setNumberDepth(0);
    // Paragraph title11 = new Paragraph("This is Section 1 in Chapter 1",
    // FontFactory.getFont(FontFactory.HELVETICA,16,Font.BOLD,new Color(255, 0, 0)));
    // Section section1 = chapter1.addSection(title11);
    // Paragraph someSectionText = new Paragraph("This text comes as part of section 1 of chapter 1.");
    // section1.add(someSectionText);
    // someSectionText = new Paragraph("Following is a 3 X 2 table.");
    // section1.add(someSectionText);
    List contactList=allContactlList;
    int i=contactList.size()/2;
    Font f1=new Font("Verdana", Font.PLAIN, 12);
    Table t = new Table(2,i);
    // t.setBorderColor(new Color(220, 255, 100));
    t.setPadding(2);
    t.setSpacing(10);
    t.setBorderWidth(0);

    for(int j=0;j<contactList.size();j++)
    {
    Contact contact=(Contact)contactList.get(j);
    String contactText="Name : "+contact.getContactname()+"\n"
    +"Address : "+contact.getAddress()+"\n"
    +"Phone : "+contact.getPhone()+"\n"
    +"E-mail : "+contact.getEmail();

    Cell c1 = new Cell(contactText);
    c1.setMaxLines(4);
    //c1.setWidth("10");
    //c1.setc
    //c1.setBorder(1);
    t.addCell(c1);
    }


    //section1.add(t);
    document.add(t);



    document.close();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123
    you need to be a bit more elaborate then this...
    what is the problem?
    what is it you want ur code to be checked for?
    MOST important, what is the detailed error that you are getting?
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Jun 2013
    Posts
    2
    it is a method for printing in pdf format

  4. #4
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123
    what does it do?
    does it not print?
    you have to give actual problem here...
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles