Example usage for com.itextpdf.text BaseColor BLACK

List of usage examples for com.itextpdf.text BaseColor BLACK

Introduction

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

Prototype

BaseColor BLACK

To view the source code for com.itextpdf.text BaseColor BLACK.

Click Source Link

Usage

From source file:GUI_StafKlinik.Panel_Laporan_Keuangan.java

private void createPdf(List<Laporan_Keuangan> list) {
    JFileChooser saveFile = new JFileChooser();
    saveFile.setSelectedFile(new File("D:/document/Laporan Keuangan.pdf"));
    String result = null;/* w  w  w.  j a v a 2 s.  c  o  m*/
    if (saveFile.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
        result = saveFile.getSelectedFile().toString();
    } else {
        System.out.println("No Selection ");
    }
    try {
        // TODO add your handling code here:
        Document document = new Document();
        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(result));
            document.open();
            PdfContentByte canvas = writer.getDirectContent();
            Rectangle rect = new Rectangle(50, 800, 550, 700);
            rect.setBorder(Rectangle.BOX);
            rect.setBorderWidth(0);
            rect.setBorderColor(BaseColor.BLACK);
            canvas.rectangle(rect);
            Paragraph preface;
            preface = getPreface("Laporan Keuangan");
            document.add(preface);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(createTableLaporan(list));
            document.close();
            open(result);
        } catch (DocumentException ex) {
            Logger.getLogger(Panel_Laporan_Keuangan.class.getName()).log(Level.SEVERE, null, ex);
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Panel_Laporan_Keuangan.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:GUI_StafKlinik.Panel_Penggajian.java

private void createPdf(List<Penggajian> list) {
    JFileChooser saveFile = new JFileChooser();
    saveFile.setSelectedFile(new File("D:/document/Slip Gaji.pdf"));
    String result = null;// w  w  w  . ja v a  2 s .  c o  m
    if (saveFile.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
        result = saveFile.getSelectedFile().toString();
    } else {
        System.out.println("No Selection ");
    }
    try {
        Document document = new Document();
        try {
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(result));
            document.open();
            PdfContentByte canvas = writer.getDirectContent();

            for (int i = 0; i < list.size(); i++) {
                document.newPage();
                Rectangle rect = new Rectangle(50, 800, 550, 700);
                rect.setBorder(Rectangle.BOX);
                rect.setBorderWidth(0);
                rect.setBorderColor(BaseColor.BLACK);
                canvas.rectangle(rect);
                Paragraph preface;
                preface = getPreface("Slip Gaji");
                document.add(preface);
                document.add(Chunk.NEWLINE);
                document.add(Chunk.NEWLINE);
                document.add(createTableLaporan(list.get(i)));
            }
            document.close();
            open(result);
        } catch (DocumentException ex) {
            Logger.getLogger(Panel_Laporan_Keuangan.class.getName()).log(Level.SEVERE, null, ex);
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Panel_Laporan_Keuangan.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:helpers.PDFHeaderFooter.java

@Override
public void onStartPage(PdfWriter writer, Document document) {
    Rectangle rect = writer.getBoxSize("art");
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(""), rect.getLeft(),
            rect.getTop(), 0);/*  w w w.  j a  v a  2s  . c  om*/
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER,
            new Phrase("Page " + document.getPageNumber(),
                    FontFactory.getFont(FontFactory.TIMES_ITALIC, 5, Font.ITALIC, BaseColor.BLACK)),
            rect.getRight(), rect.getTop(), 0);
}

From source file:IAS.Class.BackIssueLabels.java

public Paragraph prepareBILLabelPDFContent(subInfo sLabelInfo, String bilLabel) {
    Paragraph info = null;//from w w  w . j ava 2 s. co  m

    info = new Paragraph();
    info.setLeading(lfixedLeading, lmultipliedLeadingPlus);
    info.setAlignment(textAlignment);

    Font font;
    font = new Font(sfontType, sfontSizeHeader - 1, sfontStyle, BaseColor.BLACK);
    if (!bilLabel.isEmpty() && !sLabelInfo.getsubscriberNumber().isEmpty()) {
        String header = sLabelInfo.getsubscriberNumber() + " " + bilLabel;
        info.add(new Chunk(header, font));
        info.add(Chunk.NEWLINE);
    }

    font = new Font(sfontType, sfontSize, sfontStyle, BaseColor.BLACK);
    String firstLine = sLabelInfo.getsubscriberName();
    // + " " + sLabelInfo.getjournalCode();

    //if(!noHeader){

    //if(sLabelInfo.getcopies() > 1){
    //    firstLine = firstLine + " " + sLabelInfo.getcopies();
    //}

    //firstLine = firstLine + " " + sLabelInfo.getsubtypecode();

    //if(sLabelInfo.equals("Paid")) {
    //    firstLine = firstLine + " " + sLabelInfo.getstartDate()+
    //        " " + "to" +
    //        " " + sLabelInfo.getendDate();
    //}
    if (!firstLine.isEmpty()) {
        info.add(new Chunk(firstLine, font));
        info.add(Chunk.NEWLINE);
    }
    //}

    //info.add(new Chunk(sLabelInfo.getsubscriberName(), font));
    //info.add(Chunk.NEWLINE);
    if (!sLabelInfo.getdepartment().isEmpty()) {
        info.add(new Chunk(sLabelInfo.getdepartment(), font));
        info.add(Chunk.NEWLINE);
    }
    if (!sLabelInfo.getinstitution().isEmpty()) {
        info.add(new Chunk(sLabelInfo.getinstitution(), font));
        info.add(Chunk.NEWLINE);
    }

    if (!sLabelInfo.getaddress().isEmpty()) {
        info.add(new Chunk(sLabelInfo.getaddress(), font));
        info.add(Chunk.NEWLINE);
    }
    font = new Font(sfontType, sfontSize, Font.BOLD);
    /*
    String lastLine = sLabelInfo.getcity() +
        " " + sLabelInfo.getpincode() +
        " " + sLabelInfo.getstate() +
        " ";
    if(!sLabelInfo.getcountry().equals("India")){
    lastLine = lastLine + sLabelInfo.getcountry();
    }
    */

    String lastLine = "";
    if (!sLabelInfo.getcity().isEmpty()) {
        lastLine = lastLine + sLabelInfo.getcity();
    }
    if (sLabelInfo.getcity().isEmpty()) {
        lastLine = lastLine + sLabelInfo.getpincode();
    } else {
        lastLine = lastLine + " " + sLabelInfo.getpincode();
    }
    if (sLabelInfo.getpincode().isEmpty()) {
        lastLine = lastLine + sLabelInfo.getstate();
    } else {
        lastLine = lastLine + " " + sLabelInfo.getstate();
    }

    String country = "";
    if (!sLabelInfo.getcountry().equals("India")) {
        country = sLabelInfo.getcountry();
    }

    if (sLabelInfo.getstate().isEmpty()) {
        lastLine = lastLine + country;
    } else {
        lastLine = lastLine + " " + country;
    }

    if (!lastLine.isEmpty()) {
        lastLine = lastLine.trim();
        // Remove the leading spaces
        //lastLine.replaceAll("^\\s+", "");
        info.add(new Chunk(lastLine, font));
    }

    return info;

}

From source file:ihm.panneaux.GenererPdf.java

private void initComponement() throws FileNotFoundException, DocumentException, IOException {
    String DEST = "devis/devis-" + devis.getNumero() + ".pdf";
    OutputStream file = new FileOutputStream(new File(DEST));

    com.itextpdf.text.Document document = new com.itextpdf.text.Document();
    PdfWriter.getInstance((com.itextpdf.text.Document) document, file);
    // PAS TOUCHE
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(DEST));

    Rectangle rect = new Rectangle(30, 30, 550, 800);
    writer.setBoxSize("art", rect);
    HeaderFooterPageEvent event = new HeaderFooterPageEvent();
    writer.setPageEvent(event);/*w ww. j a  v  a  2 s. c  o  m*/
    document.open();
    PdfContentByte canvas = writer.getDirectContent();

    Image logo = Image.getInstance("images/logo.png");
    logo.scaleAbsolute(200, 57);

    // INFO DEVIS
    Image devisImg = Image.getInstance("images/imgDevis.png");
    devisImg.scaleAbsolute(110, 34);
    devisImg.setAbsolutePosition((PageSize.POSTCARD.getWidth() + 150),
            (PageSize.POSTCARD.getHeight() - devisImg.getScaledHeight()) * 2);
    Font fontImgDevis = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
    Phrase numeroInfo = new Phrase("Numro  " + devis.getNumero(), fontImgDevis);
    ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, numeroInfo, devisImg.getScaledWidth() + 413,
            devisImg.getScaledHeight() + 710, 0);
    Phrase dateInfo = new Phrase("Le  " + devis.getDate(), fontImgDevis);
    ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, dateInfo, devisImg.getScaledWidth() + 420,
            devisImg.getScaledHeight() + 695, 0);
    Image devisImgBordure = Image.getInstance("images/bordureDevis.png");
    devisImgBordure.setAbsolutePosition((devisImg.getScaledWidth() + 318), devisImg.getScaledHeight() + 660);
    devisImgBordure.scaleAbsolute(120, 122);

    // INFO ENTREPRISE
    Font fontEntreprise = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD);
    Phrase coGerants = new Phrase("Co-grants : " + devis.getEntreprise().getCoGerant(), fontEntreprise);
    ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, coGerants, devisImg.getScaledWidth() + 210,
            devisImg.getScaledHeight() + 660, 0);
    Phrase siege = new Phrase("Sige : " + devis.getEntreprise().getSiege(), fontEntreprise);
    ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, siege, devisImg.getScaledWidth() + 149,
            devisImg.getScaledHeight() + 640, 0);
    Phrase tel = new Phrase("TEL : " + devis.getEntreprise().getTel(), fontEntreprise);
    ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, tel, devisImg.getScaledWidth() + 113,
            devisImg.getScaledHeight() + 625, 0);
    Image bordureEntreprise = Image.getInstance("images/bordureEntreprise.png");
    bordureEntreprise.setAbsolutePosition(devisImg.getScaledWidth() - 80, devisImg.getScaledHeight() + 610);

    // INFO CLIENT
    Font fontClient = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL);
    Phrase nomPrenom = new Phrase(devis.getClient().getNom() + " " + devis.getClient().getPrenom(), fontClient);
    Phrase commune = new Phrase(devis.getClient().getAdresse(), fontClient);
    Phrase adresse = new Phrase(devis.getClient().getCodePostale() + " " + devis.getClient().getCommune(),
            fontClient);
    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, nomPrenom, PageSize.A4.getWidth() - 280,
            devisImg.getScaledHeight() + 595, 0);
    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, commune, PageSize.A4.getWidth() - 280,
            devisImg.getScaledHeight() + 580, 0);
    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, adresse, PageSize.A4.getWidth() - 280,
            devisImg.getScaledHeight() + 565, 0);

    document.add(logo);
    document.add(devisImg);
    document.add(devisImgBordure);
    document.add(bordureEntreprise);

    // AJOUT DES DONNEES DU TABLEAUX 

    float[] columnWidths = { 14, 3, 4, 3, 4 };
    Font fontCategorie = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
    fontCategorie.setColor(BaseColor.GREEN);

    PdfPTable table = new PdfPTable(columnWidths);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    table.setTotalWidth(PageSize.A4.getWidth() - 15);

    table.setSpacingBefore(150);

    table.setLockedWidth(true);

    Font Categorie = new Font(FontFamily.HELVETICA, 13, Font.BOLD);
    Font Chantier = new Font(FontFamily.HELVETICA, 11, Font.UNDERLINE);

    PdfPCell cellChantier = new PdfPCell(new Phrase("CHANTIER : " + chantier, Chantier));
    cellChantier.setColspan(3);
    cellChantier.setBorder(Rectangle.NO_BORDER);
    table.addCell(cellChantier);
    table.addCell(" ");
    table.addCell(" ");

    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");

    table.addCell(new Phrase("Dsignation", Categorie));
    PdfPCell unite = new PdfPCell(new Phrase("Unite", Categorie));
    PdfPCell quantite = new PdfPCell(new Phrase("Quantite", Categorie));
    PdfPCell prixht = new PdfPCell(new Phrase("Prix HT", Categorie));
    PdfPCell pvtht = new PdfPCell(new Phrase("Pvt HT", Categorie));

    unite.setHorizontalAlignment(Element.ALIGN_CENTER);
    quantite.setHorizontalAlignment(Element.ALIGN_CENTER);
    prixht.setHorizontalAlignment(Element.ALIGN_CENTER);
    pvtht.setHorizontalAlignment(Element.ALIGN_CENTER);

    unite.setBorder(Rectangle.NO_BORDER);
    quantite.setBorder(Rectangle.NO_BORDER);
    prixht.setBorder(Rectangle.NO_BORDER);
    pvtht.setBorder(Rectangle.NO_BORDER);

    table.addCell(unite);
    table.addCell(quantite);
    table.addCell(prixht);
    table.addCell(pvtht);

    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");

    double htTotalParcour = 0;
    double ttcTotalParcour = 0;

    if (this.EquipementDeChantier.isEmpty() == false) {
        table.addCell(new Phrase("Equipement De Chantier", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");

        for (DevisContenu listeMaterielDevi : EquipementDeChantier) {

            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            /* BACKUP
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            table.addCell(listeMaterielDevi.getMateriel().getUnite());
            table.addCell(Double.toString(listeMaterielDevi.getQuantite()));
            table.addCell(Double.toString(listeMaterielDevi.getMateriel().getPrix())+"");
            table.addCell(Double.toString(listeMaterielDevi.getPvtHT())+"");
            */
            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }
    if (Couverture.isEmpty() == false) {
        table.addCell(new Phrase("Couverture", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : Couverture) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }
    if (CouvertureArdoise.isEmpty() == false) {
        table.addCell(new Phrase("Couverture Ardoise", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : CouvertureArdoise) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }
    if (CouvertureTuile.isEmpty() == false) {
        table.addCell(new Phrase("Couverture Tuile", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : CouvertureTuile) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }
    if (this.Demoussage.isEmpty() == false) {
        table.addCell(new Phrase("Demoussage", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : Demoussage) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");

    }
    if (this.Velux.isEmpty() == false) {
        table.addCell(new Phrase("Velux", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : Velux) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");

    }
    if (this.Zinguerie.isEmpty() == false) {
        table.addCell(new Phrase("Zinguerie", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : Zinguerie) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }
    if (Plancher.isEmpty() == false) {
        table.addCell(new Phrase("Plancher", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : Plancher) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }

    ttcTotalParcour = (ttcTotalParcour * devis.getTva() / 100) + ttcTotalParcour;

    LineDash solid = new SolidLine();
    PdfPCell cell, cell2, cellSOUSTOTAL, cellhttotal, tva, getTva, totalttc, gettotalttc;

    table.addCell(new Phrase(" "));
    table.addCell(new Phrase(" "));
    table.addCell(new Phrase(" "));
    table.addCell(new Phrase(" "));

    cell = new PdfPCell(new Phrase(""));
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setCellEvent(new CustomBorder(null, null, null, solid));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);

    table.addCell(new Phrase(""));
    table.addCell(new Phrase(""));
    cellSOUSTOTAL = new PdfPCell(new Phrase("SOUS-TOTAL"));
    cellSOUSTOTAL.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    cellSOUSTOTAL.setBorder(Rectangle.NO_BORDER);
    table.addCell(cellSOUSTOTAL);
    table.addCell(new Phrase(""));
    double prixHT_2Chiffre = Math.round((htTotalParcour) * Math.pow(10, 2)) / Math.pow(10, 2);
    String httotal = String.valueOf(prixHT_2Chiffre);
    cellhttotal = new PdfPCell(new Phrase(httotal + ""));
    cellhttotal.setBorder(Rectangle.NO_BORDER);
    cellhttotal.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cellhttotal);

    table.addCell(new Phrase(""));
    table.addCell(new Phrase(""));
    tva = new PdfPCell(new Phrase("TVA"));
    tva.setBorder(Rectangle.NO_BORDER);
    tva.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(tva);

    getTva = new PdfPCell(new Phrase(devis.getTva() + "%"));
    getTva.setBorder(Rectangle.NO_BORDER);
    getTva.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(getTva);

    String tvaprix = String.valueOf(htTotalParcour * devis.getTva() / 100);
    double prixTVA_2Chiffre = Math.round(Double.parseDouble(tvaprix) * Math.pow(10, 2)) / Math.pow(10, 2);
    cell2 = new PdfPCell(new Phrase(Double.toString(prixTVA_2Chiffre) + ""));
    cell2.setBorder(PdfPCell.NO_BORDER);
    cell2.setCellEvent(new CustomBorder(null, null, null, solid));
    cell2.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell2);

    table.addCell("");
    table.addCell("");
    totalttc = new PdfPCell(new Phrase("Total TTC"));
    totalttc.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    totalttc.setBorder(PdfPCell.NO_BORDER);
    table.addCell(totalttc);
    table.addCell("");
    double prixTTC_2Chiffre = Math.round(ttcTotalParcour * Math.pow(10, 2)) / Math.pow(10, 2);
    String ttctotal = String.valueOf(Double.toString(prixTTC_2Chiffre));
    gettotalttc = new PdfPCell(new Phrase(ttctotal + ""));
    gettotalttc.setBorder(PdfPCell.NO_BORDER);
    gettotalttc.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(gettotalttc);

    table.setSpacingAfter(10);

    document.add(table);

    Pattern p = Pattern.compile("[.^\\.]+");
    String texte = devis.getInformationComplementaire();

    Font infoComptBlue = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL);
    infoComptBlue.setColor(BaseColor.BLUE);
    Font infoComptRed = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL);
    infoComptRed.setColor(BaseColor.RED);
    Font infoComptBlack = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL);
    infoComptBlack.setColor(BaseColor.BLACK);

    Paragraph infoComp = new Paragraph();
    Image BonPourAccord = null;
    BonPourAccord = Image.getInstance("images/BonPourAccord.png");
    infoComp.setAlignment(Element.ALIGN_LEFT);
    BonPourAccord.setAlignment(Image.TEXTWRAP | Image.ALIGN_RIGHT);

    String[] phrase = p.split(texte);
    for (int i = 0; i < phrase.length; i++) {
        if (i == 0 || i == 1) {
            infoComp.add(new Paragraph(phrase[i], infoComptBlue));
        }
        if (i == 2 || i == 3 || i == 4 || i == 5) {
            infoComp.add(new Paragraph(phrase[i], infoComptRed));

        }
        if (i > 5 && i <= 11)
            infoComp.add(new Paragraph(phrase[i], infoComptBlack));
        if (i > 11)
            infoComp.add(new Paragraph(phrase[i], infoComptRed));
    }
    /* A OPTIMISER */

    float taille_tableau = table.calculateHeights() + table.getRowHeight(table.getLastCompletedRowIndex());

    if (taille_tableau > 386) {
        document.newPage();
    }
    document.add(BonPourAccord);
    document.add(infoComp);

    document.close();

    EnvoieDevis envoie = new EnvoieDevis(null, true, session, devis);
    this.CouvertureArdoise.clear();
    this.CouvertureTuile.clear();
    this.Demoussage.clear();
    this.EquipementDeChantier.clear();
    this.Velux.clear();
    this.Zinguerie.clear();
    this.Couverture.clear();
    this.Plancher.clear();
}

From source file:itext_result.Main.java

private int developScreeningSheet() {
    new SwingWorker<Object, Object>() {
        String filename;//from  w  w w  .jav  a  2 s  .c  o  m

        @Override
        protected void done() {

            // ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. ");
        }

        public PdfPCell createBarcode(PdfWriter writer, String code) throws DocumentException, IOException {
            BarcodeEAN barcode = new BarcodeEAN();
            barcode.setCodeType(Barcode.EAN8);
            barcode.setCode(code);
            PdfPCell cell = new PdfPCell(
                    barcode.createImageWithBarcode(writer.getDirectContent(), BaseColor.BLACK, BaseColor.GRAY),
                    true);
            cell.setPadding(10);
            return cell;
        }

        class ImageContent implements PdfPTableEvent {

            protected com.itextpdf.text.Image content;

            public ImageContent(com.itextpdf.text.Image content) {
                this.content = content;
            }

            public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows,
                    int rowStart, PdfContentByte[] canvases) {
                try {
                    PdfContentByte canvas = canvases[PdfPTable.TEXTCANVAS];
                    float x = widths[3][1] + 10;
                    float y = heights[3] - 10 - content.getScaledHeight();
                    content.setAbsolutePosition(x, y);
                    canvas.addImage(content);
                } catch (DocumentException e) {
                    throw new ExceptionConverter(e);
                }
            }
        }

        @Override
        protected Object doInBackground() throws Exception {
            //   System.err.println(" Roll No Received ....." + rollno);
            Document doc = new Document();
            try {
                PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("12345" + ".pdf"));
                doc.open();
                doc.addTitle("Recruitment PET Sheett - " + "Created By SOS : ");
                doc.addSubject("Confidential Report Eyes Only");
                doc.addKeywords("");
                doc.addAuthor("SOS");
                doc.addCreator("SOS");

                // A4 = 210mm x 297mm ~ 605points x 855points
                doc.setPageSize(PageSize.A5);
                doc.setMargins(15f, 15f, 15f, 15f);

                /////////////////////////////////////////////////////////////
                int pageno = 1;

                for (int i = 0; i == pageno; i++) {

                    //    doc.add(imageRight);
                }

                PdfContentByte cb = writer.getDirectContent();
                //DONE
                BarcodeEAN codeEAN = new BarcodeEAN();
                codeEAN.setCodeType(Barcode.EAN8);
                Barcode128 code128 = new Barcode128();
                code128.setCode(String.valueOf("123456"));

                Barcode128 code128_jacket = new Barcode128();
                code128_jacket.setCode(String.valueOf("10345"));

                codeEAN.setCode(String.valueOf("123456"));
                com.itextpdf.text.Image imageEAN = code128.createImageWithBarcode(cb, null, null);
                // imageEAN.scalePercent(10f);
                //464f, 725f
                //  imageEAN.setAbsolutePosition(474f, 662f);

                int i = 1;
                while (i <= pageno) {
                    doc.newPage();
                    //   cb.addImage(imageRight);
                    //   cb.addImage(imageEAN);
                    i++;
                }

                com.itextpdf.text.Image carcode = code128_jacket.createImageWithBarcode(cb, null, null);
                carcode.scaleAbsolute(100f, 35f);
                carcode.setAbsolutePosition(500f, 600f);
                writer.addDirectImageSimple(carcode);
                //     cb.addImage(carcode);

                com.itextpdf.text.Image carcode2 = code128.createImageWithBarcode(cb, null, null);
                carcode2.scaleAbsolute(100f, 35f);
                carcode2.setAbsolutePosition(450f, 760f);
                writer.addDirectImageSimple(carcode2);
                //    cb.addImage(carcode2);

                Image image1 = Image.getInstance("jklogo.gif");

                PdfPTable table = new PdfPTable(1);
                table.setWidthPercentage(99);
                table.addCell(image1);
                doc.add(table);
                table = new PdfPTable(4);
                table.setWidthPercentage(99);

                float[] columnWidths = { 6, 2 };
                PdfPTable CandidateTable = new PdfPTable(columnWidths);
                Font f = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK);
                Font fsmall = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK);
                PdfPCell rollno = new PdfPCell(new Phrase("Roll No# " + String.valueOf("123456"), fsmall));
                PdfPCell cname = new PdfPCell(new Phrase("Name #" + String.valueOf("John Doe"), fsmall));
                //                    DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
                //                    String today = formatter.format(cInfo.getDob());
                PdfPCell dob = new PdfPCell(new Phrase("DOB#" + String.valueOf("12-03-1989"), fsmall));
                PdfPCell fname = new PdfPCell(new Phrase("F/H Name #" + String.valueOf("Big John"), fsmall));
                PdfPCell type = new PdfPCell(new Phrase("Total Time  #" + String.valueOf("350.00"), fsmall));

                //  String scrtoday = formatter.format(cInfo.getScreeningdate());
                //  System.out.println("Today : " + today);
                PdfPCell scrdate = new PdfPCell(new Phrase("Laps  #" + String.valueOf("4"), fsmall));
                PdfPCell cell = new PdfPCell(new Phrase(" ", fsmall));

                rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                cname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                dob.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                fname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                type.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                scrdate.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                cell.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);

                CandidateTable.addCell(rollno);
                CandidateTable.addCell(cell);
                CandidateTable.addCell(cname);
                CandidateTable.addCell(cell);
                CandidateTable.addCell(dob);
                CandidateTable.addCell(cell);

                PdfPTable CandidateOtherTable = new PdfPTable(columnWidths);
                CandidateOtherTable.addCell(fname);
                CandidateOtherTable.addCell(cell);
                CandidateOtherTable.addCell(scrdate);
                CandidateOtherTable.addCell(cell);
                CandidateOtherTable.addCell(type);
                CandidateOtherTable.addCell(cell);

                PdfPCell race_start_time = new PdfPCell(new Phrase("Start Time :XX-XX-XX ", fsmall));
                PdfPCell race_end_time = new PdfPCell(new Phrase("End Time :XX-XX-XX", fsmall));
                PdfPCell race_total_time = new PdfPCell(new Phrase("Total Time : 350.00   ", fsmall));
                race_start_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                race_end_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                race_total_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);

                PdfPTable CandidateRaceDetails = new PdfPTable(columnWidths);
                CandidateRaceDetails.addCell(race_start_time);
                CandidateRaceDetails.addCell(cell);
                CandidateRaceDetails.addCell(race_end_time);
                CandidateRaceDetails.addCell(cell);
                CandidateRaceDetails.addCell(race_total_time);
                CandidateRaceDetails.addCell(cell);

                PdfPTable tablewith3cells = new PdfPTable(3);
                //1 St Col for Roll No Name and DOB
                tablewith3cells.addCell(CandidateTable);
                //2 nd Col for Father Name sCREEning Date Gurkha 
                tablewith3cells.addCell(CandidateOtherTable);
                //3rd Col for Barcode to be Printed
                tablewith3cells.addCell(CandidateRaceDetails);
                // Setting the Width here to 101
                tablewith3cells.setWidthPercentage(99);
                doc.add(tablewith3cells);

                PdfPTable userArea = new PdfPTable(1);
                userArea.setWidthPercentage(99);
                userArea.addCell(" \n \n Congratulations \n \n ");

                doc.add(userArea);

                PdfPTable footerCSBC = new PdfPTable(2);
                footerCSBC.setWidthPercentage(99);

                PdfPCell height_box = new PdfPCell(new Phrase("Height  \n\n\n", f));
                height_box.setBorder(com.itextpdf.text.Rectangle.BOX);
                PdfPCell chest_box = new PdfPCell(new Phrase("Chest  \n\n\n", f));
                chest_box.setBorder(com.itextpdf.text.Rectangle.BOX);
                PdfPCell chest_exp_box = new PdfPCell(new Phrase("Chest Exp  \n\n\n", f));
                chest_exp_box.setBorder(com.itextpdf.text.Rectangle.BOX);
                PdfPCell pushup_box = new PdfPCell(new Phrase("Pushup  \n\n\n", f));
                pushup_box.setBorder(com.itextpdf.text.Rectangle.BOX);

                //CSignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX);
                // ASignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX);
                footerCSBC.addCell(height_box);
                footerCSBC.addCell(chest_box);
                footerCSBC.addCell(chest_exp_box);
                footerCSBC.addCell(pushup_box);

                doc.add(footerCSBC);

                float[] columnWidths_ForBarcode = { 6, 3 };
                PdfPTable terminalinfo = new PdfPTable(columnWidths_ForBarcode);
                // terminalinfo.setWidthPercentage(99);
                String computername = InetAddress.getLocalHost().getHostName();
                System.out.println(computername);
                PdfPCell pcname = new PdfPCell(new Phrase("\t Jacket \n\n ", f));

                String UserMatchScore = "\t Barcode\n\n";

                PdfPCell score = new PdfPCell(new Phrase(UserMatchScore, f));
                PdfPCell barcode = new PdfPCell(carcode2);
                PdfPCell jacketnumber = new PdfPCell(carcode);
                pcname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                score.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                barcode.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);
                jacketnumber.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);

                terminalinfo.addCell(score);
                terminalinfo.addCell(pcname);
                terminalinfo.addCell(barcode);
                terminalinfo.addCell(jacketnumber);

                doc.add(terminalinfo);

                PdfPCell eula_notice = new PdfPCell(new Phrase("  ", f));
                eula_notice.setBorder(com.itextpdf.text.Rectangle.NO_BORDER);

                cell.setHorizontalAlignment(Element.ALIGN_CENTER);

                PdfPTable eula_notice_table = new PdfPTable(1);
                eula_notice_table.setWidthPercentage(25);
                eula_notice_table.addCell(eula_notice);

                doc.add(eula_notice_table);

            } catch (Exception e) {
                System.err.println(e.getMessage());

                // ConsoleMsg(e.getMessage());
            } finally {
                doc.close();
                doc.close();
                doc.close();
            }

            //ConsoleMsg("PDF... GENERATED");
            return null;
            //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    }.execute();

    return 0;
}

From source file:jfx_horario.jefatura.JefaturaController.java

private void crearPdf(File fichero, int opcion) {
    // mtodo para generar un pdf
    try {/*w w  w  . ja  va  2 s.co  m*/
        OutputStream file = new FileOutputStream(fichero);
        Document document = new Document();
        PdfWriter.getInstance(document, file);
        document.open();
        Font titleFont = FontFactory.getFont(FontFactory.TIMES_BOLD, 18, BaseColor.BLACK);
        Paragraph docTitle = new Paragraph((String) comboProfes.getSelectionModel().getSelectedItem(),
                titleFont);
        document.add(docTitle);
        Font textH1 = FontFactory.getFont(FontFactory.TIMES_ITALIC, 14, BaseColor.BLACK);
        switch (opcion) {
        case 0:
            crearTablaEnPDF(document, textH1);
            break;
        case 1:
            crearListaClasesDiariasPDF(document, textH1);
            break;
        case 2:
            crearTablaEnPDF(document, textH1);
            crearListaClasesDiariasPDF(document, textH1);
            break;
        }
        document.close();
        file.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:jsimpresos.ConexionNotas.java

public void generarPdf(int idNota, String nombre, int cuenta) {
    Document documento = new Document();
    Nota nota = this.getNotaPorId(idNota);
    FileOutputStream ficheroPdf;//from  ww  w  . j ava  2  s  .c  o  m
    try {
        File carpeta = new File("C:\\archivosPuntoDeVenta");
        if (!carpeta.exists()) {
            carpeta.mkdir();
        }
        ficheroPdf = new FileOutputStream("c:/archivosPuntoDeVenta/" + nombre + cuenta + ".pdf");
        PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20);
        documento.setMargins(0, 0, 0, 0);
        documento.open();
        Image foto = Image.getInstance("c:/archivosPuntoDeVenta/logo.JPG");
        foto.scaleToFit(80, 90);
        PdfPTable tabla = new PdfPTable(5);
        tabla.setWidths(new float[] { 13, 12, 25, 25, 25 });
        tabla.setWidthPercentage(100);
        PdfPCell celda = new PdfPCell();
        celda.addElement(foto);
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setRowspan(6);
        tabla.addCell(celda);
        PdfPCell celda2 = new PdfPCell(
                new Paragraph("NOTA DE PEDIDO", FontFactory.getFont("Arial", 15, Font.BOLD)));
        System.out.println(nota.getUsuario());
        celda2.setColspan(3);
        celda2.setUseAscender(true);
        celda2.setBorder(Rectangle.NO_BORDER);
        celda2.setVerticalAlignment(Element.ALIGN_MIDDLE);
        tabla.addCell(celda2);
        PdfPCell celdaFecha = new PdfPCell(new Paragraph("Fecha: " + nota.getFecha()));
        celdaFecha.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celdaFecha);
        PdfPCell celda3 = new PdfPCell(new Phrase("Calle del Rayo y 2 de Abril 31a. Col. centro, Parral, Chih.",
                FontFactory.getFont("Arial", 7, Font.BOLD, BaseColor.RED)));
        celda3.setColspan(2);
        celda3.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celda3);
        PdfPCell celda4 = new PdfPCell(new Phrase("Tel. 5230073 y 6271034745",
                FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.RED)));
        celda4.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celda4);
        Paragraph p = new Paragraph("No. " + nota.getIdNota(),
                FontFactory.getFont("Arial", 13, Font.BOLD, BaseColor.RED));
        PdfPCell celda5 = new PdfPCell();
        celda5.setUseAscender(true);
        celda5.setVerticalAlignment(Element.ALIGN_MIDDLE);
        celda5.setHorizontalAlignment(Element.ALIGN_MIDDLE);
        celda5.addElement(p);
        tabla.addCell(celda5);
        PdfPCell celdanueva = new PdfPCell(
                new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        celdanueva.setBorder(Rectangle.NO_BORDER);
        celdanueva.setColspan(4);
        tabla.addCell(celdanueva);
        PdfPCell celdanueva1 = new PdfPCell(
                new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        celdanueva1.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celdanueva1);
        PdfPCell celdanueva2 = new PdfPCell(
                new Phrase("Datos del cliente", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        celdanueva2.setBorder(Rectangle.NO_BORDER);
        celdanueva2.setColspan(3);
        tabla.addCell(celdanueva2);
        PdfPCell celdanueva3 = new PdfPCell(
                new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        celdanueva3.setBorder(Rectangle.NO_BORDER);
        tabla.addCell(celdanueva3);
        if (nota.getCliente() == null) {
            PdfPCell celda6 = new PdfPCell(
                    new Phrase("Cliente:        " + nota.getNombres() + " " + nota.getApPaterno(),
                            FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
            celda6.setBorder(Rectangle.NO_BORDER);
            celda6.setColspan(3);
            tabla.addCell(celda6);
            PdfPCell celdanueva4 = new PdfPCell(
                    new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
            celdanueva4.setBorder(Rectangle.NO_BORDER);
            tabla.addCell(celdanueva4);
            PdfPCell celda7 = new PdfPCell(new Phrase("Domicilio:       " + nota.getDomicilio(),
                    FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
            celda7.setBorder(Rectangle.NO_BORDER);
            celda7.setColspan(2);
            tabla.addCell(celda7);
            PdfPCell celda8 = new PdfPCell(new Phrase("Telfono: " + nota.getTelefono(),
                    FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
            celda8.setBorder(Rectangle.NO_BORDER);
            tabla.addCell(celda8);

        } else {
            PdfPCell celda6 = new PdfPCell(new Phrase(
                    "Cliente:        " + nota.getCliente().getNombres() + " "
                            + nota.getCliente().getApPaterno(),
                    FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
            celda6.setBorder(Rectangle.NO_BORDER);
            celda6.setColspan(3);
            tabla.addCell(celda6);
            PdfPCell celdanueva4 = new PdfPCell(
                    new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
            celdanueva4.setBorder(Rectangle.NO_BORDER);
            tabla.addCell(celdanueva4);
            PdfPCell celda7 = new PdfPCell(new Phrase("Domicilio:     " + nota.getCliente().getDomicilio(),
                    FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
            celda7.setBorder(Rectangle.NO_BORDER);
            celda7.setColspan(2);
            tabla.addCell(celda7);
            PdfPCell celda8 = new PdfPCell(new Phrase("Telfono: " + nota.getCliente().getTelefono(),
                    FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
            celda8.setBorder(Rectangle.NO_BORDER);
            tabla.addCell(celda8);
        }
        PdfPTable tabla2 = new PdfPTable(4);
        tabla2.setWidths(new float[] { 10, 70, 15, 15 });
        tabla2.setWidthPercentage(99.5f);
        PdfPCell celda21 = new PdfPCell(
                new Phrase("Cantidad", FontFactory.getFont("Arial", 11, Font.BOLD, BaseColor.BLACK)));
        tabla2.addCell(celda21);
        PdfPCell celda22 = new PdfPCell(
                new Phrase("Artculo", FontFactory.getFont("Arial", 11, Font.BOLD, BaseColor.BLACK)));
        tabla2.addCell(celda22);
        PdfPCell celda23 = new PdfPCell(
                new Phrase("Precio unitario", FontFactory.getFont("Arial", 11, Font.BOLD, BaseColor.BLACK)));
        tabla2.addCell(celda23);
        PdfPCell celda24 = new PdfPCell(
                new Phrase("Total", FontFactory.getFont("Arial", 11, Font.BOLD, BaseColor.BLACK)));
        tabla2.addCell(celda24);
        double total = 0;
        for (int i = 0; i < 6; i++) {
            if (i < nota.getArticulos().size()) {
                PdfPCell celda25 = new PdfPCell(new Phrase(nota.getArticulos().get(i).getCantidad() + "",
                        FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
                tabla2.addCell(celda25);
                PdfPCell celda26 = new PdfPCell(new Phrase(nota.getArticulos().get(i).getServicio() + "",
                        FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
                tabla2.addCell(celda26);
                PdfPCell celda27 = new PdfPCell(new Phrase(nota.getArticulos().get(i).getPrecio() + "",
                        FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
                tabla2.addCell(celda27);
                PdfPCell celda28 = new PdfPCell(new Phrase(
                        (nota.getArticulos().get(i).getCantidad() * nota.getArticulos().get(i).getPrecio())
                                + "",
                        FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
                tabla2.addCell(celda28);
                total += nota.getArticulos().get(i).getCantidad() * nota.getArticulos().get(i).getPrecio();
            } else {
                PdfPCell celda29 = new PdfPCell(
                        new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
                tabla2.addCell(celda29);
                tabla2.addCell(celda29);
                tabla2.addCell(celda29);
                tabla2.addCell(celda29);
            }

        }
        PdfPTable tabla3 = new PdfPTable(4);
        tabla3.setWidths(new float[] { 55, 25, 15, 15 });
        tabla3.setWidthPercentage(99.5f);
        PdfPCell celda31 = new PdfPCell(new Phrase("Observaciones: " + nota.getObservaciones(),
                FontFactory.getFont("Arial", 9, BaseColor.BLACK)));
        celda31.setRowspan(4);
        tabla3.addCell(celda31);
        PdfPCell celda32 = new PdfPCell(new Phrase(
                "Suma recibida de abono : " + nota.getAbonos().get(nota.getAbonos().size() - 1).getMonto(),
                FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        celda32.setRowspan(4);
        tabla3.addCell(celda32);
        PdfPCell celda33 = new PdfPCell(
                new Phrase("Total", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        tabla3.addCell(celda33);
        PdfPCell celda34 = new PdfPCell(
                new Phrase(total + "", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        tabla3.addCell(celda34);
        PdfPCell celda35 = new PdfPCell(
                new Phrase("Total abonado", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        tabla3.addCell(celda35);
        double totalAbonado = 0;
        for (int i = 0; i < nota.getAbonos().size(); i++) {
            totalAbonado += nota.getAbonos().get(i).getMonto();

        }
        PdfPCell celda36 = new PdfPCell(
                new Phrase(totalAbonado + "", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        tabla3.addCell(celda36);
        PdfPCell celda37 = new PdfPCell(
                new Phrase("Saldo actual", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        tabla3.addCell(celda37);
        PdfPCell celda38 = new PdfPCell(new Phrase((total - totalAbonado) + "",
                FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        tabla3.addCell(celda38);
        PdfPCell celda39 = new PdfPCell(
                new Phrase("Fecha entrega", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        tabla3.addCell(celda39);
        PdfPCell celda40 = new PdfPCell(new Phrase(nota.getFechaEntrega(),
                FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        tabla3.addCell(celda40);
        PdfPTable tabla4 = new PdfPTable(3);
        tabla4.setWidths(new float[] { 30, 30, 30 });
        tabla4.setWidthPercentage(99.5f);
        PdfPCell celda41 = new PdfPCell(
                new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        celda41.setBorder(Rectangle.NO_BORDER);
        celda41.setColspan(3);
        tabla4.addCell(celda41);
        PdfPCell celda42 = new PdfPCell(
                new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        celda42.setBorder(Rectangle.NO_BORDER);
        tabla4.addCell(celda42);
        PdfPCell celda43 = new PdfPCell(new Phrase("Firma de conformidad del cliente: ",
                FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        celda43.setBorder(Rectangle.NO_BORDER);
        tabla4.addCell(celda43);
        PdfPCell celda44 = new PdfPCell(
                new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK)));
        celda44.setBorder(Rectangle.NO_BORDER);
        tabla4.addCell(celda44);
        tabla4.addCell(celda41);
        tabla4.addCell(celda41);
        tabla4.addCell(celda41);
        documento.add(tabla);
        documento.add(tabla2);
        documento.add(tabla3);
        documento.add(tabla4);
        documento.add(tabla);
        documento.add(tabla2);
        documento.add(tabla3);
        documento.add(tabla4);

        documento.close();

        abrirPDF("c:/archivosPuntoDeVenta/" + nombre + cuenta + ".pdf");
    } catch (FileNotFoundException ex) {
        //            JOptionPane.showMessageDialog(null, "Error con el pdf");
        //            System.out.println(ex.getMessage());
        cuenta++;
        generarPdf(idNota, "nota", cuenta);
        abrirPDF("c:/archivosPuntoDeVenta/" + nombre + cuenta + ".pdf");
    } catch (DocumentException ex) {
        JOptionPane.showMessageDialog(null, "Error al guardar pdf");
        System.out.println(ex.getMessage());
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null, "Error con el pdf");
    }
}

From source file:logica.Generar_pdf.java

public void ConvertirPDF(int num, String nombre, String nombre2, String cedula, String cedula2,
        String direccion, String direccion2, String telefono, String telefono2, String sede, String tipo,
        String observacion, int peso, int declaracion_precio, int precio_neto, int precio_seguro,
        int precio_impuesto, int total_envio, String forma_pago, String fecha) throws FileNotFoundException {
    String nombre_pdf = "Factura No " + num + ".pdf";
    System.out.println(nombre_pdf);
    try {//  ww w  . j ava  2 s  . co  m
        //Creamos documento indicando el tamao y margenes
        Document documento = new Document(PageSize.LETTER, 20, 20, 20, 20);

        //Creamos el PDF y lo instanceamos para poder escribir sobre el
        PdfWriter.getInstance(documento, new FileOutputStream(nombre_pdf)).setInitialLeading(20);

        //Abrimos el documento
        documento.open();
        System.out.println("Documento Abierto");

        //Anexamos el texto a un objeto Pharagraph
        Paragraph parametro = new Paragraph("Factura Envio de Paquete No. " + num,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, Font.BOLD, BaseColor.BLACK));
        parametro.setAlignment(1);
        Paragraph parametro17 = new Paragraph("Fecha: " + fecha,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, Font.BOLD, BaseColor.BLACK));
        parametro17.setAlignment(1);
        Paragraph parametro2 = new Paragraph("Datos Remitente",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro3 = new Paragraph("Nombre: " + nombre + "        Telefono: " + telefono,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro4 = new Paragraph("Cedula: " + cedula + "        Direccin: " + direccion,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro5 = new Paragraph("Datos Destinatario",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro6 = new Paragraph("Nombre: " + nombre2 + "        Telefono: " + telefono2,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro7 = new Paragraph("Cedula: " + cedula2 + "        Direccin: " + direccion2,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));

        Paragraph parametro8 = new Paragraph("Datos Envio",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro9 = new Paragraph("Tipo de Envio: " + tipo + "        Observacin: " + observacion,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro10 = new Paragraph(
                "Peso: " + peso + "        Declaracin precio Envio: " + declaracion_precio,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro11 = new Paragraph("Datos Pago",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro12 = new Paragraph("Precio de Envio Neto: " + precio_neto,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro13 = new Paragraph("Precio Seguro:  " + precio_seguro,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro14 = new Paragraph("Excedente Impuesto:  " + precio_impuesto,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro15 = new Paragraph("Total Envio:  " + total_envio,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro16 = new Paragraph("Forma de Pago:  " + forma_pago,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));

        //Escribimos sobre el
        documento.add(parametro);
        documento.add(parametro17);
        documento.add(parametro2);
        documento.add(parametro3);
        documento.add(parametro4);
        documento.add(parametro5);
        documento.add(parametro6);
        documento.add(parametro7);
        documento.add(parametro8);
        documento.add(parametro9);
        documento.add(parametro10);
        documento.add(parametro11);
        documento.add(parametro12);
        documento.add(parametro13);
        documento.add(parametro14);
        documento.add(parametro15);
        documento.add(parametro16);

        //Cerrar documento
        documento.close();

        //Mensaje de Exito
        JOptionPane.showMessageDialog(null, "PDF Creado con exito.");

    } catch (DocumentException de) {
        System.out.println("Error...");
    }

}

From source file:login.DigiHoInitial.java

private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed
    // TODO add your handling code here:
    Calendar timer = Calendar.getInstance();
    timer.getTime();//from w w w  . j  ava 2 s. com
    SimpleDateFormat Tdate = new SimpleDateFormat("dd-MMM-yyy");
    jTextField17.setText(Tdate.format(timer.getTime()));
    jLabel15.setText("");
    Random rand = new Random();
    int number, number1;
    number = rand.nextInt(8999);
    number1 = 1000 + number;

    jTextField11.setText(jTextField11.getText() + number1);

    Document doc = new Document();
    try {
        PdfWriter.getInstance(doc,
                new FileOutputStream("f:\\DiGiho\\Registration Form\\" + jTextField11.getText() + ".pdf"));
        doc.open();
        Paragraph para = new Paragraph();
        doc.add(new Paragraph("\n",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.DARK_GRAY)));
        doc.add(new Paragraph("\n\n\n\n\n\n\n\n\n\n"));
        doc.add(new Phrase("Customer ID         "));
        doc.add(new Phrase(jTextField11.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("                                                    Date          "
                + jTextField17.getText() + "   \n\n"));
        doc.add(new Phrase("Name:-                   "));
        doc.add(new Phrase(jTextField5.getText() + ". " + jTextField6.getText() + " " + jTextField1.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nFather's Name:-     "));
        doc.add(new Phrase(jTextField2.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nAddress                "));
        doc.add(new Phrase(jTextField3.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nBlock                    "));
        doc.add(new Phrase(jTextField16.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("                                           District                  "));
        doc.add(new Phrase(jTextField10.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nCity                       "));
        doc.add(new Phrase(jTextField15.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("                                                Pin Code                  "));
        doc.add(new Phrase(jTextField9.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase());
        doc.add(new Phrase("\nState                    "));
        doc.add(new Phrase(jTextField14.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("                                                   Date of Birth             "));
        doc.add(new Phrase(jTextField12.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nMoblie No.           "));
        doc.add(new Phrase(jTextField7.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("                                         Phone No.                 "));
        doc.add(new Phrase(jTextField13.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase());
        doc.add(new Phrase("\nEmail address          "));
        doc.add(new Phrase(jTextField8.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nOccupation:          "));
        doc.add(new Phrase(a, FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(para);
        doc.add(new Phrase(
                "          \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n                         "
                        + jTextField6.getText() + "  " + jTextField1.getText()));
        doc.close();
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(DigiHoInitial.class.getName()).log(Level.SEVERE, null, ex);
    }
    JOptionPane.showMessageDialog(null, "File has been created", "deeps message", JOptionPane.PLAIN_MESSAGE);

}