c# - Hiding table border in iTextSharp -


how can hide table border using itextsharp. using following code generate file:

var document = new document(pagesize.a4, 50, 50, 25, 25);  // create new pdfwriter object, specifying output stream var output = new memorystream(); var writer = pdfwriter.getinstance(document, output);  document.open(); pdfptable table = new pdfptable(3); var bodyfont = fontfactory.getfont("arial", 10, font.normal); pdfpcell cell = new pdfpcell(new phrase("header spanning 3 columns")); cell.colspan = 3; cell.horizontalalignment = 1; //0=left, 1=centre, 2=right table.addcell(cell); font arial = fontfactory.getfont("arial", 6, basecolor.blue); cell = new pdfpcell(new phrase("font test here ", arial)); cell.paddingleft = 5f; cell.colspan = 1; table.addcell(cell); cell = new pdfpcell(new phrase("xyx")); cell.colspan = 2; table.addcell(cell); cell = new pdfpcell(new phrase("hello world")); cell.paddingleft = 5f; cell.colspan = 1; table.addcell(cell); cell = new pdfpcell(new phrase("xyx")); cell.colspan = 2; table.addcell(cell);    table.spacingbefore = 5f; document.add(table); document.close();  response.contenttype = "application/pdf"; response.addheader("content-disposition", "attachment;filename=receipt-test.pdf"); response.binarywrite(output.toarray()); 

do need specify no borders individual cells or can specify no borders table itself.

thank you

although upvoted answer martijn, want add clarification.

only cells have borders in itext; tables don't have border. martijn's suggestion set border of default cell no_border correct:

table.defaultcell.border = rectangle.no_border; 

but won't work code snippet provided in question. properties of default cell used if itext needs create pdfpcell instance implicitly (for instance: if use addcell() method passing phrase parameter).

in code snippet provided @brown_dynamite, pdfpcell objects created explicitly. means need set border of each of these cells no_border.

usually, write factory class create cells. way, can reduce amount of code in class creates table.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -