java - how to align the columns properly in DynamicReports -
i using dynamicreports design reports pdf.here using componentcolumnbuilder
and horizantallist
, verticallist
.i able display them columns fixed widths.which shown below
my code follows
jasperreportbuilder report = dynamicreports.report();//a new report stylebuilder plainstyle = stl.style().setfontname("freeuniversal"); stylebuilder boldstyle = stl.style(plainstyle).bold().setborder(stl.pen1point()); stylebuilder col1style = stl.style().setleftborder(stl.pen1point()); stylebuilder col2style = stl.style().setleftborder(stl.pen1point()).setbottomborder(stl.pen1point()); stylebuilder col3style = stl.style().bold().setbottomborder(stl.pen1point()).setleftborder(stl.pen1point()); verticallistbuilder companylist = cmp.verticallist(); companylist.add(cmp.horizontallist().add(cmp.text(field("companyname", type.stringtype()))).setstyle(col1style)); companylist.add(cmp.horizontallist().add(cmp.text(field("branchlocationaddress", type.stringtype()))).setstyle(col1style)); companylist.add(cmp.horizontallist().add(cmp.text("mobile number:")).add(cmp.text(field("mobilenumber", type.stringtype()))).setstyle(col1style)); companylist.add(cmp.horizontallist().add(cmp.text("phone number:")).add(cmp.text(field("landlinenumber", type.stringtype()))).setstyle(col1style)); companylist.add(cmp.horizontallist().add(cmp.text("email:")).add(cmp.text(field("emailid", type.stringtype()))).setstyle(col2style)); companylist.add(cmp.horizontallist().add(cmp.text(field("organizationname", type.stringtype()))).setstyle(col1style)); companylist.add(cmp.horizontallist().add(cmp.text(field("deliveryaddress", type.stringtype()))).setstyle(col1style).setfixedheight(30)); companylist.add(cmp.horizontallist().add(cmp.text("contact number:")).add(cmp.text(field("phoneno", type.stringtype()))).setstyle(col2style)); companylist.add(cmp.horizontallist().add(cmp.text("works address:same above")).setstyle(col3style).setfixedheight(40)); componentcolumnbuilder namecolumn = col.componentcolumn("", companylist).setfixedwidth(275); verticallistbuilder receivinglist = cmp.verticallist(); receivinglist.add(cmp.horizontallist().add(cmp.text("invoice no")).setstyle(col1style)); receivinglist.add(cmp.horizontallist().add(cmp.text(field("invoiceno", type.stringtype()))).setstyle(col2style)); receivinglist.add(cmp.horizontallist().add(cmp.text("delivery note")).setstyle(col1style)); receivinglist.add(cmp.horizontallist().add(cmp.text(field("deliverynote", type.stringtype()))).setstyle(col2style)); receivinglist.add(cmp.horizontallist().add(cmp.text("esugam no")).setstyle(col1style)); receivinglist.add(cmp.horizontallist().add(cmp.text(field("esugamno", type.stringtype()))).setstyle(col2style)); receivinglist.add(cmp.horizontallist().add(cmp.text("buyer order no")).setstyle(col1style)); receivinglist.add(cmp.horizontallist().add(cmp.text(field("buyerorderno", type.stringtype()))).setstyle(col2style)); receivinglist.add(cmp.horizontallist().add(cmp.text("dispatch document no")).setstyle(col1style)); receivinglist.add(cmp.horizontallist().add(cmp.text(field("dispatchdocumentno", type.stringtype()))).setstyle(col2style)); receivinglist.add(cmp.horizontallist().add(cmp.text("dispatch through")).setstyle(col1style)); receivinglist.add(cmp.horizontallist().add(cmp.text(field("dispatchthrough", type.stringtype()))).setstyle(col2style)); componentcolumnbuilder receivingcolumn = col.componentcolumn("", receivinglist).setfixedwidth(137); verticallistbuilder invoicelist = cmp.verticallist(); invoicelist.add(cmp.horizontallist().add(cmp.text("dated")).setstyle(col1style)); invoicelist.add(cmp.horizontallist().add(cmp.text(field("invoicedate", type.stringtype()))).setstyle(col2style)); invoicelist.add(cmp.horizontallist().add(cmp.text("mode/terms of payment")).setstyle(col1style)); invoicelist.add(cmp.horizontallist().add(cmp.text(field("termsofpayment", type.stringtype()))).setstyle(col2style)); invoicelist.add(cmp.horizontallist().add(cmp.text("other reference")).setstyle(col2style)); invoicelist.add(cmp.horizontallist().add(cmp.text("dated")).setstyle(col1style)); invoicelist.add(cmp.horizontallist().add(cmp.text(field("buydate", type.stringtype()))).setstyle(col2style)); invoicelist.add(cmp.horizontallist().add(cmp.text("dated")).setstyle(col1style)); invoicelist.add(cmp.horizontallist().add(cmp.text(field("dated", type.stringtype()))).setstyle(col2style)); invoicelist.add(cmp.horizontallist().add(cmp.text("destination")).setstyle(col1style)); invoicelist.add(cmp.horizontallist().add(cmp.text(field("destination", type.stringtype()))).setstyle(col2style)); componentcolumnbuilder invoicecolumn = col.componentcolumn("", invoicelist).setfixedwidth(138); report .columnheader(//title of report components.text("tax invoice cum delivery challan").setstyle(boldstyle).setfixedheight(10) .sethorizontalalignment(horizontalalignment.center)) .columns(namecolumn) .columns(receivingcolumn) .columns(invoicecolumn) .pagefooter(components.pagexofy())//show page number on page footer .setdatasource("select companyname,branchlocationaddress,mobilenumber,landlinenumber,emailid,invoiceno,deliverynote,esugamno,invoicedate,termsofpayment,organizationname,deliveryaddress,phoneno,buyerorderno,dispatchdocumentno,dispatchthrough,buydate,dated,destination marketing_database.company_profile,marketing_database.invoiceclient_details invoiceclient_details.cid ='1'", connection); try { //show report report.show(); //export report pdf file report.topdf(new fileoutputstream("c:/report.pdf")); } catch (drexception e) { e.printstacktrace(); } catch (filenotfoundexception e) { e.printstacktrace(); } }
as can see in pic columns alignment irregular. questions if data in database large , when fill data pdf,the alignment should damaged. mean 3 columns should come in same line. in appreciated
Comments
Post a Comment