You are on page 1of 2

coneccion ob=new coneccion(); public void pdf(String[]tit, String sql, int num,int res)throws SQLException , DocumentException,FileNotFoundException, IOException{ String

titulo=" "+tit[0]; for(int i=1,j;i<tit.length;i++){ for(j=0;j<(res-tit[i-1].length());j++) titulo=titulo+" "; titulo=titulo+tit[i];

} ResultSet res=ob.resul(sql); Document document =new Document(); PdfWriter.getInstance(document, new FileOutputStream("tablePDF.pdf")); document.open(); document.add(new Paragraph(titulo, new Font (Font.FontFamily.HELVETICA,16,0,BaseColor.BLUE))); document.add(new Paragraph((" "), new Font (Font.FontFamily.HELVETICA,5,6,BaseColor.RED))); PdfPTable table=new PdfPTable(num); while(res.next()){ for(int i=0;i<=num;i++){ table.addCell(res.getString(i++)); } document.add(table); document.rightMargin(); document.close(); File path=new File("tablePDF.pdf"); Desktop.getDesktop().open(path);

usuario mgusuario=new usuario(); } }

You might also like