asp.net - Space between data tables while converting into pdf -
asp.net - Space between data tables while converting into pdf -
how include spaces between info tables while generating pdf document pdfwriter?
this relevant code snippet:
public void exporttopdf(datatable dt) { document document = new document(); pdfwriter author = pdfwriter.getinstance(document, new filestream("e://sample2.pdf", filemode.create)); document.open(); itextsharp.text.font font5 = itextsharp.text.fontfactory.getfont(fontfactory.helvetica, 5); int col = dt.columns.count; int row1 = dt.rows.count; int newcol; if (col > convert.toint16(txt_columns.text)) { newcol = convert.toint16(txt_columns.text); } else { newcol = col; } int k=0, prev=0, dummy=0; dummy = newcol; (int num_table = 1, temp = 0; num_table <= ((col / dummy) + 1); num_table++, temp++) { if (newcol > 0) { pdfptable table = new pdfptable(newcol); pdfprow row = null; float[] widths = new float[newcol]; (int = 0; < newcol; i++) { widths[i] = 4f; } table.setwidths(widths); table.widthpercentage = 100; int icol = 0; string colname = ""; pdfpcell cell = new pdfpcell(new phrase("products")); cell.colspan = newcol; int j = 1; foreach (datacolumn c in dt.columns) { if (j > temp * dummy && j <= num_table * dummy) { table.addcell(new phrase(c.columnname, font5)); } j++; } foreach (datarow r in dt.rows) { if (dt.rows.count > 0) { (k=prev; k < ((num_table * dummy > col) ? col : (num_table * dummy)); k++) { table.addcell(new phrase(r[k].tostring(), font5)); } } } prev = k; if (newcol > (col - (num_table * newcol))) { newcol = (col - (num_table * newcol)); } document.add(table); } // need code gap here } document.close(); }
the space needed @ end. poster might utilize open source itext library generate pdf-document.
thank you!
there different ways add together "space". in context of tables, utilize this:
table.spacingbefore = 5; table.spacingafter = 5;
the first line adds 5pts of space before table. sec line adds 5pts of space after table.
you add together newline. there different ways this:
document.add(chunk.newline); // height of newline depend on leading document.add(new paragraph("\n")); // can define leading `paragraph`; default 16pt ...
there may other solutions, give ones above seek , allow know 1 works best you.
asp.net pdf-generation itextsharp
Comments
Post a Comment