Example usage for com.itextpdf.text Font NORMAL

List of usage examples for com.itextpdf.text Font NORMAL

Introduction

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

Prototype

int NORMAL

To view the source code for com.itextpdf.text Font NORMAL.

Click Source Link

Document

this is a possible style.

Usage

From source file:rs.marko.helper.Kreiranje.java

public static File createPdfStatistika(List<Stavkadnevneberbe> stavke, Date pocetak, Date kraj) {
    Document document = new Document();
    File yourFile = null;/*from  w  w  w . j a  va  2s . c o  m*/
    try {
        yourFile = new File(System.getProperty("user.home") + "/Desktop/" + pocetak + "_" + kraj + ".pdf");
        if (!yourFile.exists()) {
            yourFile.createNewFile();
        }
        FileOutputStream oFile = new FileOutputStream(yourFile, false);
        document.setPageSize(PageSize.A4.rotate());
        PdfWriter.getInstance(document, oFile);
        document.open();
        //                        String text = "";
        //                        for (int i = 0; i < 10000; i++) {
        //                                text += "test";
        //              ,          }
        //            String jmbg = stavke.get(0).getDobavljac().getJmbg();

        PdfPTable table = new PdfPTable(
                new float[] { 300f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f });
        table.setWidthPercentage(100);
        table.setSpacingBefore(0f);
        table.setSpacingAfter(0f);
        Paragraph p = new Paragraph("Od: " + pocetak + " do: " + kraj);
        p.add(new Paragraph(" "));
        document.add(p);
        PdfPCell c = new PdfPCell(new Phrase(""));
        //            PdfPCell c1 = new PdfPCell(new Phrase("Sifra"));
        //            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        //            c1.setRowspan(2);
        //            c1.setColspan(2);
        //            table.addCell(c1);
        PdfPCell c1 = new PdfPCell(new Phrase("Dobavljac"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setVerticalAlignment(Element.ALIGN_MIDDLE);
        c1.setRowspan(2);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Tacne"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("I Klasa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("II Klasa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("III Klasa"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Svega"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(3);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Kol"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Iznos"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Kol"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Iznos"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Kol"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Iznos"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Kol"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Iznos"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Kol"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Cena"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase("Iznos"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(c1);

        Font font = new Font(BaseFont.createFont(), 10, Font.NORMAL);

        //                table.setHeaderRows(3);
        List<String> jmbgovi = new ArrayList<>();
        Map<Double, Double> kt = new HashMap<>();
        Map<Double, Double> k1 = new HashMap<>();
        Map<Double, Double> k2 = new HashMap<>();
        Map<Double, Double> k3 = new HashMap<>();

        Map<Double, Double> ukupnoTacneVrednost = new HashMap<>();
        Map<Double, Double> ukupnoPrvaKlasaVrednost = new HashMap<>();
        Map<Double, Double> ukupnoDrugaKlasaVrednost = new HashMap<>();
        Map<Double, Double> ukupnoTrecaKlasaVrednost = new HashMap<>();
        for (Stavkadnevneberbe stavkaDnevneBerbe : stavke) {
            if (!jmbgovi.contains(stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg())) {
                jmbgovi.add(stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg());
            }
        }
        Double ukupnoKolicinaTacne = 0.0;
        Double ukupnoKolicinaPrvaKlasa = 0.0;
        Double ukupnoKolicinaDrugaKlasa = 0.0;
        Double ukupnoKolicinaTrecaKlasa = 0.0;
        Double ukupnoCenaTacne = 0.0;
        Double ukupnoCenaPrvaKlasa = 0.0;
        Double ukupnoCenaDrugaKlasa = 0.0;
        Double ukupnoCenaTrecaKlasa = 0.0;
        Double ukupanIznosSvih = 0.0;
        for (String j : jmbgovi) {
            String imeDobavljaca = null;
            for (Stavkadnevneberbe stavkaDnevneBerbe : stavke) {
                if (stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg().equals(j)) {
                    if (imeDobavljaca == null) {
                        imeDobavljaca = stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getIme() + " "
                                + stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getPrezime();

                    }
                    if (!kt.containsKey(stavkaDnevneBerbe.getCenatacne())
                            && stavkaDnevneBerbe.getTacne() != 0) {
                        kt.put(stavkaDnevneBerbe.getCenatacne(), new Double(0));
                    }
                    if (!k1.containsKey(stavkaDnevneBerbe.getCenaprvaklasa())
                            && stavkaDnevneBerbe.getCenaprvaklasa() != 0) {
                        k1.put(stavkaDnevneBerbe.getCenaprvaklasa(), new Double(0));
                    }
                    if (!k2.containsKey(stavkaDnevneBerbe.getCenadrugaklasa())
                            && stavkaDnevneBerbe.getCenadrugaklasa() != 0) {
                        k2.put(stavkaDnevneBerbe.getCenadrugaklasa(), new Double(0));
                    }
                    if (!k3.containsKey(stavkaDnevneBerbe.getCenatrecaklasa())
                            && stavkaDnevneBerbe.getCenatrecaklasa() != 0) {
                        k3.put(stavkaDnevneBerbe.getCenatrecaklasa(), new Double(0));
                    }
                }
            }
            for (Stavkadnevneberbe s : stavke) {
                if (s.getDnevnaberba().getDobavljac().getJmbg().equals(j)) {
                    if (kt.containsKey(s.getCenatacne())) {
                        kt.put(s.getCenatacne(), kt.get(s.getCenatacne()) + s.getTacne());
                    }
                    if (k1.containsKey(s.getCenaprvaklasa())) {
                        k1.put(s.getCenaprvaklasa(), k1.get(s.getCenaprvaklasa()) + s.getPrvaklasa());
                    }
                    if (k2.containsKey(s.getCenadrugaklasa())) {
                        k2.put(s.getCenadrugaklasa(), k2.get(s.getCenadrugaklasa()) + s.getDrugaklasa());
                    }
                    if (k3.containsKey(s.getCenatrecaklasa())) {
                        k3.put(s.getCenatrecaklasa(), k3.get(s.getCenatrecaklasa()) + s.getTrecaklasa());
                    }
                }
            }
            c1 = new PdfPCell(new Phrase(imeDobavljaca));
            c1.setHorizontalAlignment(Element.ALIGN_CENTER);
            c1.setColspan(2);
            table.addCell(c1);
            Iterator it = kt.entrySet().iterator();
            Double ukupnoKolicinaT = 0.0;
            Double ukupnoCenaT = 0.0;
            Double ukupanIznos = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                ukupnoKolicinaT += (Double) pair.getValue();
                ukupnoCenaT += (Double) pair.getKey();
                ukupanIznos += ((Double) pair.getValue() * (Double) pair.getKey());
                //ukupno vrednost
                if (ukupnoTacneVrednost.containsKey((Double) pair.getKey())) {
                    ukupnoTacneVrednost.put((Double) pair.getKey(),
                            ukupnoTacneVrednost.get((Double) pair.getKey())
                                    + ((Double) pair.getKey() * (Double) pair.getValue()));
                } else {
                    ukupnoTacneVrednost.put((Double) pair.getKey(),
                            (Double) pair.getKey() * (Double) pair.getValue());
                }
            }
            c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaT, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupanIznos, 2) + "", font));
            table.addCell(c1);

            it = k1.entrySet().iterator();
            Double ukupnoKolicinaP = 0.0;
            Double ukupnoCenaP = 0.0;
            Double ukupanIznosP = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                ukupnoKolicinaP += (Double) pair.getValue();
                ukupnoCenaP += (Double) pair.getKey();
                ukupanIznosP += ((Double) pair.getValue() * (Double) pair.getKey());
                if (ukupnoPrvaKlasaVrednost.containsKey((Double) pair.getKey())) {
                    ukupnoPrvaKlasaVrednost.put((Double) pair.getKey(),
                            ukupnoPrvaKlasaVrednost.get((Double) pair.getKey())
                                    + ((Double) pair.getKey() * (Double) pair.getValue()));
                } else {
                    ukupnoPrvaKlasaVrednost.put((Double) pair.getKey(),
                            (Double) pair.getKey() * (Double) pair.getValue());
                }
            }
            c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaP, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupanIznosP, 2) + "", font));
            table.addCell(c1);

            it = k2.entrySet().iterator();
            Double ukupnoKolicinaD = 0.0;
            Double ukupnoCenaD = 0.0;
            Double ukupanIznosD = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                ukupnoKolicinaD += (Double) pair.getValue();
                ukupnoCenaD += (Double) pair.getKey();
                ukupanIznosD += ((Double) pair.getValue() * (Double) pair.getKey());
                if (ukupnoDrugaKlasaVrednost.containsKey((Double) pair.getKey())) {
                    ukupnoDrugaKlasaVrednost.put((Double) pair.getKey(),
                            ukupnoDrugaKlasaVrednost.get((Double) pair.getKey())
                                    + ((Double) pair.getKey() * (Double) pair.getValue()));
                } else {
                    ukupnoDrugaKlasaVrednost.put((Double) pair.getKey(),
                            (Double) pair.getKey() * (Double) pair.getValue());
                }
            }
            c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaD, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupanIznosD, 2) + "", font));
            table.addCell(c1);

            it = k3.entrySet().iterator();
            Double ukupnoKolicinaTr = 0.0;
            Double ukupnoCenaTr = 0.0;
            Double ukupanIznosT = 0.0;
            while (it.hasNext()) {
                Map.Entry pair = (Map.Entry) it.next();
                ukupnoKolicinaTr += (Double) pair.getValue();
                ukupnoCenaTr += (Double) pair.getKey();
                ukupanIznosT += ((Double) pair.getValue() * (Double) pair.getKey());
                if (ukupnoTrecaKlasaVrednost.containsKey((Double) pair.getKey())) {
                    ukupnoTrecaKlasaVrednost.put((Double) pair.getKey(),
                            ukupnoTrecaKlasaVrednost.get((Double) pair.getKey())
                                    + ((Double) pair.getKey() * (Double) pair.getValue()));
                } else {
                    ukupnoTrecaKlasaVrednost.put((Double) pair.getKey(),
                            (Double) pair.getKey() * (Double) pair.getValue());
                }
            }
            c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaTr, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupanIznosT, 2) + "", font));
            table.addCell(c1);
            Double ukupnoKolicina = ukupnoKolicinaT + ukupnoKolicinaP + ukupnoKolicinaD + ukupnoKolicinaTr;
            Double ukupnoVrednost = ukupanIznos + ukupanIznosP + ukupanIznosD + ukupanIznosT;
            Double ukupnoCena = ukupnoVrednost / ukupnoKolicina;
            c1 = new PdfPCell(new Phrase(round(ukupnoKolicina, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupnoCena, 2) + "", font));
            table.addCell(c1);
            c1 = new PdfPCell(new Phrase(round(ukupnoVrednost, 2) + "", font));
            table.addCell(c1);

            ukupanIznosSvih += ukupnoVrednost;

            ukupnoKolicinaTacne += ukupnoKolicinaT;
            ukupnoKolicinaPrvaKlasa += ukupnoKolicinaP;
            ukupnoKolicinaDrugaKlasa += ukupnoKolicinaD;
            ukupnoKolicinaTrecaKlasa += ukupnoKolicinaTr;

            ukupnoCenaTacne += ukupanIznos;
            ukupnoCenaPrvaKlasa += ukupanIznosP;
            ukupnoCenaDrugaKlasa += ukupanIznosD;
            ukupnoCenaTrecaKlasa += ukupanIznosT;

            kt.clear();
            k1.clear();
            k2.clear();
            k3.clear();
        }
        c1 = new PdfPCell(new Phrase("UKUPNO"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoKolicinaTacne + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoCenaTacne + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoKolicinaPrvaKlasa + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoCenaPrvaKlasa + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoKolicinaDrugaKlasa + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoCenaDrugaKlasa + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoKolicinaTrecaKlasa + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(ukupnoCenaTrecaKlasa + "", font));
        table.addCell(c1);

        Double ukupnoKolicinaSve = ukupnoKolicinaTacne + ukupnoKolicinaPrvaKlasa + ukupnoKolicinaDrugaKlasa
                + ukupnoKolicinaTrecaKlasa;
        Double prosecnaCena = ukupanIznosSvih / ukupnoKolicinaSve;

        c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaSve, 2) + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(round(prosecnaCena, 2) + "", font));
        table.addCell(c1);
        c1 = new PdfPCell(new Phrase(round(ukupanIznosSvih, 2) + "", font));
        table.addCell(c1);

        //PDV
        c1 = new PdfPCell(new Phrase("PDV"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);
        table.addCell(c);

        Iterator it = ukupnoTacneVrednost.entrySet().iterator();
        Double ukupnoTacnePdv = 0.0;
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            if ((Double) pair.getKey() == 110) {
                ukupnoTacnePdv += (((Double) pair.getValue() / (Double) pair.getKey()) * 106);
            } else {
                ukupnoTacnePdv += (Double) pair.getValue();
            }
        }
        c1 = new PdfPCell(new Phrase(round(ukupnoTacnePdv * (110.0f / 100.0f), 2) + "", font));
        table.addCell(c1);
        table.addCell(c);

        it = ukupnoPrvaKlasaVrednost.entrySet().iterator();
        Double ukupnoPrvaKlasaPdv = 0.0;
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            ukupnoPrvaKlasaPdv += (Double) pair.getValue();
        }
        c1 = new PdfPCell(new Phrase(round(ukupnoPrvaKlasaPdv * (110.0f / 100.0f), 2) + "", font));
        table.addCell(c1);
        table.addCell(c);

        it = ukupnoDrugaKlasaVrednost.entrySet().iterator();
        Double ukupnoDrugaKlasaPdv = 0.0;
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            ukupnoDrugaKlasaPdv += (Double) pair.getValue();
        }
        c1 = new PdfPCell(new Phrase(round(ukupnoDrugaKlasaPdv * (110.0f / 100.0f), 2) + "", font));
        table.addCell(c1);
        table.addCell(c);

        it = ukupnoTrecaKlasaVrednost.entrySet().iterator();
        Double ukupnoTrecaKlasaPdv = 0.0;
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry) it.next();
            ukupnoTrecaKlasaPdv += (Double) pair.getValue();
        }
        c1 = new PdfPCell(new Phrase(round(ukupnoTrecaKlasaPdv * (110.0f / 100.0f), 2) + "", font));
        table.addCell(c1);
        c = new PdfPCell(new Phrase(""));
        c.setColspan(2);
        table.addCell(c);

        Double ukupnoSvePDV = ukupnoTacnePdv + ukupnoPrvaKlasaPdv + ukupnoDrugaKlasaPdv + ukupnoTrecaKlasaPdv;
        c1 = new PdfPCell(new Phrase(round(ukupnoSvePDV * (110.0f / 100.0f), 2) + "", font));
        table.addCell(c1);

        c = new PdfPCell(new Phrase(""));
        c.setColspan(10);
        table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);
        //            table.addCell(c);

        c1 = new PdfPCell(new Phrase("DOBITAK"));
        c1.setHorizontalAlignment(Element.ALIGN_CENTER);
        c1.setColspan(2);
        table.addCell(c1);

        c1 = new PdfPCell(
                new Phrase(round((ukupnoSvePDV * (110.0f / 100.0f)) - ukupanIznosSvih, 2) + "", font));
        table.addCell(c1);

        document.add(table);
        document.add(new Paragraph(" "));
    } catch (DocumentException ex) {
        Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex);
    }
    document.close();
    return yourFile;
}

From source file:se.inera.intyg.rehabstod.service.export.pdf.PdfExportServiceImpl.java

License:Open Source License

@Override
public byte[] export(List<SjukfallEnhet> sjukfallList, PrintSjukfallRequest printSjukfallRequest,
        RehabstodUser user, int total) {

    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    try {// www .ja  v  a  2s .  c om
        unicodeCapableFont = new Font(
                BaseFont.createFont(UNICODE_CAPABLE_FONT_PATH, BaseFont.IDENTITY_H, BaseFont.EMBEDDED), 9,
                Font.NORMAL);

        Document document = new Document();
        document.setPageSize(PageSize.A4);
        document.setMargins(20, 20, 60, 20);

        PdfWriter writer = PdfWriter.getInstance(document, bos);
        // Add handlers for page events

        writer.setPageEvent(new HeaderEventHandler(
                Image.getInstance(
                        IOUtils.toByteArray(resourcePatternResolver.getResource(LOGO_PATH).getInputStream())),
                user.getNamn(), user.getValdVardenhet().getNamn()));
        writer.setPageEvent(new PageNumberingEventHandler());

        document.open();

        // Add the front page with meta info
        document.add(createFrontPage(printSjukfallRequest, user, sjukfallList.size(), total));

        // Switch to landscape mode
        document.setPageSize(PageSize.A4.rotate());
        document.newPage();

        // Add table with all sjukfall (could span several pages)
        document.add(createSjukfallTable(sjukfallList, user.getUrval(), printSjukfallRequest.isShowPatientId(),
                isSrsFeatureActive(user)));

        // Finish off by closing the document (will invoke the event handlers)
        document.close();

    } catch (DocumentException | IOException | RuntimeException e) {
        throw new PdfExportServiceException("Failed to create PDF export!", e);
    }

    return bos.toByteArray();
}

From source file:server.kartu.tik.iText.java

public String createPDF(String tanggal, ArrayList kegiatan, String divisi) {
    ArrayList<Kegiatan> list = new ArrayList<>(kegiatan);

    String output = System.getProperty("user.dir") + "\\src\\data\\pdf\\" + tanggal + " " + getNamalengkap()
            + "-" + getTglnoktp() + ".pdf";

    String namaDivisi = "";
    switch (divisi) {
    case "1":
        namaDivisi = "Ekonomi";
        break;/*from w  w  w  .j  av a  2  s  .c o  m*/
    case "2":
        namaDivisi = "Politik";
        break;
    case "3":
        namaDivisi = "Sosial Budaya";
        break;
    case "4":
        namaDivisi = "Keamanan";
        break;
    }

    Document document = new Document(PageSize.A4);
    try {
        PdfWriter.getInstance(document, new FileOutputStream(output));

        document.open();

        //------------------------------------------------------------------------------------- TITLE
        PdfPTable title = new PdfPTable(1);
        title.setWidthPercentage(100);
        Font f = new Font(FontFamily.HELVETICA, 14, Font.NORMAL, GrayColor.GRAYWHITE);
        PdfPCell celltitle = new PdfPCell(new Phrase("KARTU TIK (" + namaDivisi + ")", f));
        celltitle.setMinimumHeight(20);
        celltitle.setBackgroundColor(GrayColor.GRAYBLACK);
        celltitle.setHorizontalAlignment(Element.ALIGN_CENTER);
        celltitle.setColspan(3);
        title.addCell(celltitle);
        document.add(title);
        //-------------------------------------------------------------------------------------- END

        //------------------------------------------------------------------------------------- NAMA + ALIAS
        float[] columnWidths = { 8, 2 };
        PdfPTable tabel1 = new PdfPTable(columnWidths);
        tabel1.setWidthPercentage(100);

        PdfPTable innerTable1 = new PdfPTable(1);
        innerTable1.setWidthPercentage(100);
        PdfPTable innerTable2 = new PdfPTable(1);
        innerTable2.setWidthPercentage(100);
        PdfPCell cell;
        innerTable1.addCell(
                "1.  a. Nama Lengkap : " + getNamalengkap() + " \n\n     b. Alias : " + getAlias() + " \n\n");
        innerTable1.addCell("2.  Kebangsaan \n     a. Tgl. No. KTP : " + getTglnoktp()
                + " \n\n     b. Tgl. No. Pasport : " + getTglnopasport() + "\n\n");
        innerTable1.addCell("3.  Agama : " + getAgama());
        cell = new PdfPCell(innerTable1);
        cell.setMinimumHeight(135);
        tabel1.addCell(cell);
        if (getUrlfoto().equalsIgnoreCase("") || getUrlfoto().isEmpty() || getUrlfoto() == null) {

        } else {
            Image image = Image.getInstance(getUrlfoto());
            cell = new PdfPCell(image, false);
            if (image.getWidth() < 90) {
                cell.setPaddingLeft(8);
            } else {
                cell.setPaddingLeft(3);
            }
        }
        cell.setMinimumHeight(135);
        tabel1.addCell(cell);
        cell = new PdfPCell();
        cell.setColspan(14);
        tabel1.addCell(cell);

        document.add(tabel1);
        //------------------------------------------------------------------------------------- NAMA + ALIAS END

        //------------------------------------------------------------------------------------- TGL LAHIR + TEMPAT
        PdfPTable tabel4 = new PdfPTable(1);
        tabel4.setWidthPercentage(100);

        Paragraph pTglLahirnTempat = new Paragraph();
        pTglLahirnTempat.add("4.  a. Tgl. Lahir/ Umur : " + getTgllahir());
        pTglLahirnTempat.add("\n\n     b. Tempat Lahir     : " + getTempatlahir());
        pTglLahirnTempat.setLeading(0, 1);

        PdfPCell cTglLahirnTempat = new PdfPCell();
        cTglLahirnTempat.setMinimumHeight(45);
        cTglLahirnTempat.addElement(pTglLahirnTempat);
        tabel4.addCell(cTglLahirnTempat);

        document.add(tabel4);
        //------------------------------------------------------------------------------------- TGL LAHIR + TEMPAT END

        //------------------------------------------------------------------------------------- ALAMAT + PINDAHAN
        PdfPTable tabel5 = new PdfPTable(1);
        tabel5.setWidthPercentage(100);

        Paragraph pAlamat = new Paragraph();
        pAlamat.add("5.  Alamat : ");
        pAlamat.add(alamat);
        pAlamat.setLeading(0, 1);

        PdfPCell cAlamat = new PdfPCell();
        cAlamat.setMinimumHeight(18);
        cAlamat.addElement(pAlamat);
        tabel5.addCell(cAlamat);
        document.add(tabel5);

        PdfPTable tabel51 = new PdfPTable(1);
        tabel51.setWidthPercentage(100);

        Paragraph pAlamatUbah = new Paragraph();
        pAlamatUbah.add("6.  Perubahan Alamat :");
        pAlamatUbah.add("\n\n    1. ");
        pAlamatUbah.add("\n\n    2. ");
        pAlamatUbah.add("\n\n    3. ");
        pAlamatUbah.add("\n\n");
        pAlamatUbah.setLeading(0, 1);

        PdfPCell cAlamatUbah = new PdfPCell();
        cAlamatUbah.addElement(pAlamatUbah);
        tabel51.addCell(cAlamatUbah);
        document.add(tabel51);
        //------------------------------------------------------------------------------------- ALAMAT + PINDAHAN END

        //------------------------------------------------------------------------------------- KEDUDUKAN KELUARGA
        PdfPTable tabel6 = new PdfPTable(1);
        tabel6.setWidthPercentage(100);

        Paragraph pKedudukanKeluarga = new Paragraph();
        pKedudukanKeluarga.add("7.  Kedudukan dalam Keluarga : ");
        pKedudukanKeluarga.setLeading(0, 1);

        PdfPCell cKedudukanKeluarga = new PdfPCell();
        cKedudukanKeluarga.setMinimumHeight(20);
        cKedudukanKeluarga.addElement(pKedudukanKeluarga);
        tabel6.addCell(cKedudukanKeluarga);
        document.add(tabel6);

        PdfPTable tabel61 = new PdfPTable(1);
        tabel61.setWidthPercentage(100);

        Paragraph pNamaBapakIbu = new Paragraph();
        pNamaBapakIbu.add("8.  a.  Nama Bapak : ");
        pNamaBapakIbu.add("\n\n          Nama Ibu      : ");
        pNamaBapakIbu.add("\n\n     b.  Alamat : ");
        pNamaBapakIbu.setLeading(0, 1);

        PdfPCell cNamaBapakIbu = new PdfPCell();
        cNamaBapakIbu.setMinimumHeight(70);
        cNamaBapakIbu.addElement(pNamaBapakIbu);
        tabel61.addCell(cNamaBapakIbu);

        document.add(tabel61);
        //------------------------------------------------------------------------------------- KEDUDUKAN END

        //------------------------------------------------------------------------------------- PEKERJAAN
        PdfPTable tabel7 = new PdfPTable(2);
        tabel7.setWidthPercentage(100);

        Paragraph pPekerjaan = new Paragraph();
        pPekerjaan.add("9.  a. Pekerjaan : " + getPekerjaan());
        pPekerjaan.setLeading(0, 1);

        PdfPCell cPekerjaan = new PdfPCell();
        cPekerjaan.setMinimumHeight(20);
        cPekerjaan.addElement(pPekerjaan);
        tabel7.addCell(cPekerjaan);

        Paragraph pJabatan = new Paragraph();
        pJabatan.add("  b. Jabatan : " + getJabatan());
        pJabatan.setLeading(0, 1);

        PdfPCell cJabatan = new PdfPCell();
        cJabatan.setMinimumHeight(20);
        cJabatan.addElement(pJabatan);
        tabel7.addCell(cJabatan);

        document.add(tabel7);
        //------------------------------------------------------------------------------------- PEKERJAAN END

        //------------------------------------------------------------------------------------- INSTANSI DLL
        PdfPTable tabel8 = new PdfPTable(1);
        tabel8.setWidthPercentage(100);

        Paragraph pInstansi = new Paragraph();
        pInstansi.add("     c. Instansi/Lembaga/Kantor : " + getInstansilembagakantor());
        pInstansi.setLeading(0, 1);

        PdfPCell cInstansi = new PdfPCell();
        cInstansi.setMinimumHeight(20);
        cInstansi.addElement(pInstansi);
        tabel8.addCell(cInstansi);

        document.add(tabel8);
        //------------------------------------------------------------------------------------- INSTANSI DLL END

        //------------------------------------------------------------------------------------- NAMA ISTRI
        float[] colomn = { 7, 1, 2 };
        PdfPTable tabel9 = new PdfPTable(colomn);
        tabel9.setWidthPercentage(100);

        Paragraph pNamaIstriBapakIbu = new Paragraph();
        pNamaIstriBapakIbu.add("10.");
        pNamaIstriBapakIbu.add("\n       a. Nama Istri : ");
        pNamaIstriBapakIbu.add("\n\n       b. Nama Bapak Istri : ");
        pNamaIstriBapakIbu.add("\n\n       c. Nama Ibu Istri : ");
        pNamaIstriBapakIbu.add("\n\n       d. Alamat : ");
        pNamaIstriBapakIbu.setLeading(0, 1);

        PdfPCell cNamaIstriBapakIbu = new PdfPCell();
        cNamaIstriBapakIbu.setMinimumHeight(110);
        cNamaIstriBapakIbu.addElement(pNamaIstriBapakIbu);
        tabel9.addCell(cNamaIstriBapakIbu);

        Paragraph pUmurIstriBapakIbu = new Paragraph();
        pUmurIstriBapakIbu.add("  Umur :");
        pUmurIstriBapakIbu.setLeading(0, 1);

        PdfPCell cUmurIstriBapakIbu = new PdfPCell();
        cUmurIstriBapakIbu.setMinimumHeight(110);
        cUmurIstriBapakIbu.addElement(pUmurIstriBapakIbu);
        tabel9.addCell(cUmurIstriBapakIbu);

        Paragraph pPekerjaanIstriBapakIbu = new Paragraph();
        pPekerjaanIstriBapakIbu.add("  Pekerjaan :");
        pPekerjaanIstriBapakIbu.setLeading(0, 1);

        PdfPCell cPekerjaanIstriBapakIbu = new PdfPCell();
        cPekerjaanIstriBapakIbu.setMinimumHeight(110);
        cPekerjaanIstriBapakIbu.addElement(pPekerjaanIstriBapakIbu);
        tabel9.addCell(cPekerjaanIstriBapakIbu);

        document.add(tabel9);
        //------------------------------------------------------------------------------------- NAMA ISTRI END

        //------------------------------------------------------------------------------------- SANAK SAUDARA
        PdfPTable tabel10 = new PdfPTable(colomn);
        tabel10.setWidthPercentage(100);

        Paragraph pSanakSaudara = new Paragraph();
        pSanakSaudara.add("11.  Nama Sanak/Saudara yang menjadi Tanggungan : \n       1.\n       2.");
        pSanakSaudara.setLeading(0, 1);

        PdfPCell cSanakSaudara = new PdfPCell();
        cSanakSaudara.addElement(pSanakSaudara);
        tabel10.addCell(cSanakSaudara);

        Paragraph pSanakSaudara1 = new Paragraph();
        pSanakSaudara1.add("");
        pSanakSaudara1.setLeading(0, 1);

        PdfPCell cSanakSaudara1 = new PdfPCell();
        cSanakSaudara1.addElement(pSanakSaudara1);
        tabel10.addCell(cSanakSaudara1);

        Paragraph pSanakSaudara2 = new Paragraph();
        pSanakSaudara2.add("");
        pSanakSaudara2.setLeading(0, 1);

        PdfPCell cSanakSaudara2 = new PdfPCell();
        cSanakSaudara2.addElement(pSanakSaudara2);
        tabel10.addCell(cSanakSaudara2);

        document.add(tabel10);
        //------------------------------------------------------------------------------------- SANAK SAUDARA END

        //------------------------------------------------------------------------------------- ANAK2
        PdfPTable tabel11 = new PdfPTable(colomn);
        tabel11.setWidthPercentage(100);

        Paragraph pAnak2 = new Paragraph();
        pAnak2.add("12.  Anak-anak : ");
        pAnak2.add("\n\n       1. ");
        pAnak2.add("\n\n       2. ");
        pAnak2.add("\n\n       3. ");
        pAnak2.add("\n\n       4. ");
        pAnak2.add("\n\n       5. ");
        pAnak2.add("\n\n       6. ");
        pAnak2.add("\n");
        pAnak2.setLeading(0, 1);

        PdfPCell cAnak2 = new PdfPCell();
        cAnak2.setMinimumHeight(165);
        cAnak2.addElement(pAnak2);
        tabel11.addCell(cAnak2);

        Paragraph pUmurAnak2 = new Paragraph();
        pUmurAnak2.add("  Umur : ");
        pUmurAnak2.setLeading(0, 1);

        PdfPCell cUmurAnak2 = new PdfPCell();
        cUmurAnak2.setMinimumHeight(165);
        cUmurAnak2.addElement(pUmurAnak2);
        tabel11.addCell(cUmurAnak2);

        Paragraph pPekarjaanAnak2 = new Paragraph();
        pPekarjaanAnak2.add("  Pekerjaan : ");
        pPekarjaanAnak2.setLeading(0, 1);

        PdfPCell cPekerjaanAnak2 = new PdfPCell();
        cPekerjaanAnak2.setMinimumHeight(165);
        cPekerjaanAnak2.addElement(pPekarjaanAnak2);
        tabel11.addCell(cPekerjaanAnak2);

        document.add(tabel11);
        //------------------------------------------------------------------------------------- ANAK2 END

        //------------------------------------------------------------------------------------- CIRI-CIRI
        PdfPTable tabel12 = new PdfPTable(1);
        tabel12.setWidthPercentage(100);

        Paragraph pCiri2 = new Paragraph();
        pCiri2.add("13.  Ciri-ciri badan : ");
        pCiri2.add("\n\n       1. Rambut : " + getRambut());
        for (int i = 0; i < (35 - getRambut().length()); i++) {
            pCiri2.add(" ");
        }
        pCiri2.add("2. Muka : " + getMuka());
        for (int i = 0; i < (35 - getMuka().length()); i++) {
            pCiri2.add(" ");
        }
        pCiri2.add("3. Kulit : " + getKulit());
        pCiri2.setLeading(0, 1);

        PdfPCell cCiri2 = new PdfPCell();
        cCiri2.setMinimumHeight(45);
        cCiri2.addElement(pCiri2);
        tabel12.addCell(cCiri2);

        document.add(tabel12);
        //------------------------------------------------------------------------------------- CIRI-CIRI END

        //------------------------------------------------------------------------------------- LANJUTAN CIRI2
        PdfPTable tabel13 = new PdfPTable(1);
        tabel13.setWidthPercentage(100);

        Paragraph pCiri2Lanjutan = new Paragraph();
        for (int i = 0; i < 20; i++) {
            pCiri2Lanjutan.add(" ");
        }
        pCiri2Lanjutan.add("4.  Tinggi : " + getTinggi());
        for (int i = 0; i < (35 - getTinggi().length()); i++) {
            pCiri2Lanjutan.add(" ");
        }
        pCiri2Lanjutan.add("5.  Tanda Istimewa : " + getTandaistimewa());
        pCiri2Lanjutan.setLeading(0, 1);

        PdfPCell cCiri2Lanjutan = new PdfPCell();
        cCiri2Lanjutan.setMinimumHeight(20);
        cCiri2Lanjutan.addElement(pCiri2Lanjutan);
        tabel13.addCell(cCiri2Lanjutan);

        document.add(tabel13);
        //------------------------------------------------------------------------------------- LANJUTAN CIRI2

        //------------------------------------------------------------------------------------- RUMUS SIDIK JARI
        PdfPTable tabel14 = new PdfPTable(1);
        tabel14.setWidthPercentage(100);

        Paragraph pSidikJari = new Paragraph();
        pSidikJari.add("14.  Rumus Sidik Jari : " + getRumussidikjari());
        pSidikJari.setLeading(0, 1);

        PdfPCell cSidikJari = new PdfPCell();
        cSidikJari.setMinimumHeight(20);
        cSidikJari.addElement(pSidikJari);
        tabel14.addCell(cSidikJari);

        document.add(tabel14);
        //------------------------------------------------------------------------------------- RUMUS SIDIK JARI END

        //------------------------------------------------------------------------------------- RIWAYAT SEKOLAH
        float[] colom = { 8, 2 };
        PdfPTable tabel15 = new PdfPTable(colom);
        tabel15.setWidthPercentage(100);

        Paragraph pRiwayatSekolah = new Paragraph();
        pRiwayatSekolah.add("15.  Riwayat Sekolah : ");
        pRiwayatSekolah.add("\n\n       1. ");
        pRiwayatSekolah.add("\n\n       2. ");
        pRiwayatSekolah.add("\n\n       3. ");
        pRiwayatSekolah.add("\n\n       4. ");
        pRiwayatSekolah.add("\n\n       5. ");
        pRiwayatSekolah.add("\n\n       6. ");
        pRiwayatSekolah.setLeading(0, 1);

        PdfPCell cRiwayatSekolah = new PdfPCell();
        cRiwayatSekolah.setMinimumHeight(165);
        cRiwayatSekolah.addElement(pRiwayatSekolah);
        tabel15.addCell(cRiwayatSekolah);

        Paragraph pTahunLulus = new Paragraph();
        pTahunLulus.add("Tahun Lulus");
        pTahunLulus.setLeading(0, 1);

        PdfPCell cTahunLulus = new PdfPCell();
        cTahunLulus.setMinimumHeight(165);
        cTahunLulus.addElement(pTahunLulus);
        tabel15.addCell(cTahunLulus);

        document.add(tabel15);
        //------------------------------------------------------------------------------------- RIWAYAT SEKOLAH END

        //------------------------------------------------------------------------------------- KESENANGAN/KEGEMARAN/HOBI
        PdfPTable tabel16 = new PdfPTable(1);
        tabel16.setWidthPercentage(100);

        Paragraph pKesenenanganKegemaranHobi = new Paragraph();
        pKesenenanganKegemaranHobi.add("16.  Kesenangan/Kegemaran/Hobi : " + getHobi());
        pKesenenanganKegemaranHobi.setLeading(0, 1);

        PdfPCell cKesenenanganKegemaranHobi = new PdfPCell();
        cKesenenanganKegemaranHobi.setMinimumHeight(20);
        cKesenenanganKegemaranHobi.addElement(pKesenenanganKegemaranHobi);
        tabel16.addCell(cKesenenanganKegemaranHobi);

        document.add(tabel16);
        //------------------------------------------------------------------------------------- KESENANGAN/KEGEMARAN/HOBI END

        //------------------------------------------------------------------------------------- CATATAN KRIMINAL
        PdfPTable tabel17 = new PdfPTable(1);
        tabel17.setWidthPercentage(100);

        Paragraph pCatatanKriminal = new Paragraph();
        pCatatanKriminal.add("17.  Catatan kriminal yang ada : ");
        pCatatanKriminal.add("\n\n       1. " + getCatatankriminal1());
        pCatatanKriminal.add("\n\n       2. " + getCatatankriminal2());
        pCatatanKriminal.add("\n\n       3. " + getCatatankriminal3());
        pCatatanKriminal.setLeading(0, 1);

        PdfPCell cCatatanKriminal = new PdfPCell();
        cCatatanKriminal.setMinimumHeight(95);
        cCatatanKriminal.addElement(pCatatanKriminal);
        tabel17.addCell(cCatatanKriminal);

        document.add(tabel17);
        //------------------------------------------------------------------------------------- CATATAN KRIMINAL END

        //------------------------------------------------------------------------------------- KETERANGAN DLL
        PdfPTable tabel18 = new PdfPTable(1);
        tabel18.setWidthPercentage(100);

        Paragraph pDataKeteranganLain2 = new Paragraph();
        pDataKeteranganLain2.add("18.  Data Keterangan dan lain2 : ");
        pDataKeteranganLain2.add("\n\n\n");
        pDataKeteranganLain2.setLeading(0, 1);

        PdfPCell cDataKeteranganLain2 = new PdfPCell();
        cDataKeteranganLain2.addElement(pDataKeteranganLain2);

        if (list.size() > 0) {
            float[] kolomkegiatan = { 8, 2 };
            PdfPTable nestedTable = new PdfPTable(kolomkegiatan);

            nestedTable.addCell(new Paragraph("Kegiatan"));
            nestedTable.addCell(new Paragraph("Tanggal"));

            for (int i = 0; i < list.size(); i++) {
                nestedTable.addCell(new Paragraph(list.get(i).getNamakegiatan()));
                nestedTable.addCell(new Paragraph(list.get(i).getTanggal()));
            }

            cDataKeteranganLain2.addElement(nestedTable);
            cDataKeteranganLain2.setPaddingBottom(20f);
            tabel18.addCell(cDataKeteranganLain2);
        }

        document.add(tabel18);
        //------------------------------------------------------------------------------------- KETERANGAN DLL END

        document.close();

    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return output;
}

From source file:ServletsReportesPDF.ReporteAbonadas.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//from   w  w w .  j  a v a  2s .  c o  m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    String num_lote = request.getParameter("num_lote");

    response.setContentType("application/pdf");
    OutputStream out = response.getOutputStream();

    try {
        try {

            Statement st = null;
            Statement st2 = null;
            Statement st3 = null;
            Statement st4 = null;
            Statement st5 = null;
            ResultSet rs = null;
            ResultSet rs2 = null;
            ResultSet rs3 = null;
            ResultSet rs4 = null;
            ResultSet rs5 = null;
            java.sql.Connection con = new ConexionBD().ConexionBD2();

            st = (Statement) con.createStatement();
            st2 = (Statement) con.createStatement();
            st3 = (Statement) con.createStatement();
            st4 = (Statement) con.createStatement();
            st5 = (Statement) con.createStatement();
            rs = st.executeQuery(
                    "SELECT usuario.cedula,nombre,apellido,telefono FROM usuario JOIN lote ON lote.usuario_cedula=usuario.cedula WHERE lote.num_lote='"
                            + num_lote + "'");
            rs2 = st2.executeQuery(
                    "SELECT * from abonada a JOIN insumos_abonada i on i.id_abonada = a.id_abonada where a.num_lote ='"
                            + num_lote + "'");
            rs3 = st3.executeQuery(
                    "SELECT * from abonada a JOIN insumos_abonada i on i.id_abonada = a.id_abonada where a.num_lote ='"
                            + num_lote + "'");
            rs4 = st4.executeQuery("select * from abonada where num_lote = '" + num_lote + "'");
            rs5 = st5.executeQuery(
                    "SELECT * from abonada a JOIN insumos_abonada i on i.id_abonada = a.id_abonada where a.num_lote ='"
                            + num_lote + "'");
            if (con != null) {
                Document documento = new Document(A4.rotate());
                PdfWriter writer = PdfWriter.getInstance(documento, out);
                FooterPiePaginaiText footer = new FooterPiePaginaiText();
                writer.setPageEvent(footer);

                documento.open();

                try {

                    Image imagenes = Image.getInstance(
                            "C:\\Users\\USUARIO\\Desktop\\simpca\\SIMPCA Coagronorte\\web\\ImagenesR\\coagronorte-slogan.png");
                    imagenes.setAlignment(Element.ALIGN_RIGHT);
                    imagenes.scaleToFit(120, 120);
                    documento.add(imagenes);

                    //documento.add(imagenes);
                    Paragraph par21 = new Paragraph();
                    Font fontDescrip = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.ITALIC, BaseColor.BLACK);
                    par21.add(new Phrase("Cooperativa Agropecuaria de Norte de Santander", fontDescrip));
                    par21.setAlignment(Element.ALIGN_CENTER);
                    par21.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par21);

                    String nombre = null;
                    String Apellido = null;
                    String cedula = null;
                    while (rs.next()) {
                        nombre = (rs.getString("nombre"));
                        cedula = (rs.getString("cedula"));
                        Apellido = (rs.getString("apellido"));
                    }

                    Paragraph par2 = new Paragraph();
                    Font fontfecha = new Font(Font.FontFamily.TIMES_ROMAN, 13, Font.NORMAL, BaseColor.BLACK);
                    Date date = new Date();
                    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy ");
                    par2.add(new Paragraph("Fecha:  " + dateFormat.format(date), fontfecha));
                    //par2.add(new Paragraph(new Date().toString()));
                    par2.setAlignment(Element.ALIGN_RIGHT);
                    ;
                    documento.add(par2);

                    Paragraph par7 = new Paragraph();
                    Font fontUsuario = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL, BaseColor.BLACK);
                    par7.add(new Phrase("Nombre:   " + nombre + "  " + Apellido, fontUsuario));
                    par7.add(new Phrase("\nc.c:   " + cedula, fontUsuario));
                    par7.setAlignment(Element.ALIGN_LEFT);
                    par7.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par7);

                    Paragraph par3 = new Paragraph();
                    Font fontDescri = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK);
                    par3.add(new Phrase("Numero Lote:\n " + num_lote, fontDescri));
                    par3.setAlignment(Element.ALIGN_CENTER);
                    par3.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par3);

                } catch (Exception eX) {
                    eX.getMessage();
                }

                try {

                    Paragraph par1 = new Paragraph();
                    Font fonttitulo = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase("REPORTE ABONADAS", fonttitulo));
                    par1.setAlignment(Element.ALIGN_CENTER);
                    par1.add(new Phrase(Chunk.NEWLINE));

                    documento.add(par1);

                    PdfPTable tabla = new PdfPTable(6);
                    FontFactory.registerDirectories();
                    documento.add(new Paragraph("\n"));
                    PdfPCell celda1 = new PdfPCell(new Paragraph("Fecha",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda2 = new PdfPCell(new Paragraph("Tipo Abonada",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda3 = new PdfPCell(new Paragraph("Cantidad Bultos",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda4 = new PdfPCell(new Paragraph("Costo Bulto",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda5 = new PdfPCell(new Paragraph("Valor Total Bultos",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda6 = new PdfPCell(new Paragraph("Unidad",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));

                    tabla.addCell(celda1);
                    tabla.addCell(celda2);
                    tabla.addCell(celda3);
                    tabla.addCell(celda4);
                    tabla.addCell(celda5);
                    tabla.addCell(celda6);

                    while (rs2.next()) {

                        tabla.addCell(rs2.getString("fecha_abonada"));
                        tabla.addCell(rs2.getString("nombre_abonada"));
                        tabla.addCell(rs2.getString("cantidad_bulto_aplicado_abonada"));
                        tabla.addCell(rs2.getString("costo_unitario_bulto_abonada"));
                        tabla.addCell(rs2.getString("valor_total_bulto_abonada"));
                        tabla.addCell(rs2.getString("unidad_mano_obra_abonada"));

                    }
                    documento.add(tabla);

                } catch (Exception eX) {
                    eX.getMessage();
                }

                try {
                    Paragraph par4 = new Paragraph();

                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    Font fontFooter2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par4.add(new Phrase("REPORTE MANO DE OBRA ABONADAS", fontFooter2));
                    par4.setAlignment(Element.ALIGN_CENTER);
                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par4);

                    PdfPTable tabla2 = new PdfPTable(3);
                    FontFactory.registerDirectories();
                    PdfPCell celda10 = new PdfPCell(new Paragraph("Cantidad Mano Obra",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda10.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda20 = new PdfPCell(new Paragraph("Costo Mano Obra",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda20.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda30 = new PdfPCell(new Paragraph("Valor Total Mano Obra",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda30.setHorizontalAlignment(Element.ALIGN_CENTER);

                    tabla2.addCell(celda10);
                    tabla2.addCell(celda20);
                    tabla2.addCell(celda30);

                    while (rs3.next()) {
                        tabla2.addCell(rs3.getString("cantidad_mano_obra_abonada"));
                        tabla2.addCell(rs3.getString("costo_unitario_mano_obra_abonada"));
                        tabla2.addCell(rs3.getString("valor_total_mano_obra_abonada"));
                    }

                    documento.add(tabla2);

                } catch (Exception eX) {
                    eX.getMessage();
                }

                try {
                    Paragraph par11 = new Paragraph();

                    par11.add(new Phrase(Chunk.NEWLINE));
                    par11.add(new Phrase(Chunk.NEWLINE));
                    par11.add(new Phrase(Chunk.NEWLINE));
                    Font fontFooter3 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par11.add(new Phrase("OTROS", fontFooter3));
                    par11.setAlignment(Element.ALIGN_CENTER);
                    par11.add(new Phrase(Chunk.NEWLINE));
                    par11.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par11);

                    PdfPTable tabla3 = new PdfPTable(4);
                    FontFactory.registerDirectories();
                    PdfPCell celda21 = new PdfPCell(new Paragraph("Cantidad Transporte",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda21.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda22 = new PdfPCell(new Paragraph("Costo Transporte",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda22.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda23 = new PdfPCell(new Paragraph("Valor Total Transporte",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda23.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda24 = new PdfPCell(new Paragraph("Valor Total Abonada",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda24.setHorizontalAlignment(Element.ALIGN_CENTER);

                    tabla3.addCell(celda21);
                    tabla3.addCell(celda22);
                    tabla3.addCell(celda23);
                    tabla3.addCell(celda24);

                    while (rs4.next()) {
                        tabla3.addCell(rs4.getString("cantidad_transporte_abonada"));
                        tabla3.addCell(rs4.getString("costo_transporte_abonada"));
                        tabla3.addCell(rs4.getString("valor_total_transporte_abonada"));
                        tabla3.addCell(rs4.getString("valor_total_abonada"));
                    }

                    documento.add(tabla3);

                } catch (Exception eX) {
                    eX.getMessage();
                }

                try {
                    Paragraph par7 = new Paragraph();

                    par7.add(new Phrase(Chunk.NEWLINE));
                    par7.add(new Phrase(Chunk.NEWLINE));
                    par7.add(new Phrase(Chunk.NEWLINE));
                    Font fontFooter4 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par7.add(new Phrase("REPORTE INSUMOS ABONADAS", fontFooter4));
                    par7.setAlignment(Element.ALIGN_CENTER);
                    par7.add(new Phrase(Chunk.NEWLINE));
                    par7.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par7);

                    PdfPTable tabla4 = new PdfPTable(6);
                    FontFactory.registerDirectories();
                    PdfPCell celda31 = new PdfPCell(new Paragraph("Tipo",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda31.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda32 = new PdfPCell(new Paragraph("Nombre",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda32.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda33 = new PdfPCell(new Paragraph("Cantidad",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda33.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda34 = new PdfPCell(new Paragraph("Unidad",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda34.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda35 = new PdfPCell(new Paragraph("Valor Unitario",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda35.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda36 = new PdfPCell(new Paragraph("Valor Total",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda36.setHorizontalAlignment(Element.ALIGN_CENTER);

                    tabla4.addCell(celda31);
                    tabla4.addCell(celda32);
                    tabla4.addCell(celda33);
                    tabla4.addCell(celda34);
                    tabla4.addCell(celda35);
                    tabla4.addCell(celda36);

                    while (rs5.next()) {
                        tabla4.addCell(rs5.getString("tipo_insumo"));
                        tabla4.addCell(rs5.getString("nombre_insumo"));
                        tabla4.addCell(rs5.getString("cantidad_insumo"));
                        tabla4.addCell(rs5.getString("unidad_insumo"));
                        tabla4.addCell(rs5.getString("valor_unitario_insumo"));
                        tabla4.addCell(rs5.getString("valor_total_insumos"));
                    }

                    documento.add(tabla4);

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

                documento.close();

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

    } finally {
        out.close();
    }
}

From source file:ServletsReportesPDF.ReporteCortaBultos.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*from w w w.j  a  v  a2 s . co  m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    String num_lote = request.getParameter("num_lote");

    response.setContentType("application/pdf");
    OutputStream out = response.getOutputStream();

    try {
        try {

            Connection con = null;
            Statement st = null;
            Statement st2 = null;
            Statement st3 = null;
            Statement st4 = null;
            Statement st5 = null;
            ResultSet rs = null;
            ResultSet rs2 = null;
            ResultSet rs3 = null;
            ResultSet rs4 = null;
            ResultSet rs5 = null;
            Class.forName("com.mysql.jdbc.Driver");
            con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/simpca", "root",
                    "9510");

            st = (Statement) con.createStatement();
            st2 = (Statement) con.createStatement();
            st3 = (Statement) con.createStatement();
            st4 = (Statement) con.createStatement();
            st5 = (Statement) con.createStatement();
            rs = st.executeQuery(
                    "SELECT usuario.cedula,nombre,apellido,telefono FROM usuario JOIN lote ON lote.usuario_cedula=usuario.cedula WHERE lote.num_lote='"
                            + num_lote + "'");
            rs2 = st2.executeQuery("SELECT * from corta_bultos where num_lote ='" + num_lote + "'");
            rs3 = st3.executeQuery("SELECT * from corta_bultos where num_lote ='" + num_lote + "'");
            rs4 = st4.executeQuery("SELECT * from corta_bultos where num_lote ='" + num_lote + "'");
            rs5 = st5.executeQuery("SELECT * from corta_bultos where num_lote ='" + num_lote + "'");
            if (con != null) {
                Document documento = new Document(A4.rotate());
                PdfWriter writer = PdfWriter.getInstance(documento, out);
                FooterPiePaginaiText footer = new FooterPiePaginaiText();
                writer.setPageEvent(footer);

                documento.open();

                try {

                    Image imagenes = Image.getInstance(
                            "C:\\Users\\USUARIO\\Desktop\\simpca\\SIMPCA Coagronorte\\web\\ImagenesR\\coagronorte-slogan.png");
                    imagenes.setAlignment(Element.ALIGN_RIGHT);
                    imagenes.scaleToFit(120, 120);
                    documento.add(imagenes);

                    //documento.add(imagenes);
                    Paragraph par21 = new Paragraph();
                    Font fontDescrip = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.ITALIC, BaseColor.BLACK);
                    par21.add(new Phrase("Cooperativa Agropecuaria de Norte de Santander", fontDescrip));
                    par21.setAlignment(Element.ALIGN_CENTER);
                    par21.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par21);

                    String nombre = null;
                    String Apellido = null;
                    String cedula = null;
                    while (rs.next()) {
                        nombre = (rs.getString("nombre"));
                        cedula = (rs.getString("cedula"));
                        Apellido = (rs.getString("apellido"));
                    }

                    Paragraph par2 = new Paragraph();
                    Font fontfecha = new Font(Font.FontFamily.TIMES_ROMAN, 13, Font.NORMAL, BaseColor.BLACK);
                    Date date = new Date();
                    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy ");
                    par2.add(new Paragraph("Fecha:  " + dateFormat.format(date), fontfecha));
                    //par2.add(new Paragraph(new Date().toString()));
                    par2.setAlignment(Element.ALIGN_RIGHT);
                    ;
                    documento.add(par2);

                    Paragraph par7 = new Paragraph();
                    Font fontUsuario = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL, BaseColor.BLACK);
                    par7.add(new Phrase("Nombre:   " + nombre + "  " + Apellido, fontUsuario));
                    par7.add(new Phrase("\nc.c:   " + cedula, fontUsuario));
                    par7.setAlignment(Element.ALIGN_LEFT);
                    par7.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par7);

                    Paragraph par3 = new Paragraph();
                    Font fontDescri = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK);
                    par3.add(new Phrase("Numero Lote:\n " + num_lote, fontDescri));
                    par3.setAlignment(Element.ALIGN_CENTER);
                    par3.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par3);

                } catch (Exception eX) {
                    eX.getMessage();
                }

                try {

                    Paragraph par1 = new Paragraph();
                    Font fonttitulo = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase("REPORTE CORTA POR BULTOS", fonttitulo));
                    par1.setAlignment(Element.ALIGN_CENTER);
                    par1.add(new Phrase(Chunk.NEWLINE));

                    documento.add(par1);

                    Paragraph par2 = new Paragraph();
                    Font fonttitulo2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par2.add(new Phrase(Chunk.NEWLINE));
                    par2.add(new Phrase(Chunk.NEWLINE));
                    par2.add(new Phrase(Chunk.NEWLINE));
                    par2.add(new Phrase("REPORTE CORTO DE MAQUINA LLANTA Y ORUGA", fonttitulo2));
                    par2.setAlignment(Element.ALIGN_CENTER);
                    par2.add(new Phrase(Chunk.NEWLINE));

                    documento.add(par2);

                    PdfPTable tabla = new PdfPTable(7);
                    FontFactory.registerDirectories();
                    documento.add(new Paragraph("\n"));
                    PdfPCell celda1 = new PdfPCell(new Paragraph("Fecha",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda2 = new PdfPCell(new Paragraph("Cantidad (Llanta)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda3 = new PdfPCell(new Paragraph("Valor Unidad (Llanta)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda4 = new PdfPCell(new Paragraph("Valor Total (Llanta)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda5 = new PdfPCell(new Paragraph("Cantidad (Oruga)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda6 = new PdfPCell(new Paragraph("Valor Unidad (Oruga)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda7 = new PdfPCell(new Paragraph("Valor Total (Oruga)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));

                    tabla.addCell(celda1);
                    tabla.addCell(celda2);
                    tabla.addCell(celda3);
                    tabla.addCell(celda4);
                    tabla.addCell(celda5);
                    tabla.addCell(celda6);
                    tabla.addCell(celda7);

                    while (rs2.next()) {

                        tabla.addCell(rs2.getString("fecha_crb"));
                        tabla.addCell(rs2.getString("cantidad_mq_llanta_crb"));
                        tabla.addCell(rs2.getString("valor_mq_llanta_crb"));
                        tabla.addCell(rs2.getString("valor_total_mq_llanta_crb"));
                        tabla.addCell(rs2.getString("cantidad_mq_oruga_crb"));
                        tabla.addCell(rs2.getString("valor_mq_oruga_crb"));
                        tabla.addCell(rs2.getString("valor_total_mq_oruga_crb"));

                    }
                    documento.add(tabla);

                    Paragraph par4 = new Paragraph();

                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    Font fontFooter2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par4.add(new Phrase("REPORTE COSTOS DE LLENADOR, TRACTOR Y BULTEADOR", fontFooter2));
                    par4.setAlignment(Element.ALIGN_CENTER);
                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par4);

                    PdfPTable tabla2 = new PdfPTable(9);
                    FontFactory.registerDirectories();
                    PdfPCell celda10 = new PdfPCell(new Paragraph("Cantidad (Llenador)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda10.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda20 = new PdfPCell(new Paragraph("Valor Unidad (Llenador)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda20.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda30 = new PdfPCell(new Paragraph("Valor Total (Llenador)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda30.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda40 = new PdfPCell(new Paragraph("Cantidad (Tractor)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda40.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda50 = new PdfPCell(new Paragraph("Valor Unidad (Tractor)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda50.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda60 = new PdfPCell(new Paragraph("Valor Total (Tractor)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda60.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda70 = new PdfPCell(new Paragraph("Cantidad (Bulteador)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda70.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda80 = new PdfPCell(new Paragraph("Valor Unidad (Bulteador)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda80.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda90 = new PdfPCell(new Paragraph("Valor Total (Bulteador)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda90.setHorizontalAlignment(Element.ALIGN_CENTER);

                    tabla2.addCell(celda10);
                    tabla2.addCell(celda20);
                    tabla2.addCell(celda30);
                    tabla2.addCell(celda40);
                    tabla2.addCell(celda50);
                    tabla2.addCell(celda60);
                    tabla2.addCell(celda70);
                    tabla2.addCell(celda80);
                    tabla2.addCell(celda90);

                    while (rs3.next()) {
                        tabla2.addCell(rs3.getString("cantidad_llenador_crb"));
                        tabla2.addCell(rs3.getString("valor_llenador_crb"));
                        tabla2.addCell(rs3.getString("valor_total_llenador_crb"));
                        tabla2.addCell(rs3.getString("cantidad_tractor_crb"));
                        tabla2.addCell(rs3.getString("valor_tractor_crb"));
                        tabla2.addCell(rs3.getString("valor_total_tractor_crb"));
                        tabla2.addCell(rs3.getString("cantidad_bulteador_crb"));
                        tabla2.addCell(rs3.getString("valor_bulteador_crb"));
                        tabla2.addCell(rs3.getString("valor_total_bulteador_crb"));
                    }

                    documento.add(tabla2);

                    Paragraph par8 = new Paragraph();

                    par8.add(new Phrase(Chunk.NEWLINE));
                    par8.add(new Phrase(Chunk.NEWLINE));
                    par8.add(new Phrase(Chunk.NEWLINE));
                    Font fontFooter4 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par8.add(new Phrase("REPORTE COSTOS DE FLETE", fontFooter4));
                    par8.setAlignment(Element.ALIGN_CENTER);
                    par8.add(new Phrase(Chunk.NEWLINE));
                    par8.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par8);

                    PdfPTable tabla3 = new PdfPTable(3);
                    FontFactory.registerDirectories();
                    PdfPCell celda100 = new PdfPCell(new Paragraph("Cantidad (Flete)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda100.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda110 = new PdfPCell(new Paragraph("Valor Unidad (Flete)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda110.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda120 = new PdfPCell(new Paragraph("Valor Total (Flete)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda120.setHorizontalAlignment(Element.ALIGN_CENTER);

                    tabla3.addCell(celda100);
                    tabla3.addCell(celda110);
                    tabla3.addCell(celda120);

                    while (rs4.next()) {
                        tabla3.addCell(rs4.getString("cantidad_flete_crb"));
                        tabla3.addCell(rs4.getString("valor_flete_crb"));
                        tabla3.addCell(rs4.getString("valor_total_flete_crb"));
                    }

                    documento.add(tabla3);

                    Paragraph par9 = new Paragraph();

                    par9.add(new Phrase(Chunk.NEWLINE));
                    par9.add(new Phrase(Chunk.NEWLINE));
                    par9.add(new Phrase(Chunk.NEWLINE));
                    Font fontFooter5 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par9.add(new Phrase("REPORTE COSTOS ADICIONALES", fontFooter5));
                    par9.setAlignment(Element.ALIGN_CENTER);
                    par9.add(new Phrase(Chunk.NEWLINE));
                    par9.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par9);

                    PdfPTable tabla4 = new PdfPTable(6);
                    FontFactory.registerDirectories();
                    PdfPCell celda130 = new PdfPCell(new Paragraph("Valor Cabuya O Nylon",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda130.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda140 = new PdfPCell(new Paragraph("Valor Celadura Mquina",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda140.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda150 = new PdfPCell(new Paragraph("Valor Alimentacin",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda150.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda160 = new PdfPCell(new Paragraph("Valor Administracin",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda160.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda170 = new PdfPCell(new Paragraph("Valor Transporte Mquina Oruga",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda170.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda180 = new PdfPCell(new Paragraph("Costo Total",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda180.setHorizontalAlignment(Element.ALIGN_CENTER);

                    tabla4.addCell(celda130);
                    tabla4.addCell(celda140);
                    tabla4.addCell(celda150);
                    tabla4.addCell(celda160);
                    tabla4.addCell(celda170);
                    tabla4.addCell(celda180);

                    while (rs5.next()) {
                        tabla4.addCell(rs5.getString("valor_cabuya_nylon_crb"));
                        tabla4.addCell(rs5.getString("valor_celaduria_maquina_crb"));
                        tabla4.addCell(rs5.getString("valor_alimentacion_crb"));
                        tabla4.addCell(rs5.getString("valor_administracion_crb"));
                        tabla4.addCell(rs5.getString("valor_maquina_oruga_crb"));
                        tabla4.addCell(rs5.getString("valor_total_crb"));
                    }

                    documento.add(tabla4);

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

                documento.close();

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

    } finally {
        out.close();
    }
}

From source file:ServletsReportesPDF.ReporteCortaGranel.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  w ww.j  ava2s.  c  om*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    String num_lote = request.getParameter("num_lote");

    response.setContentType("application/pdf");
    OutputStream out = response.getOutputStream();

    try {
        try {

            Connection con = null;
            Statement st = null;
            Statement st2 = null;
            Statement st3 = null;
            Statement st4 = null;
            Statement st5 = null;
            ResultSet rs = null;
            ResultSet rs2 = null;
            ResultSet rs3 = null;
            ResultSet rs4 = null;
            ResultSet rs5 = null;
            Class.forName("com.mysql.jdbc.Driver");
            con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/simpca", "root",
                    "9510");

            st = (Statement) con.createStatement();
            st2 = (Statement) con.createStatement();
            st3 = (Statement) con.createStatement();
            st4 = (Statement) con.createStatement();
            st5 = (Statement) con.createStatement();
            rs = st.executeQuery(
                    "SELECT usuario.cedula,nombre,apellido,telefono FROM usuario JOIN lote ON lote.usuario_cedula=usuario.cedula WHERE lote.num_lote='"
                            + num_lote + "'");
            rs2 = st2.executeQuery("SELECT * from corta_granel where num_lote ='" + num_lote + "'");
            rs3 = st3.executeQuery("SELECT * from corta_granel where num_lote ='" + num_lote + "'");
            rs4 = st4.executeQuery("SELECT * from corta_granel where num_lote ='" + num_lote + "'");
            rs5 = st5.executeQuery("SELECT * from corta_granel where num_lote ='" + num_lote + "'");
            if (con != null) {
                Document documento = new Document(A4.rotate());
                PdfWriter writer = PdfWriter.getInstance(documento, out);
                FooterPiePaginaiText footer = new FooterPiePaginaiText();
                writer.setPageEvent(footer);

                documento.open();

                try {

                    Image imagenes = Image.getInstance(
                            "C:\\Users\\USUARIO\\Desktop\\simpca\\SIMPCA Coagronorte\\web\\ImagenesR\\coagronorte-slogan.png");
                    imagenes.setAlignment(Element.ALIGN_RIGHT);
                    imagenes.scaleToFit(120, 120);
                    documento.add(imagenes);

                    //documento.add(imagenes);
                    Paragraph par21 = new Paragraph();
                    Font fontDescrip = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.ITALIC, BaseColor.BLACK);
                    par21.add(new Phrase("Cooperativa Agropecuaria de Norte de Santander", fontDescrip));
                    par21.setAlignment(Element.ALIGN_CENTER);
                    par21.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par21);

                    String nombre = null;
                    String Apellido = null;
                    String cedula = null;
                    while (rs.next()) {
                        nombre = (rs.getString("nombre"));
                        cedula = (rs.getString("cedula"));
                        Apellido = (rs.getString("apellido"));
                    }

                    Paragraph par2 = new Paragraph();
                    Font fontfecha = new Font(Font.FontFamily.TIMES_ROMAN, 13, Font.NORMAL, BaseColor.BLACK);
                    Date date = new Date();
                    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy ");
                    par2.add(new Paragraph("Fecha:  " + dateFormat.format(date), fontfecha));
                    //par2.add(new Paragraph(new Date().toString()));
                    par2.setAlignment(Element.ALIGN_RIGHT);
                    ;
                    documento.add(par2);

                    Paragraph par7 = new Paragraph();
                    Font fontUsuario = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL, BaseColor.BLACK);
                    par7.add(new Phrase("Nombre:   " + nombre + "  " + Apellido, fontUsuario));
                    par7.add(new Phrase("\nc.c:   " + cedula, fontUsuario));
                    par7.setAlignment(Element.ALIGN_LEFT);
                    par7.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par7);

                    Paragraph par3 = new Paragraph();
                    Font fontDescri = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK);
                    par3.add(new Phrase("Numero Lote:\n " + num_lote, fontDescri));
                    par3.setAlignment(Element.ALIGN_CENTER);
                    par3.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par3);

                } catch (Exception eX) {
                    eX.getMessage();
                }

                try {

                    Paragraph par1 = new Paragraph();
                    Font fonttitulo = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase("REPORTE CORTA POR GRANEL", fonttitulo));
                    par1.setAlignment(Element.ALIGN_CENTER);
                    par1.add(new Phrase(Chunk.NEWLINE));

                    documento.add(par1);

                    Paragraph par2 = new Paragraph();
                    Font fonttitulo2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par2.add(new Phrase(Chunk.NEWLINE));
                    par2.add(new Phrase(Chunk.NEWLINE));
                    par2.add(new Phrase(Chunk.NEWLINE));
                    par2.add(new Phrase("REPORTE CORTO DE MAQUINA LLANTA", fonttitulo2));
                    par2.setAlignment(Element.ALIGN_CENTER);
                    par2.add(new Phrase(Chunk.NEWLINE));

                    documento.add(par2);

                    PdfPTable tabla = new PdfPTable(4);
                    FontFactory.registerDirectories();
                    documento.add(new Paragraph("\n"));
                    PdfPCell celda1 = new PdfPCell(new Paragraph("Fecha",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda2 = new PdfPCell(new Paragraph("Cantidad (Llanta)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda3 = new PdfPCell(new Paragraph("Valor Unidad (Llanta)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda4 = new PdfPCell(new Paragraph("Valor Total (Llanta)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));

                    tabla.addCell(celda1);
                    tabla.addCell(celda2);
                    tabla.addCell(celda3);
                    tabla.addCell(celda4);

                    while (rs2.next()) {

                        tabla.addCell(rs2.getString("fecha_crg"));
                        tabla.addCell(rs2.getString("cantidad_mq_llanta_crg"));
                        tabla.addCell(rs2.getString("valor_mq_llanta_crg"));
                        tabla.addCell(rs2.getString("valor_total_mq_llanta_crg"));

                    }
                    documento.add(tabla);

                    Paragraph par4 = new Paragraph();

                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    Font fontFooter2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par4.add(new Phrase("REPORTE CORTO DE MAQUINA ORUGA", fontFooter2));
                    par4.setAlignment(Element.ALIGN_CENTER);
                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par4);

                    PdfPTable tabla2 = new PdfPTable(3);
                    FontFactory.registerDirectories();

                    PdfPCell celda5 = new PdfPCell(new Paragraph("Cantidad (Oruga)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda6 = new PdfPCell(new Paragraph("Valor Unidad (Oruga)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda7 = new PdfPCell(new Paragraph("Valor Total (Oruga)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));

                    tabla2.addCell(celda5);
                    tabla2.addCell(celda6);
                    tabla2.addCell(celda7);

                    while (rs3.next()) {
                        tabla2.addCell(rs3.getString("cantidad_mq_oruga_crg"));
                        tabla2.addCell(rs3.getString("valor_mq_oruga_crg"));
                        tabla2.addCell(rs3.getString("valor_total_mq_oruga_crg"));
                    }

                    documento.add(tabla2);

                    Paragraph par8 = new Paragraph();

                    par8.add(new Phrase(Chunk.NEWLINE));
                    par8.add(new Phrase(Chunk.NEWLINE));
                    par8.add(new Phrase(Chunk.NEWLINE));
                    Font fontFooter4 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par8.add(new Phrase("REPORTE COSTOS DE FLETE", fontFooter4));
                    par8.setAlignment(Element.ALIGN_CENTER);
                    par8.add(new Phrase(Chunk.NEWLINE));
                    par8.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par8);

                    PdfPTable tabla3 = new PdfPTable(3);
                    FontFactory.registerDirectories();
                    PdfPCell celda100 = new PdfPCell(new Paragraph("Cantidad (Flete)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda100.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda110 = new PdfPCell(new Paragraph("Valor Unidad (Flete)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda110.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda120 = new PdfPCell(new Paragraph("Valor Total (Flete)",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda120.setHorizontalAlignment(Element.ALIGN_CENTER);

                    tabla3.addCell(celda100);
                    tabla3.addCell(celda110);
                    tabla3.addCell(celda120);

                    while (rs4.next()) {
                        tabla3.addCell(rs4.getString("cantidad_flete_crg"));
                        tabla3.addCell(rs4.getString("valor_flete_crg"));
                        tabla3.addCell(rs4.getString("valor_total_flete_crg"));
                    }

                    documento.add(tabla3);

                    Paragraph par9 = new Paragraph();

                    par9.add(new Phrase(Chunk.NEWLINE));
                    par9.add(new Phrase(Chunk.NEWLINE));
                    par9.add(new Phrase(Chunk.NEWLINE));
                    Font fontFooter5 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par9.add(new Phrase("REPORTE COSTOS ADICIONALES", fontFooter5));
                    par9.setAlignment(Element.ALIGN_CENTER);
                    par9.add(new Phrase(Chunk.NEWLINE));
                    par9.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par9);

                    PdfPTable tabla4 = new PdfPTable(4);
                    FontFactory.registerDirectories();
                    PdfPCell celda150 = new PdfPCell(new Paragraph("Valor Alimentacin",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda150.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda140 = new PdfPCell(new Paragraph("Valor Celadura Mquina",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda140.setHorizontalAlignment(Element.ALIGN_CENTER);

                    PdfPCell celda160 = new PdfPCell(new Paragraph("Valor Administracin",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda160.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda170 = new PdfPCell(new Paragraph("Costo Total",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda170.setHorizontalAlignment(Element.ALIGN_CENTER);

                    tabla4.addCell(celda140);
                    tabla4.addCell(celda150);
                    tabla4.addCell(celda160);
                    tabla4.addCell(celda170);

                    while (rs5.next()) {
                        tabla4.addCell(rs5.getString("valor_celaduria_maquina_crg"));
                        tabla4.addCell(rs5.getString("valor_alimentacion_crg"));
                        tabla4.addCell(rs5.getString("valor_administracion_crg"));
                        tabla4.addCell(rs5.getString("valor_total_crg"));
                    }

                    documento.add(tabla4);

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

                documento.close();

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

    } finally {
        out.close();
    }
}

From source file:ServletsReportesPDF.ReporteCortaMaleza.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//  ww w .  j  a  va  2 s.  c om
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    String num_lote = request.getParameter("num_lote");

    response.setContentType("application/pdf");
    OutputStream out = response.getOutputStream();

    try {
        try {

            Connection con = null;
            Statement st = null;
            Statement st2 = null;
            Statement st3 = null;
            ResultSet rs = null;
            ResultSet rs2 = null;
            ResultSet rs3 = null;
            Class.forName("com.mysql.jdbc.Driver");
            con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/simpca", "root",
                    "9510");

            st = (Statement) con.createStatement();
            st2 = (Statement) con.createStatement();
            st3 = (Statement) con.createStatement();
            rs = st.executeQuery(
                    "SELECT usuario.cedula,nombre,apellido,telefono FROM usuario JOIN lote ON lote.usuario_cedula=usuario.cedula WHERE lote.num_lote='"
                            + num_lote + "'");
            rs2 = st2.executeQuery("SELECT * from manejo_residuos_cosecha where num_lote ='" + num_lote + "'");
            rs3 = st3.executeQuery("SELECT * from manejo_residuos_cosecha where num_lote ='" + num_lote + "'");
            if (con != null) {
                Document documento = new Document(A4.rotate());
                PdfWriter writer = PdfWriter.getInstance(documento, out);
                FooterPiePaginaiText footer = new FooterPiePaginaiText();
                writer.setPageEvent(footer);

                documento.open();

                try {

                    Image imagenes = Image.getInstance(
                            "C:\\Users\\USUARIO\\Desktop\\simpca\\SIMPCA Coagronorte\\web\\ImagenesR\\coagronorte-slogan.png");
                    imagenes.setAlignment(Element.ALIGN_RIGHT);
                    imagenes.scaleToFit(120, 120);
                    documento.add(imagenes);

                    //documento.add(imagenes);
                    Paragraph par21 = new Paragraph();
                    Font fontDescrip = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.ITALIC, BaseColor.BLACK);
                    par21.add(new Phrase("Cooperativa Agropecuaria de Norte de Santander", fontDescrip));
                    par21.setAlignment(Element.ALIGN_CENTER);
                    par21.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par21);

                    String nombre = null;
                    String Apellido = null;
                    String cedula = null;
                    while (rs.next()) {
                        nombre = (rs.getString("nombre"));
                        cedula = (rs.getString("cedula"));
                        Apellido = (rs.getString("apellido"));
                    }

                    Paragraph par2 = new Paragraph();
                    Font fontfecha = new Font(Font.FontFamily.TIMES_ROMAN, 13, Font.NORMAL, BaseColor.BLACK);
                    Date date = new Date();
                    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy ");
                    par2.add(new Paragraph("Fecha:  " + dateFormat.format(date), fontfecha));
                    //par2.add(new Paragraph(new Date().toString()));
                    par2.setAlignment(Element.ALIGN_RIGHT);
                    ;
                    documento.add(par2);

                    Paragraph par7 = new Paragraph();
                    Font fontUsuario = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL, BaseColor.BLACK);
                    par7.add(new Phrase("Nombre:   " + nombre + "  " + Apellido, fontUsuario));
                    par7.add(new Phrase("\nc.c:   " + cedula, fontUsuario));
                    par7.setAlignment(Element.ALIGN_LEFT);
                    par7.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par7);

                    Paragraph par3 = new Paragraph();
                    Font fontDescri = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK);
                    par3.add(new Phrase("Numero Lote:\n " + num_lote, fontDescri));
                    par3.setAlignment(Element.ALIGN_CENTER);
                    par3.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par3);

                } catch (Exception eX) {
                    eX.getMessage();
                }

                try {

                    Paragraph par1 = new Paragraph();
                    Font fonttitulo = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase("REPORTE MANEJO RESIDUOS DE COSECHA", fonttitulo));
                    par1.setAlignment(Element.ALIGN_CENTER);
                    par1.add(new Phrase(Chunk.NEWLINE));

                    documento.add(par1);

                    PdfPTable tabla = new PdfPTable(5);
                    FontFactory.registerDirectories();
                    documento.add(new Paragraph("\n"));
                    PdfPCell celda1 = new PdfPCell(new Paragraph("Fecha",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda2 = new PdfPCell(new Paragraph("Tipo de Manejo",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda3 = new PdfPCell(new Paragraph("Cantidad Hectreas",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda4 = new PdfPCell(new Paragraph("Valor de Hectreas",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda5 = new PdfPCell(new Paragraph("Valor Total",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));

                    tabla.addCell(celda1);
                    tabla.addCell(celda2);
                    tabla.addCell(celda3);
                    tabla.addCell(celda4);
                    tabla.addCell(celda5);

                    while (rs2.next()) {

                        tabla.addCell(rs2.getString("fecha_mrc"));
                        tabla.addCell(rs2.getString("tipo_manejo_mrc"));
                        tabla.addCell(rs2.getString("cantidad_hectareas_mrc"));
                        tabla.addCell(rs2.getString("valor_hectareas_mrc"));
                        tabla.addCell(rs2.getString("valor_total_mrc"));

                    }
                    documento.add(tabla);

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

                documento.close();

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

    } finally {
        out.close();
    }
}

From source file:ServletsReportesPDF.ReporteDespalille.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//from   w ww  . j  a  v  a2s  . c om
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    String num_lote = request.getParameter("num_lote");

    response.setContentType("application/pdf");
    OutputStream out = response.getOutputStream();

    try {
        try {

            Connection con = null;
            Statement st = null;
            Statement st2 = null;
            ResultSet rs = null;
            ResultSet rs2 = null;
            Class.forName("com.mysql.jdbc.Driver");
            con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/simpca", "root",
                    "9510");

            st = (Statement) con.createStatement();
            st2 = (Statement) con.createStatement();
            rs = st.executeQuery(
                    "SELECT usuario.cedula,nombre,apellido,telefono FROM usuario JOIN lote ON lote.usuario_cedula=usuario.cedula WHERE lote.num_lote='"
                            + num_lote + "'");
            rs2 = st2.executeQuery("SELECT * from despalille where num_lote ='" + num_lote + "'");
            if (con != null) {
                Document documento = new Document(A4.rotate());
                PdfWriter writer = PdfWriter.getInstance(documento, out);
                FooterPiePaginaiText footer = new FooterPiePaginaiText();
                writer.setPageEvent(footer);

                documento.open();

                try {

                    Image imagenes = Image.getInstance(
                            "C:\\Users\\USUARIO\\Desktop\\simpca\\SIMPCA Coagronorte\\web\\ImagenesR\\coagronorte-slogan.png");
                    imagenes.setAlignment(Element.ALIGN_RIGHT);
                    imagenes.scaleToFit(120, 120);
                    documento.add(imagenes);

                    //documento.add(imagenes);
                    Paragraph par21 = new Paragraph();
                    Font fontDescrip = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.ITALIC, BaseColor.BLACK);
                    par21.add(new Phrase("Cooperativa Agropecuaria de Norte de Santander", fontDescrip));
                    par21.setAlignment(Element.ALIGN_CENTER);
                    par21.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par21);

                    String nombre = null;
                    String Apellido = null;
                    String cedula = null;
                    while (rs.next()) {
                        nombre = (rs.getString("nombre"));
                        cedula = (rs.getString("cedula"));
                        Apellido = (rs.getString("apellido"));
                    }

                    Paragraph par2 = new Paragraph();
                    Font fontfecha = new Font(Font.FontFamily.TIMES_ROMAN, 13, Font.NORMAL, BaseColor.BLACK);
                    Date date = new Date();
                    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy ");
                    par2.add(new Paragraph("Fecha:  " + dateFormat.format(date), fontfecha));
                    //par2.add(new Paragraph(new Date().toString()));
                    par2.setAlignment(Element.ALIGN_RIGHT);
                    ;
                    documento.add(par2);

                    Paragraph par7 = new Paragraph();
                    Font fontUsuario = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL, BaseColor.BLACK);
                    par7.add(new Phrase("Nombre:   " + nombre + "  " + Apellido, fontUsuario));
                    par7.add(new Phrase("\nc.c:   " + cedula, fontUsuario));
                    par7.setAlignment(Element.ALIGN_LEFT);
                    par7.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par7);

                    Paragraph par3 = new Paragraph();
                    Font fontDescri = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK);
                    par3.add(new Phrase("Numero Lote:\n " + num_lote, fontDescri));
                    par3.setAlignment(Element.ALIGN_CENTER);
                    par3.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par3);

                } catch (Exception eX) {
                    eX.getMessage();
                }

                try {

                    Paragraph par1 = new Paragraph();
                    Font fonttitulo = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase("REPORTE DESPALILLE", fonttitulo));
                    par1.setAlignment(Element.ALIGN_CENTER);
                    par1.add(new Phrase(Chunk.NEWLINE));

                    documento.add(par1);

                    PdfPTable tabla = new PdfPTable(4);
                    FontFactory.registerDirectories();
                    documento.add(new Paragraph("\n"));
                    PdfPCell celda1 = new PdfPCell(new Paragraph("Fecha",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda2 = new PdfPCell(new Paragraph("Cantidad Jornales",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda3 = new PdfPCell(new Paragraph("Valor Unitario Jornal",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda4 = new PdfPCell(new Paragraph("Valor Total Jornal",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));

                    tabla.addCell(celda1);
                    tabla.addCell(celda2);
                    tabla.addCell(celda3);
                    tabla.addCell(celda4);

                    while (rs2.next()) {

                        tabla.addCell(rs2.getString("fecha_dsp"));
                        tabla.addCell(rs2.getString("cantidad_mano_obra_dsp"));
                        tabla.addCell(rs2.getString("precio_mano_obra_dsp"));
                        tabla.addCell(rs2.getString("total_mano_obra_dsp"));

                    }
                    documento.add(tabla);

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

                documento.close();

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

    } finally {
        out.close();
    }
}

From source file:ServletsReportesPDF.ReporteEntresaque.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  w w  w.jav  a  2s . com*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    String num_lote = request.getParameter("num_lote");

    response.setContentType("application/pdf");
    OutputStream out = response.getOutputStream();

    try {
        try {

            Connection con = null;
            Statement st = null;
            Statement st2 = null;
            ResultSet rs = null;
            ResultSet rs2 = null;
            Class.forName("com.mysql.jdbc.Driver");
            con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/simpca", "root",
                    "9510");

            st = (Statement) con.createStatement();
            st2 = (Statement) con.createStatement();
            rs = st.executeQuery(
                    "SELECT usuario.cedula,nombre,apellido,telefono FROM usuario JOIN lote ON lote.usuario_cedula=usuario.cedula WHERE lote.num_lote='"
                            + num_lote + "'");
            rs2 = st2.executeQuery("SELECT * from entresaque where num_lote ='" + num_lote + "'");
            if (con != null) {
                Document documento = new Document(A4.rotate());
                PdfWriter writer = PdfWriter.getInstance(documento, out);
                FooterPiePaginaiText footer = new FooterPiePaginaiText();
                writer.setPageEvent(footer);

                documento.open();

                try {

                    Image imagenes = Image.getInstance(
                            "C:\\Users\\USUARIO\\Desktop\\simpca\\SIMPCA Coagronorte\\web\\ImagenesR\\coagronorte-slogan.png");
                    imagenes.setAlignment(Element.ALIGN_RIGHT);
                    imagenes.scaleToFit(200, 200);
                    documento.add(imagenes);

                    //documento.add(imagenes);
                    Paragraph par21 = new Paragraph();
                    Font fontDescrip = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.ITALIC, BaseColor.BLACK);
                    par21.add(new Phrase("Cooperativa Agropecuaria de Norte de Santander", fontDescrip));
                    par21.setAlignment(Element.ALIGN_CENTER);
                    par21.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par21);

                    String nombre = null;
                    String Apellido = null;
                    String cedula = null;
                    while (rs.next()) {
                        nombre = (rs.getString("nombre"));
                        cedula = (rs.getString("cedula"));
                        Apellido = (rs.getString("apellido"));
                    }

                    Paragraph par2 = new Paragraph();
                    Font fontfecha = new Font(Font.FontFamily.TIMES_ROMAN, 13, Font.NORMAL, BaseColor.BLACK);
                    Date date = new Date();
                    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy ");
                    par2.add(new Paragraph("Fecha:  " + dateFormat.format(date), fontfecha));
                    //par2.add(new Paragraph(new Date().toString()));
                    par2.setAlignment(Element.ALIGN_RIGHT);
                    ;
                    documento.add(par2);

                    Paragraph par7 = new Paragraph();
                    Font fontUsuario = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL, BaseColor.BLACK);
                    par7.add(new Phrase("Nombre:   " + nombre + "  " + Apellido, fontUsuario));
                    par7.add(new Phrase("\nc.c:   " + cedula, fontUsuario));
                    par7.setAlignment(Element.ALIGN_LEFT);
                    par7.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par7);

                    Paragraph par3 = new Paragraph();
                    Font fontDescri = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK);
                    par3.add(new Phrase("Numero Lote:\n " + num_lote, fontDescri));
                    par3.setAlignment(Element.ALIGN_CENTER);
                    par3.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par3);

                } catch (Exception eX) {
                    eX.getMessage();
                }

                try {

                    Paragraph par1 = new Paragraph();
                    Font fonttitulo = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase("REPORTE ENTRESAQUE", fonttitulo));
                    par1.setAlignment(Element.ALIGN_CENTER);
                    par1.add(new Phrase(Chunk.NEWLINE));

                    documento.add(par1);

                    PdfPTable tabla = new PdfPTable(4);
                    FontFactory.registerDirectories();
                    documento.add(new Paragraph("\n"));
                    PdfPCell celda1 = new PdfPCell(new Paragraph("Fecha",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda2 = new PdfPCell(new Paragraph("Cantidad Jornales",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda3 = new PdfPCell(new Paragraph("Valor Unitario Jornal",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda4 = new PdfPCell(new Paragraph("Valor Total Jornal",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));

                    tabla.addCell(celda1);
                    tabla.addCell(celda2);
                    tabla.addCell(celda3);
                    tabla.addCell(celda4);

                    while (rs2.next()) {

                        tabla.addCell(rs2.getString("fecha_etsq"));
                        tabla.addCell(rs2.getString("cantidad_mano_obra_etsq"));
                        tabla.addCell(rs2.getString("precio_mano_obra_etsq"));
                        tabla.addCell(rs2.getString("total_mano_obra_etsq"));

                    }
                    documento.add(tabla);

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

                documento.close();

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

    } finally {
        out.close();
    }
}

From source file:ServletsReportesPDF.ReporteFumigas.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  w w  w.j  a  va 2  s.  c om*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    String num_lote = request.getParameter("num_lote");

    response.setContentType("application/pdf");
    OutputStream out = response.getOutputStream();

    try {
        try {

            Connection con = null;
            Statement st = null;
            Statement st2 = null;
            Statement st3 = null;
            ResultSet rs = null;
            ResultSet rs2 = null;
            ResultSet rs3 = null;
            Class.forName("com.mysql.jdbc.Driver");
            con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/simpca", "root",
                    "9510");

            st = (Statement) con.createStatement();
            st2 = (Statement) con.createStatement();
            st3 = (Statement) con.createStatement();
            rs = st.executeQuery(
                    "SELECT usuario.cedula,nombre,apellido,telefono FROM usuario JOIN lote ON lote.usuario_cedula=usuario.cedula WHERE lote.num_lote='"
                            + num_lote + "'");
            rs2 = st2.executeQuery("SELECT * from fumiga where num_lote ='" + num_lote + "'");
            rs3 = st3.executeQuery(
                    "SELECT * from fumiga f JOIN  insumos_fumiga i on i.id_fumiga = f.id_fumiga where f.num_lote ='"
                            + num_lote + "'");
            if (con != null) {
                Document documento = new Document(A4.rotate());
                PdfWriter writer = PdfWriter.getInstance(documento, out);
                FooterPiePaginaiText footer = new FooterPiePaginaiText();
                writer.setPageEvent(footer);

                documento.open();

                try {

                    Image imagenes = Image.getInstance(
                            "C:\\Users\\USUARIO\\Desktop\\simpca\\SIMPCA Coagronorte\\web\\ImagenesR\\coagronorte-slogan.png");
                    imagenes.setAlignment(Element.ALIGN_RIGHT);
                    imagenes.scaleToFit(200, 200);
                    documento.add(imagenes);

                    //documento.add(imagenes);
                    Paragraph par21 = new Paragraph();
                    Font fontDescrip = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.ITALIC, BaseColor.BLACK);
                    par21.add(new Phrase("Cooperativa Agropecuaria de Norte de Santander", fontDescrip));
                    par21.setAlignment(Element.ALIGN_CENTER);
                    par21.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par21);

                    String nombre = null;
                    String Apellido = null;
                    String cedula = null;
                    while (rs.next()) {
                        nombre = (rs.getString("nombre"));
                        cedula = (rs.getString("cedula"));
                        Apellido = (rs.getString("apellido"));
                    }

                    Paragraph par2 = new Paragraph();
                    Font fontfecha = new Font(Font.FontFamily.TIMES_ROMAN, 13, Font.NORMAL, BaseColor.BLACK);
                    Date date = new Date();
                    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy ");
                    par2.add(new Paragraph("Fecha:  " + dateFormat.format(date), fontfecha));
                    //par2.add(new Paragraph(new Date().toString()));
                    par2.setAlignment(Element.ALIGN_RIGHT);
                    ;
                    documento.add(par2);

                    Paragraph par7 = new Paragraph();
                    Font fontUsuario = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL, BaseColor.BLACK);
                    par7.add(new Phrase("Nombre:   " + nombre + "  " + Apellido, fontUsuario));
                    par7.add(new Phrase("\nc.c:   " + cedula, fontUsuario));
                    par7.setAlignment(Element.ALIGN_LEFT);
                    par7.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par7);

                    Paragraph par3 = new Paragraph();
                    Font fontDescri = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK);
                    par3.add(new Phrase("Numero Lote:\n " + num_lote, fontDescri));
                    par3.setAlignment(Element.ALIGN_CENTER);
                    par3.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par3);

                } catch (Exception eX) {
                    eX.getMessage();
                }

                try {

                    Paragraph par1 = new Paragraph();
                    Font fonttitulo = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase(Chunk.NEWLINE));
                    par1.add(new Phrase("REPORTE FUMIGAS", fonttitulo));
                    par1.setAlignment(Element.ALIGN_CENTER);
                    par1.add(new Phrase(Chunk.NEWLINE));

                    documento.add(par1);

                    PdfPTable tabla = new PdfPTable(6);
                    FontFactory.registerDirectories();
                    documento.add(new Paragraph("\n"));
                    PdfPCell celda1 = new PdfPCell(new Paragraph("Fecha",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda2 = new PdfPCell(new Paragraph("Tipo de Fumiga",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda3 = new PdfPCell(new Paragraph("Cantidad Jornales",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda4 = new PdfPCell(new Paragraph("Valor Jornal",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda5 = new PdfPCell(new Paragraph("Valor Total Mano Obra",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    PdfPCell celda6 = new PdfPCell(new Paragraph("Valor Total Fumiga",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));

                    tabla.addCell(celda1);
                    tabla.addCell(celda2);
                    tabla.addCell(celda3);
                    tabla.addCell(celda4);
                    tabla.addCell(celda5);
                    tabla.addCell(celda6);

                    while (rs2.next()) {

                        tabla.addCell(rs2.getString("fecha_fumiga"));
                        tabla.addCell(rs2.getString("nombre_fumiga_fumiga"));
                        tabla.addCell(rs2.getString("cantidad_mano_obra_fumiga"));
                        tabla.addCell(rs2.getString("valor_uni_mano_obra_fumiga"));
                        tabla.addCell(rs2.getString("valor_total_mano_obra_fumiga"));
                        tabla.addCell(rs2.getString("valor_total_fumiga"));

                    }
                    documento.add(tabla);

                    Paragraph par4 = new Paragraph();

                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    Font fontFooter2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK);
                    par4.add(new Phrase("REPORTE INSUMOS FUMIGAS", fontFooter2));
                    par4.setAlignment(Element.ALIGN_CENTER);
                    par4.add(new Phrase(Chunk.NEWLINE));
                    par4.add(new Phrase(Chunk.NEWLINE));
                    documento.add(par4);

                    PdfPTable tabla2 = new PdfPTable(6);
                    FontFactory.registerDirectories();
                    PdfPCell celda10 = new PdfPCell(new Paragraph("Tipo",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda10.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda20 = new PdfPCell(new Paragraph("Nombre",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda20.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda30 = new PdfPCell(new Paragraph("Cantidad",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda30.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda40 = new PdfPCell(new Paragraph("Unidad",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda40.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda50 = new PdfPCell(new Paragraph("Valor Unitario",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda50.setHorizontalAlignment(Element.ALIGN_CENTER);
                    PdfPCell celda60 = new PdfPCell(new Paragraph("Valor Total",
                            FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK)));
                    celda60.setHorizontalAlignment(Element.ALIGN_CENTER);

                    tabla2.addCell(celda10);
                    tabla2.addCell(celda20);
                    tabla2.addCell(celda30);
                    tabla2.addCell(celda40);
                    tabla2.addCell(celda50);
                    tabla2.addCell(celda60);

                    while (rs3.next()) {
                        tabla2.addCell(rs3.getString("tipo_insumo"));
                        tabla2.addCell(rs3.getString("nombre_insumo"));
                        tabla2.addCell(rs3.getString("cantidad_insumo"));
                        tabla2.addCell(rs3.getString("unidad_insumo"));
                        tabla2.addCell(rs3.getString("valor_unitario_insumo"));
                        tabla2.addCell(rs3.getString("valor_total_insumos"));
                    }

                    documento.add(tabla2);

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

                documento.close();

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

    } finally {
        out.close();
    }
}