css - Using iTextSharp to export to PDF and repeat headers -


i have gone through quite few posts , tried suggested, header not being repeated on page webgrid flows on to.

here code :

public filestreamresult exportcombinedpdf(int projectid)     {         list<pipelinedetails> pipelist = new list<pipelinedetails>();         projectmanager pm = new projectmanager();          pipelist = pm.getpipelinelist(projectid);          //this css styling webgrid         string webgridstyle = pm.pipeline_htmlforexport(projectid);         //this creating table other details being exported         string projecthtml = pm.project_htmlforexport(projectid);          webgrid grid = new webgrid(source: pipelist, canpage: false, cansort: false);         string gridhtml = grid.gethtml(tablestyle: "webgrid",                                        headerstyle: "webgridheader",                                        alternatingrowstyle: "webgridalt",                 columns: grid.columns(                  grid.column("nodenumber", "node nr."),                  grid.column("accumulated_length", "accumulated length"),                  grid.column("elevation", "elevation"),                  grid.column("pipe_outside_diameter", "pipe outside diameter"),                  grid.column("wall_thickness", "wall thickness"),                  grid.column("control_point_description", "control point description"),                  grid.column("control_point_size", "control point size"))).tostring();          string exportdata = string.format("<html><body>{0}{1} <br /> {2}</body></html>", "<style>" + webgridstyle + "</style>", projecthtml, gridhtml);          var bytes = system.text.encoding.utf8.getbytes(exportdata);         using (var input = new memorystream(bytes))         {             var output = new memorystream();             var document = new itextsharp.text.document(pagesize.a4, 50, 50, 50, 50);             var writer = pdfwriter.getinstance(document, output);              font headerfont = fontfactory.getfont("verdana", 10);             font rowfont = fontfactory.getfont("verdana", 10);              writer.closestream = false;             document.open();              var xmlworker = itextsharp.tool.xml.xmlworkerhelper.getinstance();             xmlworker.parsexhtml(writer, document, input, system.text.encoding.utf8);              document.close();             output.position = 0;              return file(output, "application/pdf", "pipeline_report.pdf");              //return new filestreamresult(output, "application/pdf");         }      } 

i have tried adding repeat-header:yes css, did not work. tried adding following code below, did not work :

//this done before document opened :             pdfptable table = new pdfptable(7);              table.headerrows = 2;  //this done before document closed :              document.add(table); 

but mentioned, did not work. cant imagine difficult set repeat header.

otherwise, next option set webgrid start on new page. possible ?

i appreciate help. thank you.

so able pagebreak work. thought giving me result wanted, post answer.

i changed exportdata string adding pagebreak :

string exportdata = string.format("<html><body>{0}{1} <p style='page-break-after:always;'></p> {2}</body></html>", "<style>" + webgridstyle + "</style>", projecthtml, gridhtml); 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -