Example usage for com.itextpdf.text Document addSubject

List of usage examples for com.itextpdf.text Document addSubject

Introduction

In this page you can find the example usage for com.itextpdf.text Document addSubject.

Prototype


public boolean addSubject(String subject) 

Source Link

Document

Adds the subject to a Document.

Usage

From source file:sqlsentinel.report.PDFGenerator.java

License:Open Source License

private static void addMetaData(Document document) {
    document.addTitle("SQLSentinel Report");
    document.addSubject("site: " + url);
    document.addKeywords("");
    document.addAuthor("SQLSentinel");
    document.addCreator("SQLSentinel");
}

From source file:staff.cashier.CashierController.java

@FXML
private void onClickGetPayment(ActionEvent e)
        throws SQLException, IOException, ClassNotFoundException, DocumentException, DecoderException {
    PendingBill currBill = cashierView.getSelectionModel().getSelectedItem();
    System.out.println(currBill.getCusName() + " " + currBill.getOrderID() + " " + currBill.getBill());

    int orderid = currBill.getOrderID();
    int bill_status = 1;
    Statement st = conn.createStatement();
    Statement st1 = conn.createStatement();
    Statement st2 = conn.createStatement();
    // set bill status 1 in order_info table.
    String query = "update order_info set bill_paid='" + bill_status + "' where order_id='"
            + currBill.getOrderID() + "'";
    st.executeUpdate(query);//from www.jav a2  s.  c  o m
    // set cus_id=0 in corrosponding table.
    String query1 = "select * from order_info where order_id='" + currBill.getOrderID() + "'";
    ResultSet rs = st1.executeQuery(query1);
    rs.next();
    BigInteger cus_id = new BigInteger(Long.toString(rs.getLong("c_id")));
    BigInteger new_cid = BigInteger.ZERO;
    String query2 = "update table_info set c_id='" + new_cid + "',order_taken=0 where c_id='" + cus_id + "'";
    st2.executeUpdate(query2);

    //deleting the row
    ObservableList<PendingBill> billSelected, allBill;
    allBill = cashierView.getItems();

    allBill.remove((currBill));

    //Inserting into `bill` schema
    int counter = 0;
    //fetching the bill_id of the last order
    query = "select * from bill";
    rs = st.executeQuery(query);
    while (rs.next()) {
        counter = rs.getInt("bill_id");

    }

    counter++;
    String query3 = "insert into bill values(" + counter + "," + currBill.bill + ")";
    st.executeUpdate(query3);
    //Updating the bill_generation schema
    String query4 = "insert into bill_generation values(" + currBill.orderID + ",'" + caid + "'," + counter
            + ")";
    st.executeUpdate(query4);

    //GENERATING THE BILL IN PDF FORM
    String query5 = "select * from order_info where order_id=" + orderid + " ";
    ResultSet rs1 = st.executeQuery(query5);
    rs1.next();
    String itemList = rs1.getString("list");
    int tis = rs1.getInt("table_id");
    float cc = rs1.getFloat("cost");
    //String itemDetails=rs1.getString("item_qty");
    int coupon = rs1.getInt("coupon_id");

    float disc_p = 0;
    //FETCHING THE DISCOUNT PERCENT CORRESPONDING TO THAT COUPON
    if (coupon != 0) {
        Statement st4 = conn.createStatement();
        String q4 = "select discount_percent from coupon where coupon_id=" + coupon;
        ResultSet rs4 = st4.executeQuery(q4);
        rs4.next();
        disc_p = rs4.getFloat("discount_percent");

    }
    //FETCHING CUSTOMER NAME
    String query6 = "select * from customer where c_id=" + cus_id + "";
    ResultSet rs2 = st.executeQuery(query6);
    rs2.next();
    String cusname = rs2.getString("c_name");
    String email = rs2.getString("c_email");

    String itemsInfo = "";
    /*----------------DESERIALIZATION
    ByteArrayInputStream in = new ByteArrayInputStream(Hex.decodeHex(itemList.toCharArray()));
      String[] aa= (String[]) (new ObjectInputStream(in).readObject());
     //System.out.println(Arrays.toString();
      try{
     for (String aa1 : aa) {
     if(aa1!=null){
         int i;
      String tmp="";
     for( i=0;i<(aa1.length()-1);i++)
     {
                 
         tmp+=aa1.charAt(i);
     }
     int qty=Integer.parseInt(""+aa1.charAt(i));
     itemsInfo+="Item name:    "+tmp+"  Qty:"+qty+"\n\n";
             
     }
     }
      }
      catch(Exception ee){}
    -----------------------------------------*/

    //EXTRACTING INFORMATION ABOUT ORDERED ITEMS
    String tmp = "";
    for (int i = 0; i < (itemList.length() - 1); i++) {
        if (itemList.charAt(i + 1) == '-') {
            int qty = Integer.parseInt("" + itemList.charAt(i));
            Statement st3 = conn.createStatement();
            String q3 = "Select price from menu where d_name='" + tmp + "'";
            ResultSet rs3 = st3.executeQuery(q3);
            rs3.next();
            float p = rs3.getFloat("price");
            itemsInfo += "Item name:" + tmp + "  Qty:" + qty + "  Price:+" + p + "    Total:" + (qty * p)
                    + "\n\n";

            tmp = "";
            i++;
        } else
            tmp += itemList.charAt(i);
    }

    itemsInfo += "Total Cost :" + cc + "\n\n";
    if (coupon != 0) {
        float tprice = cc - ((disc_p * cc) / 100);
        itemsInfo += "You have been given a discount of " + disc_p + "%\n\nFinal Cost     :   Rs." + tprice
                + "\n\n";
    }
    System.out.println("Item info:" + itemsInfo);
    //WRITING TO PDF
    Document doc = new Document();

    PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("Order" + orderid + ".pdf"));
    doc.open();
    doc.addTitle("CENTRICO RESTAURANT");
    doc.addCreationDate();
    doc.addSubject("BILL");
    //System.out.println(itemDetails);

    doc.add(new Paragraph("                         CENTRICO RESTAURANT\n\nORDER ID     :   " + orderid
            + "\n\nTABLE ID       :   " + tis + "\n\nCUSTOMER NAME     :   " + cusname
            + "\n\nEMAIL ID       :   " + email + "\n\n" + itemsInfo + "\n\n"));

    doc.close();
    writer.close();

    //SENDING THE BILL IN MAIL TO THE CUSTOMER
    GmailQuickstart a = new GmailQuickstart();
    a.setCusemail(email);
    a.setCusmessage("Thankyou so much " + cusname
            + " for coming here.Please visit us again :) \n Please find your bill attached below\n");
    a.setCussubject("Bill for order number " + orderid);
    a.setFileName("Order" + orderid + ".pdf");
    Thread t = new Thread(a);
    t.start();

    //alert
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setTitle("Information dialog");
    alert.setHeaderText(null);
    alert.setContentText(" Payment has Received Successfully");
    alert.showAndWait();
}

From source file:tn.com.hitechart.eds.Util.pdfRpport.FirstPdf.java

private void addMetaData(Document document) {

    document.addTitle("My first PDF");
    document.addSubject("Using iText");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor("AHMED BEJ");
    document.addCreator("AHMED BEJ");
}

From source file:tn.esprit.twin1.brogrammers.eventify.Eventify.util.TicketGenerator.java

public static void GenerateTicket(Ticket ticket) {
    Document document = new Document();
    try {//w  w w  .  j  av  a 2  s . c  o  m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(FILE));
        Rectangle pagesize = new Rectangle(700, 300);
        document.open();
        Paragraph emptyline = new Paragraph();
        emptyline.add(new Paragraph(" "));
        document.setPageSize(pagesize);
        document.newPage();
        //PIC
        PdfContentByte canvas = writer.getDirectContentUnder();
        Image image = Image.getInstance(IMAGE);
        //image.scaleAbsolute(pagesize.rotate());
        image.setAbsolutePosition(0, 0);
        canvas.addImage(image);
        //PIC
        document.addTitle("Your Access To" + ticket.getEvent().getTitle());
        document.addSubject(ticket.getEvent().getTheme());
        document.addKeywords(ticket.getEvent().getTitle() + "Ticket");
        document.addAuthor("Mohamed Firas Ouertani");
        document.addCreator("Mohamed Firas Ouertani");
        Paragraph prefacetitle = new Paragraph();
        prefacetitle.add(new Paragraph("Your Ticket For " + ticket.getEvent().getTitle(), bigFont));
        document.add(prefacetitle);
        document.add(emptyline);

        Paragraph prefacetime = new Paragraph();
        prefacetime.add(new Paragraph(ticket.getEvent().getStartTime().toString(), greyFont));
        document.add(prefacetime);
        document.add(emptyline);
        document.add(emptyline);
        Paragraph prefacetype = new Paragraph();
        prefacetype.add(new Paragraph("You Reserved For: " + ticket.getTypeTicket(), catFont));
        document.add(prefacetype);
        //QR
        BarcodeQRCode qrcode = new BarcodeQRCode(
                "REF:#" + ticket.getEvent().getId() + "" + ticket.getEvent().getTitle().trim(), 1, 1, null);
        Image qrcodeImage = qrcode.getImage();
        qrcodeImage.setAbsolutePosition(520, 70);
        qrcodeImage.scalePercent(400);
        document.add(qrcodeImage);
        //QR

        //Bar
        PdfContentByte cb = writer.getDirectContent();
        Barcode128 code128 = new Barcode128();

        BarcodeEAN codeEAN = new BarcodeEAN();
        codeEAN.setCode("REF:#" + ticket.getEvent().getId() + "" + ticket.getEvent().getTitle().trim());
        codeEAN.setCodeType(BarcodeEAN.EAN13);
        Image codeEANImage = code128.createImageWithBarcode(cb, null, null);
        codeEANImage.setAbsolutePosition(10, 10);
        codeEANImage.scalePercent(125);
        document.add(codeEANImage);
        //Bar

        document.close();

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

}

From source file:tourma.views.report.HTMLtoPDF.java

public static void exportToPDF(FileOutputStream output, String source, String title, Rectangle size,
        boolean excludeCutTable) {
    try {/*  w w w. jav a2s  .  c om*/
        Document document = new Document(size);
        PdfWriter pdfWriter = PdfWriter.getInstance(document, output);
        document.open();
        document.addAuthor(Tournament.getTournament().getParams().getTournamentOrga());
        document.addCreator("TourMa");
        document.addSubject(Tournament.getTournament().getParams().getTournamentName());
        document.addCreationDate();
        document.addTitle(title);
        XMLWorkerHelper worker = XMLWorkerHelper.getInstance();

        worker.parseXHtml(pdfWriter, document, new StringReader(source));

        document.close();
    } catch (DocumentException | IOException e) {
        e.printStackTrace();
    }
}

From source file:uk.ac.openmf.utils.OpenMFPDFGenerator.java

public static void addMetaData(Document document, String title, String subject) {
    document.addTitle(title);//  w  ww  . j ava2 s  .c  o  m
    document.addSubject(subject);
}

From source file:vemo.controller.ReportController.java

@RequestMapping(value = "report/RentalsPDF", produces = "application/pdf")
@ResponseBody//from w ww  .  j  a  v  a2  s. com
public String RentalsPDF(ModelMap model, HttpServletResponse response, HttpServletRequest request,
        Integer maxResults, @RequestParam(value = "first", required = false) String first,
        @RequestParam(value = "last", required = false) String last) throws DocumentException, IOException {
    Document document = new Document();
    PdfWriter.getInstance(document, response.getOutputStream());
    document.open();

    document.addTitle("Report Of Rentals");
    document.addSubject("Report");
    document.addKeywords("Report Of Rentals");
    document.addAuthor("Sandy Andryanto");
    document.addCreator("Sandy Andryanto");

    document.add(new Paragraph(" "));
    document.add(new Paragraph(" "));
    document.add(new Paragraph(" REPORT OF RENTALS "));
    document.add(new Paragraph(" "));
    document.add(new Paragraph(" "));

    PdfPTable table = new PdfPTable(6);
    table.addCell("No");
    table.addCell("Date");
    table.addCell("Account Count");
    table.addCell("Movie Count");
    table.addCell("Total Loan");
    table.addCell("Total Returned");

    List<CustomersRentals> list = ReportDao.list(0, maxResults, first, last);
    for (int i = 0; i < list.size(); i++) {
        table.addCell("" + (i + 1));
        table.addCell("" + list.get(i).getDate());
        table.addCell("" + ReportDao.GetReportRentals("" + list.get(i).getDate(), "account_id"));
        table.addCell("" + ReportDao.GetReportRentals("" + list.get(i).getDate(), "movie_id"));
        table.addCell("" + ReportDao.GetReportRentals2("" + list.get(i).getDate(), "loan"));
        table.addCell("" + ReportDao.GetReportRentals2("" + list.get(i).getDate(), "return"));
    }

    document.add(table);
    document.close();

    return "RentalsPDF";
}

From source file:vemo.controller.ReportController.java

@RequestMapping(value = "report/FinancialsPDF", produces = "application/pdf")
@ResponseBody//  w  w w.ja  v  a 2 s  .c o  m
public String FinancialsPDF(ModelMap model, HttpServletResponse response, HttpServletRequest request,
        Integer maxResults, @RequestParam(value = "first", required = false) String first,
        @RequestParam(value = "last", required = false) String last) throws DocumentException, IOException {
    Document document = new Document();
    PdfWriter.getInstance(document, response.getOutputStream());
    document.open();

    document.addTitle("Report Of Financials");
    document.addSubject("Report");
    document.addKeywords("Report Of Financials");
    document.addAuthor("Sandy Andryanto");
    document.addCreator("Sandy Andryanto");

    document.add(new Paragraph(" "));
    document.add(new Paragraph(" "));
    document.add(new Paragraph(" REPORT OF FINANCIALS "));
    document.add(new Paragraph(" "));
    document.add(new Paragraph(" "));

    PdfPTable table = new PdfPTable(5);
    table.addCell("No");
    table.addCell("Date");
    table.addCell("Customer Name");
    table.addCell("Movie Title");
    table.addCell("Amount");

    int SUM = 0;
    List<CustomersRentals> list = ReportDao.list(0, maxResults, first, last);
    for (int i = 0; i < list.size(); i++) {
        table.addCell("" + (i + 1));
        table.addCell("" + list.get(i).getDate());
        table.addCell("" + list.get(i).getRentals().getCustomers().getFullName());
        table.addCell("" + list.get(i).getRentals().getMovies().getTitle());
        table.addCell("" + list.get(i).getAmount());
        SUM += list.get(i).getAmount();
    }

    table.addCell("");
    table.addCell("");
    table.addCell("TOTAL");
    table.addCell("");
    table.addCell("$ " + SUM);

    document.add(table);
    document.close();

    return "RentalsPDF";
}

From source file:wtw.ui.GeneratingPdfAction.java

private static void addMetaData(Document document) {
    document.addTitle("My first PDF");
    document.addSubject("Using iText");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor("Konda Reddy. Lingamdinne");
    document.addCreator("Konda Reddy. Lingamdinne");
}

From source file:za.org.rfm.pdf.EventPDF.java

private static void addMetaData(Document document) {
    document.addTitle("Event report");
    document.addSubject("Test PDF report");
    document.addKeywords("RFM, PDF, iText");
    document.addAuthor("Lars Vogel");
    document.addCreator("Lars Vogel");
}