List of usage examples for com.itextpdf.text Font BOLD
int BOLD
To view the source code for com.itextpdf.text Font BOLD.
Click Source Link
From source file:be.thomasmore.service.CreatePDFServiceImp.java
@Override public void createPDF(List<Score> scores) { try {/* ww w. java 2s. com*/ OutputStream file = new FileOutputStream(new File("D:\\Desktop\\Scores.pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); document.add(new Paragraph("Scores")); document.add(new Paragraph(new Date().toString())); document.addAuthor("Projectgroep 4"); document.addCreator("Projectgroep 4"); document.addTitle("ScoreTracker"); //Create Paragraph Paragraph paragraph = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); //New line paragraph.add(new Paragraph(" ")); paragraph.add("Scores"); paragraph.add(new Paragraph(" ")); document.add(paragraph); //Create a table in PDF PdfPTable pdftabel = new PdfPTable(4); PdfPCell cell1 = new PdfPCell(new Phrase("Student")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); cell1 = new PdfPCell(new Phrase("Vak")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); cell1 = new PdfPCell(new Phrase("Test")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); cell1 = new PdfPCell(new Phrase("Score")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); pdftabel.setHeaderRows(1); for (Score score : scores) { pdftabel.addCell(score.getStudent().getNaam()); pdftabel.addCell(score.getTest().getVak().getNaam()); pdftabel.addCell(score.getTest().getNaam()); int resultaat = score.getScore(); pdftabel.addCell(resultaat + " / " + score.getTest().getTotaal()); } document.add(pdftabel); document.addCreationDate(); document.close(); file.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:be.thomasmore.service.CreatePDFServiceImp.java
@Override public void createPDFVoorStudent(ArrayList<ArrayList<Score>> puntenlijst, List<Double> gemiddeldelijst, Double totaalGemiddelde) { try {/* w w w .ja v a 2 s . com*/ OutputStream file = new FileOutputStream(new File("D:\\Desktop\\Scores.pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); document.add(new Paragraph("Scores")); document.add(new Paragraph(puntenlijst.get(0).get(0).getStudent().getNaam())); document.add(new Paragraph(new Date().toString())); document.addAuthor("Projectgroep 4"); document.addCreator("Projectgroep 4"); document.addTitle("ScoreTracker"); //Create Paragraph Paragraph paragraph = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); //New line paragraph.add(new Paragraph(" ")); paragraph.add("Scores"); paragraph.add(new Paragraph(" ")); document.add(paragraph); for (int i = 0; i < puntenlijst.size(); i++) { //Create a table in PDF PdfPTable pdftabel = new PdfPTable(2); //vak invullen paragraph = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); paragraph.add(new Paragraph(puntenlijst.get(i).get(0).getTest().getVak().getNaam())); document.add(paragraph); PdfPCell cell1 = new PdfPCell(new Phrase("Test")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); cell1 = new PdfPCell(new Phrase("Score")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); pdftabel.setHeaderRows(1); for (Score score : puntenlijst.get(i)) { pdftabel.addCell(score.getTest().getNaam()); int resultaat = score.getScore(); pdftabel.addCell(resultaat + " / " + score.getTest().getTotaal()); } document.add(pdftabel); //gemmidelde per vak invoeren paragraph = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); paragraph.add(new Paragraph("Gemiddelde: " + gemiddeldelijst.get(i).toString())); document.add(paragraph); } paragraph = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); paragraph.add(new Paragraph("Algemeen gemiddelde: " + totaalGemiddelde)); document.add(paragraph); document.addCreationDate(); document.close(); file.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:be.zenodotus.creatie.GeneratePDF.java
License:Open Source License
public String vakantieAfdruk(Context context, String name, int jaar) { this.context = context; PdfWriter w = null;/*www. ja v a2s . c o m*/ Document d = new Document(PageSize.A4.rotate(), 5, 5, 10, 10); d.setPageCount(3); String fileName = name; String file = name; GregorianCalendar datum = new GregorianCalendar(); datum.set(GregorianCalendar.YEAR, jaar); String[] maanden = { "Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December" }; int[] dagen = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; VerlofDao dao = new VerlofDao(context); FeestdagDao feestdagDao = new FeestdagDao(context); WerkdagDao werkdagDao = new WerkdagDao(context); File folder = new File(context.getFilesDir(), "pdfs"); folder.mkdirs(); if (datum.isLeapYear(jaar)) { dagen[1] = 29; } File temp = null; temp = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "Jacqueline" + jaar + ".pdf"); fileName = temp.toString(); try { dao.open(); ArrayList<Verlof> verloflijst = dao.getAlleVerlovenPerJaar(jaar); w = PdfWriter.getInstance(d, new FileOutputStream(temp)); d.open(); d.addAuthor("Jacqueline Vandenbroecke"); d.addCreationDate(); d.addCreator("Verlofplanner"); d.addTitle("Vakantie " + jaar + " van Jacqueline Vandenbroecke"); Font standaard = FontFactory.getFont(FontFactory.HELVETICA, 8); Font standaardBold = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD); Paragraph gegeven = new Paragraph("Jacqueline Vandenbroecke Verlof " + jaar + "\n", standaardBold); gegeven.setAlignment(Paragraph.ALIGN_CENTER); d.add(gegeven); for (int paginas = 0; paginas < 2; paginas++) { int aantal = 0; if (paginas == 1) { d.newPage(); aantal = 6; } PdfPTable table = new PdfPTable(6); for (int i = aantal; i < (aantal + 6); i++) { PdfPCell cell = new PdfPCell(new Paragraph(maanden[i], standaardBold)); cell.setBorder(1); table.addCell(cell); } int dag = 1; int k = aantal; for (int i = aantal; i < (aantal + 6); i++) { for (int j = 0; j < 32; j++) { if (k > ((aantal + 6) - 1)) { k = aantal; dag++; } if (dag > dagen[k]) { PdfPCell cell = new PdfPCell(new Paragraph("", standaard)); table.addCell(cell); k++; } else { SimpleDateFormat formatterDag = new SimpleDateFormat("dd"); SimpleDateFormat formatterWeek = new SimpleDateFormat("EEE"); datum.set(jaar, k, dag); PdfPTable dagTabel = new PdfPTable(4); PdfPCell cellDag = new PdfPCell( new Paragraph(formatterDag.format(datum.getTime()), standaard)); PdfPCell cellWeek = new PdfPCell( new Paragraph(formatterWeek.format(datum.getTime()), standaard)); ArrayList<Verlof> verlof = new ArrayList<Verlof>(); for (int z = 0; z < verloflijst.size(); z++) { if (((verloflijst.get(z).getDag() + 1) == dag) && (verloflijst.get(z).getMaand() == k)) { verlof.add(verloflijst.get(z)); } } feestdagDao.open(); Feestdag feestdag = feestdagDao.getFeestdag(jaar, datum.get(GregorianCalendar.MONTH), datum.get(GregorianCalendar.DATE)); feestdagDao.close(); werkdagDao.open(); java.util.List<Werkdag> weekend = werkdagDao.getWeekend(); werkdagDao.close(); String Verlof = ""; String uur = ""; if (verlof.size() > 0) { if (verlof.size() > 1) { Verlof = verlof.get(0).getVerlofsoort() + "\n" + verlof.get(1).getVerlofsoort(); uur = verlof.get(0).getUrental() + "\n" + verlof.get(1).getUrental(); } else { Verlof = verlof.get(0).getVerlofsoort(); uur = verlof.get(0).getUrental(); } } PdfPCell cellVerlof = new PdfPCell(new Paragraph(Verlof, standaard)); PdfPCell uren = new PdfPCell(new Paragraph(uur, standaard)); if (verlof.size() > 0) { BaseColor kleur = new BaseColor(Color.GRAY); cellVerlof.setBackgroundColor(kleur); uren.setBackgroundColor(kleur); cellDag.setBackgroundColor(kleur); cellWeek.setBackgroundColor(kleur); } for (int z = 0; z < weekend.size(); z++) { if ((formatterWeek.format(datum.getTime())).equals(weekend.get(z).getDag())) { BaseColor kleur = new BaseColor(Color.LTGRAY); cellVerlof.setBackgroundColor(kleur); uren.setBackgroundColor(kleur); cellDag.setBackgroundColor(kleur); cellWeek.setBackgroundColor(kleur); } } if (feestdag != null) { BaseColor kleur = new BaseColor(Color.GREEN); uren.setBackgroundColor(kleur); cellVerlof.setBackgroundColor(kleur); uren.setBackgroundColor(kleur); cellDag.setBackgroundColor(kleur); cellWeek.setBackgroundColor(kleur); } dagTabel.addCell(cellDag); dagTabel.addCell(cellWeek); dagTabel.addCell(cellVerlof); dagTabel.addCell(uren); table.addCell(dagTabel); k++; } } } d.add(table); dao.close(); } } catch (Exception ex) { ex.printStackTrace(); } finally { d.close(); w.close(); } return fileName; }
From source file:biblioteca.reportes.PdfCreator.java
License:Open Source License
/** * createPdf es una funcin estatica que funciona como plantilla para generar * reportes dinamicos, segn la necesidad del usuario. * @param path La direccin del archivo donde se guardar el pdf * @param titulo El Ttulo que llevar el pdf * @param encabezado Un texto que se mostrar bajo el ttulo * @param tabla La tabla de resultados que mostrar el pdf */// w w w . j av a2 s.c o m static public void createPdf(String path, String titulo, String encabezado, PdfPTable tabla) { Document document = new Document(); // step 2 try { PdfWriter.getInstance(document, new FileOutputStream(path)); Font myFontTitle = new Font(); myFontTitle.setFamily("Arial"); myFontTitle.setStyle(Font.BOLD); myFontTitle.setSize(14); Font Univallef = new Font(); Univallef.setColor(BaseColor.RED); Univallef.setFamily("Arial"); Univallef.setSize(18); Image header = Image .getInstance(PdfCreator.class.getResource("/biblioteca/gui/resources/minilogo.png")); header.setAlignment(Image.ALIGN_CENTER); header.scaleToFit(50, 75); Paragraph Univalle = new Paragraph("Universidad del Valle", Univallef); Univalle.setAlignment(Paragraph.ALIGN_CENTER); Paragraph pTitulo = new Paragraph(titulo, myFontTitle); pTitulo.setAlignment(Paragraph.ALIGN_CENTER); Paragraph biblioteca = new Paragraph("Biblioteca Digital EISC", myFontTitle); biblioteca.setAlignment(Paragraph.ALIGN_CENTER); Paragraph developers = new Paragraph( "Desarrollado por:\n Mara Cristina Bustos \n Alejandro Valds Villada", myFontTitle); developers.setAlignment(Paragraph.ALIGN_CENTER); Paragraph Fecha = new Paragraph("Fecha y Hora del Reporte: " + fecha, myFontTitle); document.open(); // step 4 document.add(header); document.add(new Paragraph("\r\n")); document.add(Univalle); document.add(new Paragraph("\r\n")); document.add(pTitulo); document.add(new Paragraph("\r\n")); document.add(biblioteca); document.add(new Paragraph("\r\n")); document.add(developers); document.add(new Paragraph("\r\n")); document.add(Fecha); document.add(new Paragraph("\r\n")); document.add(new Paragraph(encabezado + (tabla.getRows().size() - 1))); document.add(new Paragraph("\r\n")); document.add(tabla); // step 5 document.close(); } catch (DocumentException de) { System.err.println(de); } catch (IOException ioex) { System.err.println(ioex); } }
From source file:biblioteca.reportes.PdfCreator.java
License:Open Source License
static public void createArrayListPdf(String path, String titulo, String encabezado, ArrayList<PdfPTable> tablas) { Document document = new Document(); ArrayList<String> NombreTablas = new DaoReportesEstadisticas().getNombreTablas(); //step 2//from ww w. j a v a2s . co m try { PdfWriter.getInstance(document, new FileOutputStream(path)); Font myFontTitle = new Font(); myFontTitle.setFamily("Arial"); myFontTitle.setStyle(Font.BOLD); myFontTitle.setSize(12); Font Univallef = new Font(); Univallef.setColor(BaseColor.RED); Univallef.setFamily("Arial"); Univallef.setSize(18); Image header = Image .getInstance(PdfCreator.class.getResource("/biblioteca/gui/resources/minilogo.png")); header.setAlignment(Image.ALIGN_CENTER); header.scaleToFit(50, 75); Paragraph Univalle = new Paragraph("Universidad del Valle", Univallef); Univalle.setAlignment(Paragraph.ALIGN_CENTER); Paragraph pTitulo = new Paragraph(titulo, myFontTitle); pTitulo.setAlignment(Paragraph.ALIGN_CENTER); Paragraph biblioteca = new Paragraph("Biblioteca Digital EISC", myFontTitle); biblioteca.setAlignment(Paragraph.ALIGN_CENTER); Paragraph developers = new Paragraph( "Desarrollado por:\n Mara Cristina Bustos \n Alejandro Valds Villada", myFontTitle); developers.setAlignment(Paragraph.ALIGN_CENTER); Paragraph Fecha = new Paragraph("Fecha y Hora de Reporte: " + fecha, myFontTitle); document.open(); // step 4 document.add(header); document.add(new Paragraph("\r\n")); document.add(Univalle); document.add(new Paragraph("\r\n")); document.add(pTitulo); document.add(new Paragraph("\r\n")); document.add(biblioteca); document.add(new Paragraph("\r\n")); document.add(developers); document.add(new Paragraph("\r\n")); document.add(Fecha); document.add(new Paragraph("\r\n")); for (int i = 0; i < tablas.size(); i++) { document.add(new Paragraph(NombreTablas.get(i))); document.add(new Paragraph(encabezado + (tablas.get(i).getRows().size() - 1))); document.add(new Paragraph("\r\n")); document.add(tablas.get(i)); } // step 5 document.close(); } catch (DocumentException de) { System.err.println(de); } catch (IOException ioex) { System.err.println(ioex); } }
From source file:biblioteca.reportes.PdfCreator.java
License:Open Source License
static public void createDinamicPdf(String path, String titulo, String encabezado, ArrayList<Element> contenido) { Document document = new Document(); //step 2//from w w w. j av a 2s. c om try { PdfWriter.getInstance(document, new FileOutputStream(path)); Font myFontTitle = new Font(); myFontTitle.setFamily("Arial"); myFontTitle.setStyle(Font.BOLD); myFontTitle.setSize(12); Font Univallef = new Font(); Univallef.setColor(BaseColor.RED); Univallef.setFamily("Arial"); Univallef.setSize(18); Image header = Image .getInstance(PdfCreator.class.getResource("/biblioteca/gui/resources/minilogo.png")); header.setAlignment(Image.ALIGN_CENTER); header.scaleToFit(50, 75); Paragraph Univalle = new Paragraph("Universidad del Valle", Univallef); Univalle.setAlignment(Paragraph.ALIGN_CENTER); Paragraph pTitulo = new Paragraph(titulo, myFontTitle); pTitulo.setAlignment(Paragraph.ALIGN_CENTER); Paragraph biblioteca = new Paragraph("Biblioteca Digital EISC", myFontTitle); biblioteca.setAlignment(Paragraph.ALIGN_CENTER); Paragraph developers = new Paragraph( "Desarrollado por:\n Mara Cristina Bustos \n Alejandro Valds Villada", myFontTitle); developers.setAlignment(Paragraph.ALIGN_CENTER); Paragraph Fecha = new Paragraph("Fecha y Hora de Reporte: " + fecha, myFontTitle); //Paragraph Introduccion = new Paragraph("Reporte de usuarios registrados"); document.open(); // step 4 document.add(header); document.add(new Paragraph("\r\n")); document.add(Univalle); document.add(new Paragraph("\r\n")); document.add(pTitulo); document.add(new Paragraph("\r\n")); document.add(biblioteca); document.add(new Paragraph("\r\n")); document.add(developers); document.add(new Paragraph("\r\n")); document.add(Fecha); document.add(new Paragraph("\r\n")); // document.add(Introduccion); document.add(new Paragraph("\r\n")); for (int i = 0; i < contenido.size(); i++) { document.add(contenido.get(i).getClass().equals(new PdfPTable(2).getClass()) ? (PdfPTable) contenido.get(i) : contenido.get(i)); } // step 5 document.close(); } catch (DocumentException de) { System.err.println(de); } catch (IOException ioex) { System.err.println(ioex); } }
From source file:bladwin.web.reg.regPDF.java
public void genPed(String loc, regMgr regMgr, dbMgrInterface db) { Document document = null;//from www .j a v a 2 s. c om //String loc = "C:/_bisc/_javaApps/jlData/jvp/CellWidths.pdf"; //regMgr.getCustomerRegBean().setPdf(loc); try { document = new Document(PageSize.A4, 30, 30, 30, 30); PdfWriter.getInstance(document, new FileOutputStream(loc)); document.open(); customerRegBean r = regMgr.getCustomerRegBean(); customerBean c = regMgr.getCustomerBean(); customerBean a = new custObj().getcustomerBean(r.getRegCustId(), db); mgnLookupBean bean = new mgnLookupObj().getLookupBean(-947, db); Paragraph pg; pg = new Paragraph(r.getLookupDesc()); pg.setAlignment(Paragraph.ALIGN_CENTER); pg.setFont(FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)); document.add(getHeader(r.getLookupDesc())); document.add(getHeader("BALDWIN BLAZERS TRACK CLUB")); document.add(getHeader("REGISTRATION")); pg = new Paragraph("\n\r"); document.add(pg); // ------------------------------------------------------- document.add(genAthleteInfo(r, a)); pg = new Paragraph("\n\r"); document.add(pg); document.add(genParentInfo(c)); pg = new Paragraph("\n\r"); document.add(pg); document.add(genSport(r)); pg = new Paragraph("\n\r"); document.add(pg); pg = new Paragraph("PARENTS SIGNATURE"); document.add(pg); pg = new Paragraph("\n\r"); document.add(pg); pg = new Paragraph("\n\r"); document.add(pg); pg = new Paragraph("_____________________________________________________________________"); document.add(pg); pg = new Paragraph("\n\r"); document.add(pg); document.add(getHeader(r.getFeeDesc() + "\n\r" + bean.getSubjectBody())); // ---------------------------------------------------------------------------- } catch (DocumentException ex) { logger.error("DocumentException", ex); } catch (FileNotFoundException ex) { logger.error("FileNotFoundException", ex); } finally { try { if (document != null) document.close(); //pdfFileOpen(loc); } catch (Exception e) { logger.error("FileNotFoundException", e); } } }
From source file:bladwin.web.reg.regPDF.java
private Paragraph getHeader(String text) { Paragraph pg = new Paragraph(text); pg.setAlignment(Paragraph.ALIGN_CENTER); pg.setFont(FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD)); return pg;// w ww.j a v a 2 s .c om }
From source file:Boss.BOss.java
private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked if (evt.getClickCount() == 2) { try {//from w ww . j a va2 s.c o m connect = new Connection(); Statement st = connect.con.createStatement(); String SQL = "SELECT * FROM request where idrequest =" + getSelectedrequest1(); ResultSet rq = st.executeQuery(SQL); rq.next(); /*****************************/ String type = ""; if (parseInt(rq.getString("id_type")) == 1) { type = "Instalation"; } if (parseInt(rq.getString("id_type")) == 2) { type = "Transfer"; } if (parseInt(rq.getString("id_type")) == 3) { type = "Maintenamce"; } /**************************/ Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("report.pdf")); document.open(); Paragraph paragraph = new Paragraph(); paragraph.add(new Paragraph("Request : \n", FontFactory.getFont(FontFactory.COURIER_BOLD, 20, Font.BOLD, BaseColor.DARK_GRAY))); paragraph.add("ID Request :"); paragraph.add(rq.getString("idRequest") + ""); paragraph.add("\nRequest type :"); paragraph.add(type); paragraph.add("\nClient name :"); paragraph.add(rq.getString("clientName")); paragraph.add("\nPhone number :"); paragraph.add(rq.getString("TELCLIENT")); paragraph.add("\nAddress 1 :"); paragraph.add(rq.getString("address1")); paragraph.add("\nAddress 2 :"); paragraph.add(rq.getString("address2")); paragraph.add("\nTeam :"); paragraph.add(rq.getString("IDTEAM") + "\n"); /***********************/ String sql = "Select * from report where IDREQUEST = '" + getSelectedrequest1() + "' "; ResultSet rs = st.executeQuery(sql); rs.next(); /**********************/ paragraph.add(new Paragraph("Report : \n", FontFactory.getFont(FontFactory.COURIER_BOLD, 20, Font.BOLD, BaseColor.DARK_GRAY))); paragraph.add(rs.getString("REPORT") + "\n"); Paragraph date = new Paragraph(rs.getString("REPORTDATE").toString().substring(0, 10)); date.setAlignment(Element.ALIGN_RIGHT); Paragraph title = new Paragraph("Report\n", FontFactory.getFont(FontFactory.COURIER_BOLD, 20, Font.BOLD, BaseColor.BLACK)); title.setAlignment(Element.ALIGN_CENTER); document.add(date); document.add(title); document.add(paragraph); document.close(); /* Open Pdf */ Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(new File("report.pdf")); } else { System.out.println("Open is not supported"); } } catch (SQLException | ClassNotFoundException | DocumentException ex) { Logger.getLogger(BOss.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(BOss.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(BOss.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:br.com.tcc.relat.BalancoAnual.java
public static void main(String[] args) throws Exception { /* Create Connection objects */ Connection con = new ConnectionFactory().getConnection(); Statement stmt = con.createStatement(); /* Define the SQL query */ ResultSet query = stmt.executeQuery( "SELECT produto.ID, produto.descricao, produto.numEstoque, produto.numEstoqueCritico, unidade.descricao, fornecedor.nome FROM produto as produto INNER JOIN unidade as unidade ON (produto.idUnidade = unidade.id) INNER JOIN fornecedor as fornecedor ON (produto.idFornecedor = fornecedor.id)"); /* Step-2: Initialize PDF documents - logical objects */ Document PDFLogReport = new Document(); //PdfWriter.getInstance(PDFLogReport, new FileOutputStream("C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Balanco.pdf")); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("../../RelatBalanco.pdf")); PDFLogReport.open();//from w ww . jav a2 s .c om Paragraph cabecalho = new Paragraph( "AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n\n\n"); cabecalho.setAlignment(Element.ALIGN_CENTER); PDFLogReport.add(cabecalho); //we have two columns in our table PdfPTable LogTable = new PdfPTable(6); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Balano Anual"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(6); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Produto ", fonte)); LogTable.addCell(new Paragraph("Fornecedor", fonte)); LogTable.addCell(new Paragraph("Unidade", fonte)); LogTable.addCell(new Paragraph("Estoque", fonte)); LogTable.addCell(new Paragraph("Estoque Crtico", fonte)); LogTable.addCell(new Paragraph("Quantidade", fonte)); //create a cell object // PdfPCell table_cell; while (query.next()) { String produto = query.getString("descricao"); LogTable.addCell(new Paragraph(produto, fonteDados)); String fornecedor = query.getString("nome"); LogTable.addCell(new Paragraph(fornecedor, fonteDados)); String unidade = query.getString("unidade.descricao"); LogTable.addCell(new Paragraph(unidade, fonteDados)); String estoque = query.getString("numEstoque"); LogTable.addCell(new Paragraph(estoque, fonteDados)); String critico = query.getString("numEstoqueCritico"); LogTable.addCell(new Paragraph(critico, fonteDados)); LogTable.addCell(new Paragraph(" ", fonteDados)); } /* Attach report table to PDF */ PDFLogReport.add(LogTable); PDFLogReport.close(); /* Close all DB related objects */ query.close(); stmt.close(); con.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Balanco.pdf"; //Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); File pdf = new File("../../RelatBalanco.pdf"); try { Desktop.getDesktop().open(pdf); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Erro ao abrir relatrio: " + ex); } }