Example usage for com.itextpdf.text Chunk Chunk

List of usage examples for com.itextpdf.text Chunk Chunk

Introduction

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

Prototype

public Chunk(final DrawInterface separator) 

Source Link

Document

Creates a separator Chunk.

Usage

From source file:mvjce.PDF.java

public static void create(int sino) {// sino = SI.No
    // TODO code application logic here
    try {//from w  w w  . j a  v a2s .  c o  m
        //Create Document instance.
        Document document = new Document();

        //Create OutputStream instance.
        OutputStream outputStream = new FileOutputStream(
                new File("/home/narein/NetBeansProjects/" + sem + cl + "/" + usn + ".pdf"));

        //Create PDFWriter instance.
        PdfWriter.getInstance(document, outputStream);

        //Open the document.
        document.open();
        //image position
        Image imageCenter = Image.getInstance("/home/narein/Downloads/mvj.png");
        //imageCenter.setAlignment(Image.MIDDLE);
        imageCenter.setAbsolutePosition(235, 780);
        imageCenter.scaleAbsolute(146f, 53f);
        //Permanently affiliated para
        PdfPTable table = new PdfPTable(2);
        table.setWidthPercentage(100);
        table.addCell(getCell(
                "\n\n\nPermanently affiliated to VTU, Govt. of Karnataka\nApproved by AICTE, New Delhi\nNear ITPB, Bengaluru- 560067\n\n"
                        + hod_name + ", HOD - " + dep,
                PdfPCell.ALIGN_LEFT));
        table.addCell(getCell("\n\n\n\nPh: 080-42991000\nFax: 080-28452443\nWebsite: www.mvjce.edu.in\nEmail: "
                + hod_email + "\n\n", PdfPCell.ALIGN_RIGHT));
        //line across pdf
        final LineSeparator lineSeparator = new LineSeparator();
        Chunk linebreak = new Chunk(lineSeparator);
        Phrase p = new Phrase("\nPROGRESS REPORT\n",
                new Font(FontFamily.TIMES_ROMAN, 10, Font.UNDERLINE | Font.BOLD));
        Paragraph para = new Paragraph(p);
        para.setAlignment(Element.ALIGN_CENTER);
        Chunk glue = new Chunk(new VerticalPositionMark());
        Paragraph p1 = new Paragraph("\nRef:", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
        p1.add(new Chunk(glue));
        //get current date
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd.MM.yyyy");
        LocalDate localDate = LocalDate.now();
        //add date to pdf
        p1.add(new Phrase("Date: " + dtf.format(localDate) + "\n",
                new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
        Phrase dear_prnts = new Phrase("Dear Parents,\n", new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
        Phrase The_acad = new Phrase(
                "                  The academic performance of your ward Mr/Ms " + name + " of Semester " + sem
                        + " bearing the USN " + usn + " is as follows,\n\n",
                new Font(FontFamily.TIMES_ROMAN, 9));
        Phrase Rem = new Phrase("Remarks\n", new Font(FontFamily.TIMES_ROMAN, 10, Font.UNDERLINE | Font.BOLD));
        Phrase your_ward = new Phrase(
                "\nYour ward's overall performance is Good / Satisfactory / Poor / Very Poor\n",
                new Font(FontFamily.TIMES_ROMAN, 9));
        Phrase you_are = new Phrase("\nYou are requested to:\n",
                new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
        Phrase req = new Phrase("");
        Paragraph para2 = new Paragraph(
                "1) Advice your ward to attend classes regularly\n2) Note that he/she may likely be detainedfrom appearing for examinations\n"
                        + "3) Advice your ward to improve in Test/Exam performance particularly in subject\n4) Meet the Head of the Department\n5) Meet the principal\n",
                new Font(FontFamily.TIMES_ROMAN, 9));
        Chunk glue1 = new Chunk(new VerticalPositionMark());
        Paragraph p3 = new Paragraph("\nSIGNATURE:\n\nNAME OF PROCTOR:\n\nCONTACT NUMBER:",
                new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD));
        p3.add(new Chunk(glue1));
        p3.add(new Phrase(
                "SIGNATURE OF HOD\n\n            Kindly attend the Parent Teacher Meeting to be held on the date informed to your ward.\n",
                new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD)));
        Phrase Note = new Phrase("\nNOTE:", new Font(FontFamily.TIMES_ROMAN, 10, Font.UNDERLINE | Font.BOLD));
        Paragraph p4 = new Paragraph();
        p4.add(Note);
        p4.add(new Phrase(
                "  Parents are requested to contact the proctor (By Email/Letter/Phone) and confirm receipt of this feedback. Parents are also"
                        + "welcome to interact with proctors/subject faculty/ HOD for any discussion/clarification.\n",
                new Font(FontFamily.TIMES_ROMAN, 9)));
        //Add content to the document.
        document.add(imageCenter);
        document.add(table);
        document.add(linebreak);
        document.add(para);
        document.add(p1);
        document.add(dear_prnts);
        document.add(The_acad);
        document.add(createinternalsTable());
        if (internal.equals("1")) {
            document.add(new Phrase("\nPREVIOUS SEMESTER VTU RESULT\n\n",
                    new Font(FontFamily.TIMES_ROMAN, 10, Font.UNDERLINE | Font.BOLD)));
            document.add(createexternalTable());
        }
        document.add(Rem);
        document.add(your_ward);
        document.add(you_are);
        document.add(para2);
        document.add(p3);
        document.add(p4);
        //document.add(paragraph);document.add(paragraph1);

        //Close document and outputStream.
        document.close();
        outputStream.close();

        System.out.println("Pdf created successfully.");
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:nz.ac.waikato.cms.doc.HyperLinkGrades.java

License:Open Source License

/**
 * Adds the index with locations to the existing PDF.
 *
 * @param locations   the locations to index
 * @param input   the input PDF//from  w w w .  j a  v a2s . c o m
 * @param output   the output PDF
 * @return      true if successfully generated
 */
public static boolean addIndex(List<Location> locations, File input, File output) {
    try {
        // copy pages, add target
        PdfReader reader = new PdfReader(input.getAbsolutePath());
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(output.getAbsolutePath()));
        document.open();
        PdfContentByte canvas = writer.getDirectContent();
        PdfImportedPage page;
        float height = 0;
        for (int i = 1; i <= reader.getNumberOfPages(); i++) {
            document.newPage();
            page = writer.getImportedPage(reader, i);
            canvas.addTemplate(page, 1f, 0, 0, 1, 0, 0);
            Chunk loc = new Chunk(" ");
            loc.setLocalDestination("loc" + i);
            height = page.getHeight();
            ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(loc), 50, height - 50, 0);
        }
        // add index
        for (int i = 0; i < locations.size(); i++) {
            Location loc = locations.get(i);
            if (i % MAX_ITEMS_PER_PAGE == 0)
                document.newPage();
            String text = loc.getID() + " " + (loc.getName() == null ? "???" : loc.getName());
            Chunk chunk = new Chunk("Page " + (loc.getPage() + 1) + ": " + text);
            chunk.setAction(PdfAction.gotoLocalPage("loc" + (loc.getPage() + 1), false));
            ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(chunk), 50,
                    height - 100 - (i % MAX_ITEMS_PER_PAGE) * 20, 0);
        }
        document.close();

        return true;
    } catch (Exception e) {
        System.err.println("Failed to overlay locations!");
        e.printStackTrace();
        return false;
    }
}

From source file:opticalworkshopmonitoringsystem.CenteringAndEdgingView.java

License:Open Source License

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    //code for the forating of the pdf report.

    try {//from   www.  ja va 2 s  . co m
        Document document = new Document();
        JFileChooser fc = new JFileChooser();
        fc.showOpenDialog(null);

        PdfWriter.getInstance(document, new FileOutputStream(fc.getSelectedFile().getAbsolutePath()));
        document.open();

        Font courierFontItalic = new Font(Font.FontFamily.COURIER, 10, Font.ITALIC);
        Font courierFontUnderline = new Font(Font.FontFamily.COURIER, 10, Font.UNDERLINE);
        Font tr = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        Font timesRomanUnderline = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.UNDERLINE);
        Font helvetica = new Font(Font.FontFamily.HELVETICA, 14, Font.UNDERLINE);

        document.add(new Paragraph(
                "                         Centering And Edging Division                            ",
                timesRomanUnderline));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel1.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField1.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel2.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField2.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel3.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField3.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel4.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField4.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel5.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField5.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel6.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField6.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel7.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField7.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel8.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField8.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel9.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField9.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel10.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField10.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel11.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField11.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel12.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField12.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel13.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField13.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "      Prepared by                                   Checked by                                       Approved by                  "));

        document.close();
        JOptionPane.showMessageDialog(null, "report generated successfully");
    } catch (DocumentException ex) {
        Logger.getLogger(CenteringAndEdgingView.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(CenteringAndEdgingView.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:opticalworkshopmonitoringsystem.GrindingDivisionView.java

License:Open Source License

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    try {//from w ww  .j  a  v a2s.  co m
        Document document = new Document();
        JFileChooser fc = new JFileChooser();
        fc.showOpenDialog(null);

        PdfWriter.getInstance(document, new FileOutputStream(fc.getSelectedFile().getAbsolutePath()));
        document.open();

        Font courierFontItalic = new Font(Font.FontFamily.COURIER, 10, Font.ITALIC);
        Font courierFontUnderline = new Font(Font.FontFamily.COURIER, 10, Font.UNDERLINE);
        Font tr = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        Font timesRomanUnderline = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.UNDERLINE);
        Font helvetica = new Font(Font.FontFamily.HELVETICA, 14, Font.UNDERLINE);

        document.add(new Paragraph(
                "                                 Grinding Division                                         ",
                timesRomanUnderline));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel2.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField2.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel3.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField3.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel1.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField1.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel4.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField4.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel5.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField23.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel6.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField24.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel7.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField25.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel8.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField26.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Slicing Operation                        ", helvetica));

        document.add(new Paragraph(jLabel9.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField27.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel11.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField28.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel10.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField29.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel23.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField30.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel24.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField31.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Trepening Operation                        ", helvetica));

        document.add(new Paragraph(jLabel15.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField19.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel17.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField20.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel28.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField21.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel29.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField22.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel30.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField32.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Curve Generation Operation                        ", helvetica));

        document.add(new Paragraph(jLabel12.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField5.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel13.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField6.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel14.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField7.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel25.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField16.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel26.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField17.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel27.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField18.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(
                new Paragraph("          Grinding and Smoothing Operation                        ", helvetica));

        document.add(new Paragraph(jLabel38.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField43.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel39.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField44.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel40.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField45.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel41.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField46.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel42.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField47.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel43.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField48.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel44.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField49.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Inspection Details                        ", helvetica));

        document.add(new Chunk("                                                      Specified"));
        document.add(new Chunk("                                            Measured"));
        document.add(new Paragraph(jLabel16.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField8.getText()));
        document.add(
                new Chunk("                                                      " + jTextField12.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel18.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField9.getText()));
        document.add(
                new Chunk("                                                      " + jTextField15.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel19.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField10.getText()));
        document.add(
                new Chunk("                                                        " + jTextField13.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Angles                        ", helvetica));

        document.add(new Paragraph(jLabel32.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField11.getText()));
        document.add(
                new Chunk("                                                        " + jTextField14.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel33.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField33.getText()));
        document.add(
                new Chunk("                                                      " + jTextField38.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel34.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField34.getText()));
        document.add(
                new Chunk("                                                      " + jTextField39.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel35.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField35.getText()));
        document.add(
                new Chunk("                                                        " + jTextField40.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel36.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField37.getText()));
        document.add(
                new Chunk("                                                        " + jTextField41.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel37.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField36.getText()));
        document.add(
                new Chunk("                                                        " + jTextField42.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel45.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField50.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel46.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField51.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel47.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField52.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel48.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField53.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "      Prepared by                                   Checked by                                       Approved by                  "));

        document.close();
        JOptionPane.showMessageDialog(null, "report generated successfully");
    } catch (DocumentException ex) {
        Logger.getLogger(GrindingDivisionView.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(GrindingDivisionView.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:opticalworkshopmonitoringsystem.PolishingDivisionView.java

License:Open Source License

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

    try {//from w  w w .  j  a  v  a 2 s. c o  m
        // TODO add your handling code here:

        Document document = new Document();
        JFileChooser fc = new JFileChooser();
        fc.showOpenDialog(null);

        PdfWriter.getInstance(document, new FileOutputStream(fc.getSelectedFile().getAbsolutePath()));
        document.open();

        Font courierFontItalic = new Font(Font.FontFamily.COURIER, 10, Font.ITALIC);
        Font courierFontUnderline = new Font(Font.FontFamily.COURIER, 10, Font.UNDERLINE);
        Font tr = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
        Font timesRomanUnderline = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.UNDERLINE);
        Font helvetica = new Font(Font.FontFamily.HELVETICA, 14, Font.UNDERLINE);

        document.add(new Paragraph(
                "                                 Polishing Division                                         ",
                timesRomanUnderline));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(jLabel1.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField1.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel2.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField2.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel3.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField3.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Polisher Details                        ", helvetica));

        document.add(new Paragraph(jLabel4.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField4.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel5.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField5.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel6.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField6.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel7.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField7.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel8.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField8.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel9.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField9.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(
                new Paragraph("          Polishing Material(Processing)                        ", helvetica));

        document.add(new Paragraph(jLabel10.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField10.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel11.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField11.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel12.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField12.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel13.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField13.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel14.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField14.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Polishing Iteration                        ", helvetica));

        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel17.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField18.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel18.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField19.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph("          Final Inspection                        ", helvetica));

        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel23.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField23.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel24.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField24.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel25.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField25.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel26.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField26.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph(jLabel27.getText(), tr));
        document.add(
                new Chunk("                                                      " + jTextField27.getText()));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));

        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "                                                                                                                                  "));
        document.add(new Paragraph(
                "      Prepared by                                   Checked by                                       Approved by                  "));

        document.close();
        JOptionPane.showMessageDialog(null, "report generated successfully");
    } catch (DocumentException ex) {
        Logger.getLogger(PolishingDivisionView.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(PolishingDivisionView.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:org.fatec.lpbd.projetocurriculo.controller.CurriculoHelper.java

public static Chunk lineSeparator() {
    LineSeparator ls = new LineSeparator();
    return (new Chunk(ls));
}

From source file:org.openlmis.web.view.pdf.requisition.RequisitionPdfModel.java

License:Open Source License

private void insertCell(PdfPTable table, String text, int colSpan) {
    Chunk chunk;/*ww  w . ja  va2s  .  c  o  m*/
    chunk = new Chunk(text);
    PdfPCell cell = table.getDefaultCell();
    cell.setPhrase(new Phrase(chunk));
    cell.setColspan(colSpan);
    table.addCell(cell);
}

From source file:org.openmrs.module.laboratorymanagement.db.hibernate.LaboratoryDAOimpl.java

License:Open Source License

public void exportPatientReportToPDF(HttpServletRequest request, HttpServletResponse response,
        Map<ConceptName, List<Object[]>> mappedLabExam, String filename, String title, int patientId)
        throws DocumentException, IOException {

    Document document = new Document();
    Patient patient = Context.getPatientService().getPatient(patientId);
    // List<PatientBill> patientBills =
    // (List<PatientBill>)request.getAttribute("reportedPatientBillsPrint");

    /*//from   w w w.  j  a  va2 s .c o  m
     * PatientBill pb = null;
     * 
     * pb = Context.getService(BillingService.class).getPatientBill(
     * Integer.parseInt(request.getParameter("patientBills")));
     */
    /*
     * String filename = pb.getBeneficiary().getPatient().getPersonName()
     * .toString().replace(" ", "_"); filename =
     * pb.getBeneficiary().getPolicyIdNumber().replace(" ", "_") + "_" +
     * filename + ".pdf";
     */
    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition", "report"); // file name

    PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
    writer.setBoxSize("art", new Rectangle(0, 0, 2382, 3369));
    writer.setBoxSize("art", PageSize.A4);

    HeaderFooterMgt event = new HeaderFooterMgt();
    writer.setPageEvent(event);

    document.open();
    document.setPageSize(PageSize.A4);
    // document.setPageSize(new Rectangle(0, 0, 2382, 3369));

    document.addAuthor(Context.getAuthenticatedUser().getPersonName().toString());// the name of the author

    FontSelector fontTitle = new FontSelector();
    fontTitle.addFont(new Font(FontFamily.COURIER, 10.0f, Font.ITALIC));

    // Report title
    Chunk chk = new Chunk("Printed on : " + (new SimpleDateFormat("dd-MMM-yyyy").format(new Date())));
    chk.setFont(new Font(FontFamily.COURIER, 10.0f, Font.BOLD));
    Paragraph todayDate = new Paragraph();
    todayDate.setAlignment(Element.ALIGN_RIGHT);
    todayDate.add(chk);
    document.add(todayDate);
    document.add(fontTitle.process("REPUBLIQUE DU RWANDA\n"));
    document.add(fontTitle.process("POLICE NATIONALE\n"));
    document.add(fontTitle.process("KACYIRU POLICE HOSPITAL\n"));
    document.add(fontTitle.process("B.P. 6183 KIGALI\n"));
    document.add(fontTitle.process("Tl : 584897\n"));
    document.add(fontTitle.process("E-mail : medical@police.gov.rw"));
    // End Report title

    document.add(new Paragraph("\n"));
    chk = new Chunk("Laboratory results");
    chk.setFont(new Font(FontFamily.COURIER, 10.0f, Font.BOLD));
    chk.setUnderline(0.2f, -2f);
    Paragraph pa = new Paragraph();
    pa.add(chk);
    pa.setAlignment(Element.ALIGN_CENTER);
    document.add(pa);
    document.add(new Paragraph("\n"));

    document.add(fontTitle.process("Family Name: " + patient.getFamilyName() + "\n"));
    document.add(fontTitle.process("Given name: " + patient.getGivenName() + "\n"));
    document.add(fontTitle.process("Age: " + patient.getAge() + "\n"));

    // title row
    FontSelector fontTitleSelector = new FontSelector();
    fontTitleSelector.addFont(new Font(FontFamily.COURIER, 9, Font.ITALIC));
    // Table of identification;
    PdfPTable table = null;
    table = new PdfPTable(2);
    table.setWidthPercentage(100f);

    // tableHeader.addCell(table);

    // document.add(tableHeader);

    document.add(new Paragraph("\n"));

    // Table of lab report items;
    float[] colsWidth = { 6f, 3f, 6f };
    table = new PdfPTable(colsWidth);
    table.setWidthPercentage(100f);
    BaseColor bckGroundTitle = new BaseColor(170, 170, 170);
    BaseColor bckGroundTitl = new BaseColor(Color.yellow);

    // table Header
    PdfPCell cell = new PdfPCell(fontTitleSelector.process("Exam"));

    cell.setBackgroundColor(bckGroundTitle);

    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process("Result"));
    cell.setBackgroundColor(bckGroundTitle);

    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process("Normal Range"));
    cell.setBackgroundColor(bckGroundTitle);
    table.addCell(cell);
    /*
     * cell = new PdfPCell(fontTitleSelector.process("Date "));
     * cell.setBackgroundColor(bckGroundTitle); table.addCell(cell);
     */

    // normal row
    FontSelector fontselector = new FontSelector();
    fontselector.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL));

    // empty row
    FontSelector fontTotals = new FontSelector();
    fontTotals.addFont(new Font(FontFamily.COURIER, 9, Font.BOLD));

    // ===========================================================
    for (ConceptName cptName : mappedLabExam.keySet()) {

        cell = new PdfPCell(fontTitleSelector.process("" + cptName));
        cell.setBackgroundColor(bckGroundTitl);

        table.addCell(cell);
        cell = new PdfPCell(fontTitleSelector.process(""));
        table.addCell(cell);
        cell = new PdfPCell(fontTitleSelector.process(""));
        table.addCell(cell);

        List<Object[]> labExamHistory = mappedLabExam.get(cptName);
        for (Object[] labExam : labExamHistory) {
            // table Header
            // Object[] labe = listOflabtest.get(i);
            Obs ob = (Obs) labExam[0];
            cell = new PdfPCell(fontTitleSelector.process("" + ob.getConcept().getName()));

            table.addCell(cell);
            if (ob.getConcept().getDatatype().isNumeric()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueNumeric()));
                table.addCell(cell);

            }

            if (ob.getConcept().getDatatype().isCoded()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueCoded().getName()));
                table.addCell(cell);

            }

            if (ob.getConcept().getDatatype().isText()) {
                cell = new PdfPCell(fontTitleSelector.process("" + ob.getValueText()));
                table.addCell(cell);

            }

            cell = new PdfPCell(fontTitleSelector.process("" + (labExam[1] != null ? labExam[1] : "-")));
            table.addCell(cell);

            fontselector.addFont(new Font(FontFamily.COURIER, 8, Font.NORMAL));

            // empty row
            // FontSelector fontTotals = new FontSelector();
            fontTotals.addFont(new Font(FontFamily.COURIER, 9, Font.BOLD));

        }

    }

    cell = new PdfPCell(fontTitleSelector.process("Names, Signature et Stamp of Lab Chief\n"
            //+ Context.getAuthenticatedUser().getPersonName()));
            + Context.getUserService().getUser(140).getPersonName()));

    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);
    // ================================================================
    table.addCell(cell);

    document.add(table);

    // Table of signatures;
    table = new PdfPTable(2);
    table.setWidthPercentage(100f);

    cell = new PdfPCell(fontTitleSelector.process(" "));

    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell(fontTitleSelector.process(
            "Names, Signature and  Stamp of Provider\n" + Context.getAuthenticatedUser().getPersonName()));
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);
    document.add(table);
    document.close();

    document.close();
}

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

private void addTopTable(Section subCatPart, Json data) throws DocumentException {
    PdfPTable table = new PdfPTable(4);
    table.setWidthPercentage(100);//from   w w  w  .  j  a  v  a2  s .c om
    int[] widths = { 12, 55, 15, 20 };
    table.setWidths(widths);

    PdfPCell cell = null;

    OWLNamedIndividual typeInd = individual(legacyPrefix + data.at("type").asString());
    addCell(cell, table, "Type:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, getEntityLabel(typeInd), Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "SR #:", Element.ALIGN_RIGHT, boldFont, null);
    if (data.at("properties").has("hasCaseNumber"))
        addCell(cell, table, data.at("properties").at("hasCaseNumber").asString(), Element.ALIGN_LEFT,
                normalFont, null);
    else
        addCell(cell, table, GenUtils.makeCaseNumber(data.at("boid").asLong()), Element.ALIGN_LEFT, normalFont,
                null);
    //02-20-2014 - Syed add providedby to report
    addCell(cell, table, "Area:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, getArea(typeInd), Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "Priority:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, data.at("properties").at("hasPriority").at("label").asString(), Element.ALIGN_LEFT,
            normalFont, null);
    addCell(cell, table, "Group:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, getGroup(typeInd), Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "Status:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, getEntityLabel(individual(data.at("properties"), "hasStatus")), Element.ALIGN_LEFT,
            normalFont, null);

    addCell(cell, table, "Jurisdiction:", Element.ALIGN_RIGHT, boldFont, null);
    OWLLiteral jurisdiction = dataProperty(typeInd, legacyPrefix + "hasJurisdictionDescription");
    addCell(cell, table, jurisdiction != null ? jurisdiction.getLiteral() : emptyField, Element.ALIGN_LEFT,
            normalFont, null);
    addCell(cell, table, "Status Date:", Element.ALIGN_RIGHT, boldFont, null);
    String modifiedDate = data.at("properties").has("hasDateLastModified")
            ? data.at("properties").at("hasDateLastModified").asString()
            : "";
    addCell(cell, table, formatDate(modifiedDate, true, false), Element.ALIGN_LEFT, normalFont, null);

    addCell(cell, table, "Input By:", Element.ALIGN_RIGHT, boldFont, null);
    String inputBy = data.at("properties").has("isCreatedBy")
            ? data.at("properties").at("isCreatedBy").asString()
            : emptyField;
    addCell(cell, table, inputBy, Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "Created Date:", Element.ALIGN_RIGHT, boldFont, null);
    String createdDate = data.at("properties").has("hasDateCreated")
            ? data.at("properties").at("hasDateCreated").asString()
            : "";
    addCell(cell, table, formatDate(createdDate, true, false), Element.ALIGN_LEFT, normalFont, null);

    addCell(cell, table, "CC Groups:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, blankField, Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "Created By:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, getEmployeeName(inputBy), Element.ALIGN_LEFT, normalFont, null);

    addCell(cell, table, "Location:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table,
            data.at("properties").has("atAddress") ? buildAddress(data.at("properties").at("atAddress"))
                    : blankField,
            Element.ALIGN_LEFT, normalFont, null);
    addCell(cell, table, "Method Received:", Element.ALIGN_RIGHT, boldFont, null);
    addCell(cell, table, data.at("properties").at("hasIntakeMethod").at("label").asString(), Element.ALIGN_LEFT,
            normalFont, null);

    subCatPart.add(table);
    subCatPart.add(new Chunk(new LineSeparator()));
}

From source file:org.sharegov.cirm.utils.PDFViewReport.java

License:Apache License

private void addDescription(Section subCatPart, Json data) throws DocumentException {
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);/*from  ww w.  ja va  2  s  .c o m*/
    int[] widths = { 15, 85 };
    table.setWidths(widths);

    PdfPCell cell = null;

    addCell(cell, table, "Description:", Element.ALIGN_LEFT, bigBoldFont, null);
    if (data.at("properties").has("hasDetails"))
        addCell(cell, table, data.at("properties").at("hasDetails").asString(), Element.ALIGN_LEFT, normalFont,
                null);

    subCatPart.add(table);
    subCatPart.add(new Chunk(new LineSeparator()));
}