Example usage for com.itextpdf.kernel.geom PageSize A4

List of usage examples for com.itextpdf.kernel.geom PageSize A4

Introduction

In this page you can find the example usage for com.itextpdf.kernel.geom PageSize A4.

Prototype

PageSize A4

To view the source code for com.itextpdf.kernel.geom PageSize A4.

Click Source Link

Usage

From source file:com.asptt.plongee.resa.util.UtilsFSpdf.java

public Document createPdfFS(String dest, FicheSecurite fs)
            throws IOException, FileNotFoundException, java.io.IOException {
        PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
        PageSize ps = PageSize.A4.rotate();
        //calcul du nombre de page (si + de 8 palanques => 2 pages)
        int nbPage = 1;
        if (fs.getPalanques().size() > 8) {
            nbPage = 2;/*from   w ww.  j av a 2 s .c om*/
        }
        pdfDoc.addNewPage(ps);
        Document doc = new Document(pdfDoc);
        Table entete = createEntete(fs, 1, nbPage);
        doc.add(entete);

        // style pour les plongeurs
        Style s_plongeur = new Style();
        PdfFont fontPlongeur = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
        s_plongeur.setFont(fontPlongeur).setFontSize(10);
        s_plongeur.setFontColor(Color.BLACK);
        // Deuxieme table pour les palanques 
        Table tablePalanques = new Table(4);
        for (int i = 0; i < 8; i++) {
            createTablePlongeur(tablePalanques, fs, i, s_plongeur);
        }
        doc.add(tablePalanques);
        if (nbPage == 2) {
            Table tablePalanques2 = new Table(4);
            pdfDoc.addNewPage(ps);
            Table entete2 = createEntete(fs, 2, nbPage);
            doc.add(entete2);
            for (int i = 8; i < 16; i++) {
                createTablePlongeur(tablePalanques2, fs, i, s_plongeur);
            }
            doc.add(tablePalanques2);
        }
        doc.close();
        return doc;
    }

From source file:com.asptt.plongee.resa.util.UtilsFSpdf.java

public void createPdfPlongee(String dest, Plongee plongee)
            throws IOException, FileNotFoundException, java.io.IOException {
        PageSize ps = PageSize.A4.rotate();
        PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
        pdfDoc.addNewPage(ps);//  w  ww .j a  v a2 s .c o  m
        Document doc = new Document(pdfDoc);
        float[] columnWidths = { 20, 20, 5, 10, 15, 15, 15 };
        // table : premiere table pour les parametres de la plonge
        Table table = new Table(columnWidths);
        table.setMargins(0, 0, 0, 0);
        table.setWidthPercent(100);
        // entete style pour les titres
        Style s_titre = new Style();
        PdfFont fontEntete = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
        s_titre.setFont(fontEntete).setFontSize(12);
        s_titre.setFontColor(Color.ORANGE);
        // style pour l'entete de la table
        Style s_entete = new Style();
        PdfFont fontLibelle = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
        s_entete.setFont(fontLibelle).setFontSize(12);
        s_entete.setFontColor(Color.BLUE);

        Paragraph entete1 = new Paragraph();
        entete1.add(new Text("Plong\u00e9e du " + ResaUtil.getJourDatePlongee(plongee.getDatePlongee()) + "    '"
                + ResaUtil.getHeurePlongee(plongee.getDatePlongee()) + "'\n").addStyle(s_titre));
        entete1.add(
                new Text("Nombre de participants " + plongee.getParticipants().size() + "\n").addStyle(s_titre));
        entete1.add(new Text("\n").addStyle(s_titre));
        entete1.add(new Text("Inscrit\n").addStyle(s_titre));

        Cell cellEntete1 = new Cell(1, 7);
        cellEntete1.add(entete1);
        cellEntete1.setBorderRight(Border.NO_BORDER);
        //        cellEntete1.setBackgroundColor(Color.BLUE);
        cellEntete1.setHorizontalAlignment(HorizontalAlignment.LEFT);
        table.addCell(cellEntete1);

        Cell cellNom = new Cell().add(new Paragraph("Nom"));
        cellNom.setTextAlignment(TextAlignment.CENTER);
        cellNom.setFontSize(8);
        cellNom.setFontColor(Color.BLACK);
        cellNom.setPadding(5);
        cellNom.setBackgroundColor(new DeviceRgb(140, 221, 8));
        table.addCell(cellNom);

        Cell cellPrenom = new Cell().add(new Paragraph("Prnom"));
        cellPrenom.setTextAlignment(TextAlignment.CENTER);
        cellPrenom.setFontSize(8);
        cellPrenom.setFontColor(Color.BLACK);
        cellPrenom.setPadding(5);
        cellPrenom.setBackgroundColor(new DeviceRgb(140, 221, 8));
        table.addCell(cellPrenom);

        Cell cellNiveau = new Cell().add(new Paragraph("Niveau"));
        cellNiveau.setTextAlignment(TextAlignment.CENTER);
        cellNiveau.setFontSize(8);
        cellNiveau.setFontColor(Color.BLACK);
        cellNiveau.setPadding(5);
        cellNiveau.setBackgroundColor(new DeviceRgb(140, 221, 8));
        table.addCell(cellNiveau);

        Cell cellAptitude = new Cell().add(new Paragraph("Aptitude"));
        cellAptitude.setTextAlignment(TextAlignment.CENTER);
        cellAptitude.setFontSize(8);
        cellAptitude.setFontColor(Color.BLACK);
        cellAptitude.setPadding(5);
        cellAptitude.setBackgroundColor(new DeviceRgb(140, 221, 8));
        table.addCell(cellAptitude);

        Cell cellTelephone1 = new Cell().add(new Paragraph("Tlphone"));
        cellTelephone1.setTextAlignment(TextAlignment.CENTER);
        cellTelephone1.setFontSize(8);
        cellTelephone1.setFontColor(Color.BLACK);
        cellTelephone1.setPadding(5);
        cellTelephone1.setBackgroundColor(new DeviceRgb(140, 221, 8));
        table.addCell(cellTelephone1);

        Cell cellCommentaire = new Cell().add(new Paragraph("Commentaire"));
        cellCommentaire.setTextAlignment(TextAlignment.CENTER);
        cellCommentaire.setFontSize(8);
        cellCommentaire.setFontColor(Color.BLACK);
        cellCommentaire.setPadding(5);
        cellCommentaire.setBackgroundColor(new DeviceRgb(140, 221, 8));
        table.addCell(cellCommentaire);

        List<Adherent> adherentsInscrit = plongee.getParticipants();

        for (Adherent adherent : adherentsInscrit) {
            Cell cellNomP = new Cell().add(new Paragraph(adherent.getNom()));
            cellNomP.setTextAlignment(TextAlignment.CENTER);
            cellNomP.setFontSize(8);
            cellNomP.setFontColor(Color.BLACK);
            cellNomP.setPadding(5);
            cellNomP.setBackgroundColor(new DeviceRgb(140, 221, 8));
            table.addCell(cellNomP);

            Cell cellPrenomP = new Cell().add(new Paragraph(adherent.getPrenom()));
            cellPrenomP.setTextAlignment(TextAlignment.CENTER);
            cellPrenomP.setFontSize(8);
            cellPrenomP.setFontColor(Color.BLACK);
            cellPrenomP.setPadding(5);
            cellPrenomP.setBackgroundColor(new DeviceRgb(140, 221, 8));
            table.addCell(cellPrenomP);

            // Ds que le plongeur est encadrant, on affiche son niveau d'encadrement
            String niveauAffiche = adherent.getPrerogative();
            // Pour les externes, le niveau est suffix par (Ext.)
            if (adherent.getActifInt() == 2) {
                niveauAffiche = niveauAffiche + " (Ext.)";
            }
            Cell cellNiveauP = new Cell().add(new Paragraph(niveauAffiche));
            cellNiveauP.setTextAlignment(TextAlignment.CENTER);
            cellNiveauP.setFontSize(8);
            cellNiveauP.setFontColor(Color.BLACK);
            cellNiveauP.setPadding(5);
            cellNiveauP.setBackgroundColor(new DeviceRgb(140, 221, 8));
            table.addCell(cellNiveauP);

            Cell cellAptitudeP;
            if (null == adherent.getAptitude()) {
                cellAptitudeP = new Cell().add(new Paragraph("  "));
            } else {
                cellAptitudeP = new Cell().add(new Paragraph(adherent.getAptitude().getText()));
            }
            cellAptitudeP.setTextAlignment(TextAlignment.CENTER);
            cellAptitudeP.setFontSize(8);
            cellAptitudeP.setFontColor(Color.BLACK);
            cellAptitudeP.setPadding(5);
            cellAptitudeP.setBackgroundColor(new DeviceRgb(140, 221, 8));
            table.addCell(cellAptitudeP);

            Cell cellTelephone1P = new Cell().add(new Paragraph(adherent.getTelephone()));
            cellTelephone1P.setTextAlignment(TextAlignment.CENTER);
            cellTelephone1P.setFontSize(8);
            cellTelephone1P.setFontColor(Color.BLACK);
            cellTelephone1P.setPadding(5);
            cellTelephone1P.setBackgroundColor(new DeviceRgb(140, 221, 8));
            table.addCell(cellTelephone1P);

            Cell cellCommentaireP = new Cell().add(new Paragraph(adherent.getCommentaire()));
            cellCommentaireP.setTextAlignment(TextAlignment.CENTER);
            cellCommentaireP.setFontSize(8);
            cellCommentaireP.setFontColor(Color.BLACK);
            cellCommentaireP.setPadding(5);
            cellCommentaireP.setBackgroundColor(new DeviceRgb(140, 221, 8));
            table.addCell(cellCommentaireP);

        }
        doc.add(table);
        doc.close();
    }

From source file:com.isw.cec.Servlet.GenerarFoliosServlet.java

License:Open Source License

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String appPath = request.getServletContext().getRealPath("");
    String savePath = appPath + File.separator + SAVE_DIR;

    File fileSaveDir = new File(savePath);
    if (!fileSaveDir.exists())
        fileSaveDir.mkdirs();//from   w  ww.ja v a2 s  .  c  om

    String fileName = java.util.UUID.randomUUID().toString() + ".pdf";
    Curso curso = (Curso) request.getAttribute("curso");
    List<Entry<String, String>> alum_fol = Reader.getAlumFolios(curso.getID());

    OutputStream fos = new FileOutputStream(savePath + File.separator + fileName);
    PdfWriter writer = new PdfWriter(fos);

    PdfDocument pdf = new PdfDocument(writer);

    Document document = new Document(pdf, PageSize.A4);
    document.setMargins(85, 57, 71, 71);

    PdfFont font = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
    PdfFont bold = PdfFontFactory.createFont(FontConstants.TIMES_BOLD);

    Paragraph p = new Paragraph("Folios de los alumnos inscritos al curso");
    p.setTextAlignment(TextAlignment.CENTER);
    document.add(p);

    p = new Paragraph(curso.getNombre());
    p.setFont(bold);
    p.setTextAlignment(TextAlignment.CENTER);
    p.setMarginBottom(70);
    document.add(p);

    Table table = new Table(new float[] { 1, 1 });
    table.setWidthPercent(100);

    Cell c = new Cell().add(new Paragraph("ALUMNO").setFont(bold));
    c.setTextAlignment(TextAlignment.CENTER);
    table.addHeaderCell(c);

    c = new Cell().add(new Paragraph("FOLIO").setFont(bold));
    c.setTextAlignment(TextAlignment.CENTER);
    table.addHeaderCell(c);

    for (Entry<String, String> e : alum_fol) {
        table.addCell(new Cell().add(new Paragraph(e.getKey()).setFont(font)));
        table.addCell(new Cell().add(new Paragraph(e.getValue()).setFont(font)));
    }

    document.add(table);

    document.close();

    Writer.openCurso(curso.getID(), fileName);
    response.getWriter().println("OK");
}

From source file:machinetoolstore.core.util.PdfGenerator.java

public static boolean getGeneratedPdfByArtifact(ThreeRollMill artifact, String fileName) throws Exception {
    PdfWriter writer = new PdfWriter(GENERATED_FILES_PATH + fileName);
    PdfDocument pdfDocument = new PdfDocument(writer);
    Document document = new Document(pdfDocument, PageSize.A4);

    document.setMargins(15, 15, 15, 40);
    PdfFont mainFont = PdfFontFactory.createFont(FONTS_PATH + "calibril.ttf", "cp1251", false);

    //Header/*  ww w . j  a  v  a2s  .c om*/
    Paragraph headerParagraph = new Paragraph(artifact.getBrand() + " " + artifact.getModel());
    headerParagraph.setItalic();
    headerParagraph.setTextAlignment(TextAlignment.CENTER);
    headerParagraph.setFont(mainFont);
    headerParagraph.setFontSize(20);
    document.add(headerParagraph);

    //Image block witch characteristic
    Table table = new Table(3);
    table.setWidthPercent(100);

    //Image cell
    Cell imageCell = new Cell();
    imageCell.setBorder(Border.NO_BORDER);
    Image machineImage = new Image(ImageDataFactory.create(IMAGE_PATH + artifact.getMainPhoto()));
    machineImage.setWidth(100);
    machineImage.setHeight(100);
    imageCell.add(machineImage);

    //Main characteristic cell
    Cell mainCharacteristicCell = new Cell();
    List mainCharacteristicList = new List().setSymbolIndent(5).setListSymbol("\uFFFF").setFont(mainFont)
            .setFontSize(12);
    mainCharacteristicList.add("ID:").add(":").add(" ?:")
            .add("?:").add("??:").add(", $:");
    mainCharacteristicCell.add(mainCharacteristicList);

    Cell valuesCell = new Cell();
    List valuesList = new List().setSymbolIndent(5).setListSymbol("\uFFFF").setFont(mainFont).setFontSize(12);
    valuesList.add(artifact.getId().toString()).add(artifact.getManufacturer())
            .add(artifact.getYearOfIssue().toString()).add(artifact.getLocation())
            .add(artifact.getMachineState()).add(artifact.getMachinePrice().toString());
    valuesCell.add(valuesList);

    table.addCell(imageCell);
    table.addCell(mainCharacteristicCell);
    table.addCell(valuesCell);

    //Paragraph
    Paragraph contentParagraph = new Paragraph("? ?");
    contentParagraph.setItalic();
    contentParagraph.setTextAlignment(TextAlignment.CENTER);
    contentParagraph.setFont(mainFont);
    contentParagraph.setFontSize(14);
    contentParagraph.setFixedPosition(1, 635, 600);
    document.add(contentParagraph);

    //Main table
    Table mainTable = new Table(2);
    mainTable.setFont(mainFont);
    mainTable.setFontSize(10);
    mainTable.setMarginTop(35);
    mainTable.addCell(" ?").addCell(artifact.getType());
    mainTable.addCell(" , ")
            .addCell(artifact.getMaterialThickness().toString());
    mainTable.addCell(" , ").addCell(artifact.getMaterialWidth().toString());
    mainTable.addCell("? , /").addCell(artifact.getBendingSpeed().toString());
    mainTable.addCell("Min   max ?, ")
            .addCell(artifact.getMinDiameterMaxBend().toString());
    mainTable.addCell("  , ")
            .addCell(artifact.getTopRollDiameter().toString());
    mainTable.addCell(" ? , ")
            .addCell(artifact.getMiddleRollDiameter().toString());
    mainTable.addCell("???   ? , ")
            .addCell(artifact.getDistanceOfBottomTwoRolls().toString());
    mainTable.addCell(
            "?  ? ?  ?, ")
            .addCell(artifact.getMaterialProofStress().toString());
    mainTable.addCell("?  ?, ")
            .addCell(artifact.getMainEnginePower().toString());
    mainTable.addCell(" , ").addCell(artifact.getMachineDimensions());
    mainTable.addCell("? ?, ").addCell(artifact.getMachineWeight().toString());
    mainTable.addCell("?").addCell(artifact.getDescription());

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

    return true;
}

From source file:model.PrintPDF.java

public void inThongKeCanBo(ArrayList<CanBo> listCanBo, String pathName, String nam, int gt, String tongNhanVien,
        String soNVVH) {/*from w ww  . j  a va2 s .  c o  m*/
    PdfWriter pdfWriter = null;
    String gioiTinh = "";
    if (gt == 1) {
        gioiTinh = "n";
    } else {
        gioiTinh = "nam";
    }

    try {
        pdfWriter = new PdfWriter(pathName);
        PdfDocument pdfDocument = new PdfDocument(pdfWriter);
        Document document = new Document(pdfDocument, PageSize.A4.rotate());
        PdfFont hfont = PdfFontFactory.createFont("C:\\Windows\\Fonts\\tahoma.ttf", PdfEncodings.IDENTITY_H,
                true);
        document.setMargins(50, 50, 50, 50);
        document.add(new Paragraph("TRNG ?I HC B?CH KHOA H NI ").setFont(hfont).setBold()
                .setTextAlignment(TextAlignment.CENTER).setFontSize(16));
        document.add(new Paragraph("Thng k cn b " + gioiTinh + " nm " + nam + "\n\n").setFont(hfont)
                .setBold().setTextAlignment(TextAlignment.CENTER).setFontSize(14));
        float[] columnWidths = { 1, 2, 4, 3, 4 };
        Table table = new Table(columnWidths);
        table.setWidthPercent(100);
        table.addHeaderCell(new Paragraph("STT").setFont(hfont).setTextAlignment(TextAlignment.CENTER).setBold()
                .setFontSize(14));
        table.addHeaderCell(new Paragraph("M cn b").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("H? v tn ").setFont(hfont)
                .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("Ngy sinh").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("S in thoi").setFont(hfont)
                .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14));

        //  ni dung ca bng thng k
        for (int i = 0; i < listCanBo.size(); i++) {
            table.addCell(new Paragraph((i + 1) + "").setFont(hfont).setTextAlignment(TextAlignment.CENTER));
            table.addCell(new Paragraph(listCanBo.get(i).getMaCB()).setFont(hfont)
                    .setTextAlignment(TextAlignment.CENTER));
            table.addCell(new Paragraph(listCanBo.get(i).getHoTen()).setFont(hfont)
                    .setTextAlignment(TextAlignment.CENTER));
            table.addCell(new Paragraph(dateFormat.format(listCanBo.get(i).getNgaySinh())).setFont(hfont)
                    .setTextAlignment(TextAlignment.CENTER));
            table.addCell(new Paragraph(listCanBo.get(i).getSDT()).setFont(hfont)
                    .setTextAlignment(TextAlignment.CENTER));
        }
        document.add(table);
        document.add(new Paragraph("\n\n Tng s nhn vin            :  " + tongNhanVien).setFont(hfont)
                .setTextAlignment(TextAlignment.LEFT));
        document.add(new Paragraph(" Tng s nhn vin sp v? hu :  " + tongNhanVien).setFont(hfont)
                .setTextAlignment(TextAlignment.LEFT));

        document.add(new Paragraph(
                "\n\n\n H Ni, ngy    thng        nm     \n  Ng?i lp phiu \n  ( Ghi r h? tn) ")
                        .setFont(hfont).setTextAlignment(TextAlignment.RIGHT).setItalic().setMarginRight(40));
        document.close();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            pdfWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:model.PrintPDF.java

public void thongKeDoanPhi(ArrayList<String> listDataTable, String pathName, String nam, String tongDoanVien,
        String tienDoanPhi) {//from w w  w  .  j a va2s  . c  o  m
    PdfWriter pdfWriter = null;
    String gioiTinh = "";

    try {
        pdfWriter = new PdfWriter(pathName);
        PdfDocument pdfDocument = new PdfDocument(pdfWriter);
        Document document = new Document(pdfDocument, PageSize.A4.rotate());
        PdfFont hfont = PdfFontFactory.createFont("C:\\Windows\\Fonts\\tahoma.ttf", PdfEncodings.IDENTITY_H,
                true);
        document.setMargins(50, 50, 50, 50);
        document.add(new Paragraph("TRNG ?I HC B?CH KHOA H NI ").setFont(hfont).setBold()
                .setTextAlignment(TextAlignment.CENTER).setFontSize(16));
        document.add(new Paragraph("Thng k on vin  " + gioiTinh + " nm " + nam + "\n\n")
                .setFont(hfont).setBold().setTextAlignment(TextAlignment.CENTER).setFontSize(14));
        float[] columnWidths = { 1, 2, 4, 3, 4 };
        Table table = new Table(columnWidths);
        table.setWidthPercent(100);
        table.addHeaderCell(new Paragraph("STT").setFont(hfont).setTextAlignment(TextAlignment.CENTER).setBold()
                .setFontSize(14));
        table.addHeaderCell(new Paragraph("M cn b").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("H? v tn ").setFont(hfont)
                .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("Ngy sinh").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("S ti khon ").setFont(hfont)
                .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14));

        //  ni dung ca bng thng k
        for (int i = 0; i < listDataTable.size(); i++) {
            table.addCell(new Paragraph(listDataTable.get(i)).setFont(hfont)
                    .setTextAlignment(TextAlignment.CENTER).setFontSize(14));
        }

        document.add(table);
        document.add(new Paragraph("\n\n Tng s on vin           :  " + tongDoanVien).setFont(hfont)
                .setTextAlignment(TextAlignment.LEFT));
        document.add(new Paragraph(" ?on ph (VN? / ?on Vin) :  " + tienDoanPhi + "VN?")
                .setFont(hfont).setTextAlignment(TextAlignment.LEFT));
        double tongTienDoanPhi = Integer.parseInt(tongDoanVien) * Integer.parseInt(tienDoanPhi);
        document.add(new Paragraph(" Tng s ti?n on ph            :  " + tongTienDoanPhi + " VND")
                .setFont(hfont).setTextAlignment(TextAlignment.LEFT));
        document.add(new Paragraph(
                "\n\n\n H Ni, ngy    thng        nm     \n  Ng?i lp phiu \n  ( Ghi r h? tn) ")
                        .setFont(hfont).setTextAlignment(TextAlignment.RIGHT).setItalic().setMarginRight(40));
        document.close();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            pdfWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}

From source file:model.PrintPDF.java

public void thongKeCongDoanPhi(ArrayList<String> listDataTable, String pathName, String nam,
        String tongCongDoanVien, String tienCongDoanPhi) {
    PdfWriter pdfWriter = null;/*from   w  ww. j a  v  a2  s.  co  m*/

    try {
        pdfWriter = new PdfWriter(pathName);
        PdfDocument pdfDocument = new PdfDocument(pdfWriter);
        Document document = new Document(pdfDocument, PageSize.A4.rotate());
        PdfFont hfont = PdfFontFactory.createFont("C:\\Windows\\Fonts\\tahoma.ttf", PdfEncodings.IDENTITY_H,
                true);
        document.setMargins(50, 50, 50, 50);
        document.add(new Paragraph("TRNG ?I HC B?CH KHOA H NI ").setFont(hfont).setBold()
                .setTextAlignment(TextAlignment.CENTER).setFontSize(16));
        document.add(new Paragraph("Thng k cng on vin  nm " + nam + "\n\n").setFont(hfont)
                .setBold().setTextAlignment(TextAlignment.CENTER).setFontSize(14));
        float[] columnWidths = { 1, 2, 4, 3, 3, 3 };
        Table table = new Table(columnWidths);
        table.setWidthPercent(100);
        table.addHeaderCell(new Paragraph("STT").setFont(hfont).setTextAlignment(TextAlignment.CENTER).setBold()
                .setFontSize(14));
        table.addHeaderCell(new Paragraph("M cn b").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("H? v tn ").setFont(hfont)
                .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("Ngy sinh").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("Chc v ").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("Cng on ph ").setFont(hfont)
                .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14));
        //  ni dung ca bng thng k
        for (int i = 0; i < listDataTable.size(); i++) {
            table.addCell(new Paragraph(listDataTable.get(i)).setFont(hfont)
                    .setTextAlignment(TextAlignment.CENTER).setFontSize(14));
        }

        document.add(table);
        document.add(new Paragraph("\n\n Tng s nhn vin           :  " + tongCongDoanVien)
                .setFont(hfont).setTextAlignment(TextAlignment.LEFT));
        document.add(new Paragraph(" Tng cng on ph  :  " + tienCongDoanPhi).setFont(hfont)
                .setTextAlignment(TextAlignment.LEFT));

        document.add(new Paragraph(
                "\n\n\n H Ni, ngy    thng        nm     \n  Ng?i lp phiu \n  ( Ghi r h? tn) ")
                        .setFont(hfont).setTextAlignment(TextAlignment.RIGHT).setItalic().setMarginRight(40));
        document.close();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            pdfWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}

From source file:model.PrintPDF.java

public void thongKeDangPhi(ArrayList<String> listDataTable, String pathName, String nam, String tongDangVien) {
    PdfWriter pdfWriter = null;//from  www.  j  a  v  a  2  s.co m

    try {
        pdfWriter = new PdfWriter(pathName);
        PdfDocument pdfDocument = new PdfDocument(pdfWriter);
        Document document = new Document(pdfDocument, PageSize.A4.rotate());
        PdfFont hfont = PdfFontFactory.createFont("C:\\Windows\\Fonts\\tahoma.ttf", PdfEncodings.IDENTITY_H,
                true);
        document.setMargins(50, 50, 50, 50);
        document.add(new Paragraph("TRNG ?I HC B?CH KHOA H NI ").setFont(hfont).setBold()
                .setTextAlignment(TextAlignment.CENTER).setFontSize(16));
        document.add(new Paragraph("Thng k ng vin  " + " nm " + nam + "\n\n").setFont(hfont)
                .setBold().setTextAlignment(TextAlignment.CENTER).setFontSize(14));
        float[] columnWidths = { 1, 2, 4, 3, 4, 4 };
        Table table = new Table(columnWidths);
        table.setWidthPercent(100);
        table.addHeaderCell(new Paragraph("STT").setFont(hfont).setTextAlignment(TextAlignment.CENTER).setBold()
                .setFontSize(14));
        table.addHeaderCell(new Paragraph("M cn b").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("H? v tn ").setFont(hfont)
                .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("Ngy sinh").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("Chc v ").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("?ng ph ").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));

        //  ni dung ca bng thng k
        for (int i = 0; i < listDataTable.size(); i++) {
            table.addCell(new Paragraph(listDataTable.get(i)).setFont(hfont)
                    .setTextAlignment(TextAlignment.CENTER).setFontSize(14));
        }

        document.add(table);
        document.add(new Paragraph("\n\n Tng s ng vin           :  " + tongDangVien).setFont(hfont)
                .setTextAlignment(TextAlignment.LEFT));
        document.add(new Paragraph(
                "\n\n\n H Ni, ngy    thng        nm     \n  Ng?i lp phiu \n  ( Ghi r h? tn) ")
                        .setFont(hfont).setTextAlignment(TextAlignment.RIGHT).setItalic().setMarginRight(40));
        document.close();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            pdfWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}

From source file:model.PrintPDF.java

public void thongKeTienThi(ArrayList<String> listDataTable, String pathName) {
    PdfWriter pdfWriter = null;//www. j  a va2s.  c  o  m

    try {
        pdfWriter = new PdfWriter(pathName);
        PdfDocument pdfDocument = new PdfDocument(pdfWriter);
        Document document = new Document(pdfDocument, PageSize.A4.rotate());
        PdfFont hfont = PdfFontFactory.createFont("C:\\Windows\\Fonts\\tahoma.ttf", PdfEncodings.IDENTITY_H,
                true);
        document.setMargins(50, 50, 50, 50);
        document.add(new Paragraph("TRNG ?I HC B?CH KHOA H NI ").setFont(hfont).setBold()
                .setTextAlignment(TextAlignment.CENTER).setFontSize(16));
        document.add(new Paragraph("Thng k ti?n thi ging vin  " + "\n\n").setFont(hfont).setBold()
                .setTextAlignment(TextAlignment.CENTER).setFontSize(14));
        float[] columnWidths = { 1, 2, 4, 3, 4, 4 };
        Table table = new Table(columnWidths);
        table.setWidthPercent(100);
        table.addHeaderCell(new Paragraph("STT").setFont(hfont).setTextAlignment(TextAlignment.CENTER).setBold()
                .setFontSize(14));
        table.addHeaderCell(new Paragraph("M cn b").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("H? v tn ").setFont(hfont)
                .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("Mn h?c").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("S SV ").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("Ph thi").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));

        //  ni dung ca bng thng k
        for (int i = 0; i < listDataTable.size(); i++) {
            table.addCell(new Paragraph(listDataTable.get(i)).setFont(hfont)
                    .setTextAlignment(TextAlignment.CENTER).setFontSize(14));
        }

        document.add(table);
        document.add(new Paragraph(
                "\n\n\n H Ni, ngy    thng        nm     \n  Ng?i lp phiu \n  ( Ghi r h? tn) ")
                        .setFont(hfont).setTextAlignment(TextAlignment.RIGHT).setItalic().setMarginRight(40));
        document.close();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            pdfWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}

From source file:model.PrintPDF.java

public void thongKeThieuNhi(ArrayList<String> listDataTable, String pathName) {
    PdfWriter pdfWriter = null;/*from  ww w. ja  va 2s.  com*/

    try {
        pdfWriter = new PdfWriter(pathName);
        PdfDocument pdfDocument = new PdfDocument(pdfWriter);
        Document document = new Document(pdfDocument, PageSize.A4.rotate());
        PdfFont hfont = PdfFontFactory.createFont("C:\\Windows\\Fonts\\tahoma.ttf", PdfEncodings.IDENTITY_H,
                true);
        document.setMargins(50, 50, 50, 50);
        document.add(new Paragraph("TRNG ?I HC B?CH KHOA H NI ").setFont(hfont).setBold()
                .setTextAlignment(TextAlignment.CENTER).setFontSize(16));
        document.add(new Paragraph("Thng k cc chu thiu nhi   " + "\n\n").setFont(hfont).setBold()
                .setTextAlignment(TextAlignment.CENTER).setFontSize(14));
        float[] columnWidths = { 1, 3, 3, 3, 4 };
        Table table = new Table(columnWidths);
        table.setWidthPercent(100);
        table.addHeaderCell(new Paragraph("STT").setFont(hfont).setTextAlignment(TextAlignment.CENTER).setBold()
                .setFontSize(14));
        table.addHeaderCell(new Paragraph("H? v tn").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("Ngy sinh ").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("M cn b").setFont(hfont).setTextAlignment(TextAlignment.CENTER)
                .setBold().setFontSize(14));
        table.addHeaderCell(new Paragraph("H? v tn cn b ").setFont(hfont)
                .setTextAlignment(TextAlignment.CENTER).setBold().setFontSize(14));

        //  ni dung ca bng thng k
        for (int i = 0; i < listDataTable.size(); i++) {
            table.addCell(new Paragraph(listDataTable.get(i)).setFont(hfont)
                    .setTextAlignment(TextAlignment.CENTER).setFontSize(14));
        }

        document.add(table);
        document.add(new Paragraph(
                "\n\n\n H Ni, ngy    thng        nm     \n  Ng?i lp phiu \n  ( Ghi r h? tn) ")
                        .setFont(hfont).setTextAlignment(TextAlignment.RIGHT).setItalic().setMarginRight(40));
        document.close();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            pdfWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(PrintPDF.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}