Example usage for com.itextpdf.text Document addCreator

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

Introduction

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

Prototype


public boolean addCreator(String creator) 

Source Link

Document

Adds the creator to a Document.

Usage

From source file:Utility.PDFDemo.java

public void cretePDF(String name, String rpor) throws FileNotFoundException {

    try {//from  ww  w  .  j a v a2s .  com

        //Create document for pdf
        Document doc = new Document();

        //PDF writer to write into document
        PdfWriter docwriter = null;

        DecimalFormat df = new DecimalFormat("0.00");

        try {
            // //file path
            //String path = "docs/" + name;
            docwriter = PdfWriter.getInstance(doc, new FileOutputStream(rpor + ".pdf"));
        } catch (DocumentException ex) {
            Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
        }

        //document header attributes
        doc.addAuthor("CHED CU");
        doc.addCreationDate();
        doc.addProducer();
        doc.addCreator("Grant Monitor");
        doc.addTitle(rpor);
        doc.setPageSize(PageSize.A4.rotate()); //This sets page size to A4 and orientation to Landscape
        //doc.setPageSize(PageSize.A4);
        doc.setMargins(30f, 30f, 20f, 20f);

        //open document
        doc.open();

        //Creating a paragraphs and chunks
        Paragraph pp = new Paragraph("Cocoa Health And Extension", forTitle);
        pp.setAlignment(Element.ALIGN_CENTER);

        Paragraph palaglapgh = new Paragraph("(Cocobod)", bfBold12);
        palaglapgh.setAlignment(Element.ALIGN_CENTER);

        Chunk chk = new Chunk("From GIS Office, Accra", bfBold12);
        chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position
        Paragraph underText = new Paragraph(chk);
        underText.setAlignment(Element.ALIGN_CENTER);

        Chunk chuk1 = new Chunk("Lot No:", bfBold12);
        chuk1.setUnderline(.1f, -2f);
        Chunk chuk2 = new Chunk(name, bfBold12);

        Paragraph regionText = new Paragraph(rpor, bfBold12);
        regionText.setAlignment(Element.ALIGN_CENTER);
        String rporx = "";
        //            ResultSet dir = manager.PDFdemos(name);
        //            try {
        //                if (dir.next()) {
        //                    rporx = dir.getString(12);
        //
        //                }
        //            } catch (SQLException ex) {
        //                Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
        //            }

        Paragraph regionTexts = new Paragraph(rporx, bfBold12);
        regionText.setAlignment(Element.ALIGN_CENTER);
        //add the PDF table to the paragraph
        //palaglapgh.add(table);
        //Table Generation block
        regionText.add(reports());

        //SECTION TO ADD ELEMENTS TO PDF
        // add the paragraph to the document
        doc.add(pp);
        //doc.add(Chunk.NEWLINE);       //Adds a new blank line
        doc.add(palaglapgh);
        doc.add(underText);

        doc.add(chuk1);
        doc.add(chuk2);

        //Current Date and time insertion
        Paragraph newDate = new Paragraph(new Date().toString(), bf12);
        newDate.setAlignment(Element.ALIGN_RIGHT);
        doc.add(newDate);
        doc.add(regionTexts);
        doc.add(regionText);

        //close the document
        doc.close();

        //close the writer
        docwriter.close();

    } catch (DocumentException ex) {
        Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:vemo.controller.ReportController.java

@RequestMapping(value = "report/RentalsPDF", produces = "application/pdf")
@ResponseBody// w  ww  .  j a  v a  2  s .  c  o m
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/*from ww  w  .j  a  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");
}