示例#1
0
  public void addTitlePage(Document document, CustomerOrder customerOrder)
      throws DocumentException {
    Paragraph preface = new Paragraph();
    // We add one empty line
    addEmptyLine(preface, 1);
    Image image = null;
    try {
      image = Image.getInstance("img/gfcLogo.jpg");
      image.scaleAbsolute(100f, 100f);
      image.setAlignment(Image.ALIGN_LEFT);
    } catch (IOException e) {
      e.printStackTrace();
    }
    document.add(image);
    // Lets write a big header
    Phrase invoice = new Phrase();
    invoice.add(new Chunk("Generation For Christ", companyName));
    invoice.add(new Chunk("                                   Invoice", companyName));
    preface.add(new Paragraph(invoice));
    // preface.add(new Paragraph( "));

    preface.add(new Paragraph("                      We Make Disciples", companySlogan));
    // preface.add(new Paragraph( "                Invoice", companyName));
    // addEmptyLine(preface, 1);
    Date date = new Date();
    String dateFormat = new SimpleDateFormat("dd/MM/yyyy").format(date);
    preface.add(
        new Paragraph(
            "                                                                                                                                         DATE:   "
                + dateFormat,
            details));
    preface.add(
        new Paragraph(
            "25 James Street, Dandenong                                                                                   ORDER ID:    "
                + customerOrder.getOrderId(),
            details));
    preface.add(new Paragraph("Melbourne, Victoria, 3175", details));
    preface.add(new Paragraph("Phone # ", details));

    // Will create: Report generated by: _name, _date
    // preface.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " +
    // new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    //         smallBold));
    // addEmptyLine(preface, 3);
    // preface.add(new Paragraph("This document contains confidential information of GFC's member",
    //         smallBold));

    document.add(preface);
    // Start a new page
    // document.newPage();
  }
示例#2
0
  public void addContent(Document document, CustomerOrder customerOrder) throws DocumentException {

    //	Anchor anchor = new Anchor(member.getFname()+"'s Details", catFont);
    //   anchor.setName(member.getFname()+"'s Details");

    // Second parameter is the number of the chapter
    //  Chapter catPart = new Chapter(new Paragraph(anchor),1);

    // Personal Details
    Paragraph personal = new Paragraph("Bill To", subFont);
    // Section personalSection = catPart.addSection(personal);

    Phrase mFname = new Phrase();

    mFname.add(new Chunk(customerOrder.getFname(), details));
    mFname.add(new Chunk("    "));
    mFname.add(new Chunk(customerOrder.getLname(), details));
    personal.add(new Paragraph(mFname));

    Phrase street = new Phrase();
    if ((!customerOrder.getStreet().isEmpty()) && (!customerOrder.getSuburb().isEmpty())) {
      street.add(new Chunk(customerOrder.getStreet() + ", " + customerOrder.getSuburb(), details));
      personal.add(new Paragraph(street));

      Phrase city = new Phrase();

      city.add(
          new Chunk(
              customerOrder.getCity()
                  + ", "
                  + customerOrder.getState()
                  + ",  Australia, "
                  + customerOrder.getPostCode(),
              details));
      personal.add(new Paragraph(city));
    }
    Phrase phone = new Phrase();

    phone.add(new Chunk(customerOrder.getContactNo(), details));
    personal.add(new Paragraph(phone));
    addEmptyLine(personal, 2);
    PdfPTable table = new PdfPTable(2);

    PdfPCell c1 = new PdfPCell(new Phrase("Description", companySlogan));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Cost", companySlogan));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    table.setHeaderRows(1);

    c1 = new PdfPCell(new Phrase(customerOrder.getComment()));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase("$ " + customerOrder.getCost()));
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);

    Paragraph subtotal =
        new Paragraph(
            "                                                                                SubTotal:                    $ "
                + customerOrder.getCost());
    subtotal.setAlignment(Element.ALIGN_CENTER);
    Paragraph amountPaid =
        new Paragraph(
            "                                                                          Amount Paid:                    $ "
                + customerOrder.getAmountPaid());
    amountPaid.setAlignment(Element.ALIGN_CENTER);
    Paragraph line =
        new Paragraph(
            "                                                                         ----------------------------------------------");
    line.setAlignment(Element.ALIGN_CENTER);
    Paragraph balance =
        new Paragraph(
            "                                                                             Total Due:                    $ "
                + customerOrder.getBalance());
    balance.setAlignment(Element.ALIGN_CENTER);
    addEmptyLine(balance, 2);
    Paragraph pleaseContact =
        new Paragraph(
            "If you have any questions about this Invoice please don't hesitate to contact us.");
    pleaseContact.setAlignment(Element.ALIGN_CENTER);

    document.add(personal);
    document.add(table);

    document.add(subtotal);
    document.add(amountPaid);
    document.add(line);
    document.add(balance);
    document.add(pleaseContact);
  }