java - How to position a table in iText -
thanks taking time answer question. i'm dynamically filling data in pdf template. working expected except 1 part. table generating in java code not displayed in pdf. question how position table in top left corner using itext's api?
this code far:
pdfptable table = new pdfptable(3); pdfpcell cell = new pdfpcell(new phrase("vat rate")); table.setwidthpercentage(500); table.addcell(cell); cell = new pdfpcell(new phrase("net value")); table.addcell(cell); table.addcell("vat amount"); table.addcell(double.tostring(currentvatrate)); table.addcell(double.tostring(currentvatratenetvalue)); table.addcell(double.tostring(currentvatvatamount)); table.addcell("totals"); table.addcell(double.tostring(subtotalexcludingvat)); table.addcell(double.tostring(totalvatamount));
basically need 3 column table, each column 33%. how set tables position?
try this:
// table.setwidthpercentage( 500 ); table.setwidths( new int[]{ 1, 1, 1 } );
you should using following code:
com.itextpdf.text.document document = new com.itextpdf.text.document( com.itextpdf.text.pagesize.a4 ); fileoutputstream fos = new fileoutputstream( outputfilefolder + "pdftableexample.pdf" ); com.itextpdf.text.pdf.pdfwriter pdfwriter = com.itextpdf.text.pdf.pdfwriter.getinstance( document, fos ); document.open(); document.add( table ); document.close();
Comments
Post a Comment