Jump to content

Last Row Contents Of Table In A Page Break While Printing To Paper

Recommended Posts

Hi ...I intend to print a table to paper but when I print it using IE, instead of printing the whole row at the next page, the last row breaks into two parts and the contents of it are displayed incompletely. I've tried so many different solutions but none of them worked for me.Here is my code. I want to print the table using JavaScript

StringWriter sw = new StringWriter();		HtmlTextWriter hw = new HtmlTextWriter(sw);		table.Style[HtmlTextWriterStyle.BorderCollapse] = "collapse";		table.Style["page-break-after"] = "auto";		table.Style["page-break-inside"] = "avoid";		table.Style["display"] = "block";		table.RenderControl(hw);		string gridHTML = sw.ToString().Replace("\"", "'")			.Replace(System.Environment.NewLine, "");		StringBuilder sb = new StringBuilder();		sb.Append("<script type = 'text/javascript'>");		sb.Append("window.onload = new function(){");		sb.Append("var printWin = window.open('', '', 'right=0");		sb.Append(",top=0,width=1000,height=600,status=0,toolbar=1,scrollbars=1');");		sb.Append("printWin.document.write(\"");		sb.Append(gridHTML);		sb.Append("\");");		sb.Append("printWin.document.close();");		sb.Append("printWin.focus();");		sb.Append("printWin.print();");		sb.Append("printWin.close();};");		sb.Append("</script>");		ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...