I use HTML bridge window.print () to print a range between 20-30. The client says that he is printing blank pages. We can only play it on our machine.
This is the code in xaml that combines all the pages on one page and prints them. This code works and prints all pages for me. We only need this in IE. I use windows 8 and IE 10. But for the client, it prints one blank page with a header and footer. It works correctly if it prints the current page or prints all pages from start to finish.
But if he tries to print a range of 23-30, he will only print 23-27 or so. Sometimes it prints only one blank page with a header and footer. Unfortunately, none of them happen on my machine. The client said they tried it on IE 8, IE 9, and IE 11. Can some of them indicate what options I have or what things I could look for
Page.xaml.cs
Dictionary<int, List<string>> AllPages = new Dictionary<int, List<string>>();
--code to add to AllPages
for (int Page = startPage; Page <= endPage; Page++)
{
if (AllPages.ContainsKey(Page))
{
List<string> PageLines = AllPages[Page];
this.m_Div = this.m_HtmlDoc.CreateElement("DIV");
if (Page != AllPages.Count)
{
this.m_Div.SetAttribute("ID", "Page");
}
this.m_Table = this.m_HtmlDoc.CreateElement("TABLE");
this.m_Div.AppendChild(this.m_Table);
for (int Line = 0; Line < PageLines.Count; Line++)
{
this.m_TR = this.m_HtmlDoc.CreateElement("TR");
this.m_TD = this.m_HtmlDoc.CreateElement("TD");
this.m_TD.SetProperty("innerText", PageLines[Line]);
this.m_TR.AppendChild(this.m_TD);
this.m_Table.AppendChild(this.m_TR);
}
this.m_PrintReport.AppendChild(this.m_Div);
}
}
HtmlPage.Window.Invoke("printfunction", m_PrintReport);
CSS
body
{
background:#ffffff;
color:#000000;
font-family: rvConsolas;
margin: 0px;
width:100%;
height:100%;
background-color:#DDD;
min-height:100%;
}
html{
width:100%;
height:100%;
}
@font-face
{
font-family: rvConsolas;
font-style: normal;
font-weight: normal;
src: url(EmConsola.eot);
src: url('EmConsola.eot?#iefix') format('embedded-opentype')
}
@page
{
size: auto;
margin: 0mm;
}
#rptViewer
{
display: none;
visibility: hidden;
}
#printReport
{
visibility: visible;
font-family: rvConsolas;
overflow: hidden;
display:inline-block;
}
td
{
font-family: rvConsolas;
overflow:visible;
font-size: 52%;
display:block;
}
#Page
{
page-break-after: always;
}
Aspx page
<link href="Style/style.css" rel="Stylesheet" media="screen" />
<link href="Style/print.css" type="text/css" rel="Stylesheet" media="print" />
<script src="Scripts/Silverlight.js" type="text/javascript"></script>
<script type="text/javascript">
function init() {
printReport.style.display = false;
}
function onSLLoad(plugIn, userContext, sender) {
alert("silverlight");
window.status +=
plugIn.id + " loaded into " + userContext + ". ";
}
function printfunction(arg) {
var contents = arg.innerHTML;
var frame1 = document.createElement('iframe');
frame1.name = "frame1";
frame1.style.position = "absolute";
frame1.style.top = "-1000000px";
document.body.appendChild(frame1);
var frameDoc = (frame1.contentWindow) ? frame1.contentWindow : (frame1.contentDocument.document) ? frame1.contentDocument.document : frame1.contentDocument;
frameDoc.document.open();
frameDoc.document.write('<html><head>');
frameDoc.document.write('</head><body>');
var path = "Style";
var style = document.createElement('link');
style.rel = 'stylesheet';
style.type = 'text/css';
style.href = path + '/print.css';
frameDoc.document.getElementsByTagName('head')[0].appendChild(style);
frameDoc.document.write(contents);
frameDoc.document.write('</body></html>');
frameDoc.document.close();
setTimeout(function () {
frame1.contentWindow.focus();
frame1.contentWindow.print();
document.body.removeChild(frame1);
},1000);
}
</script>
</head>
<body>
<div id="printReport" style ="
white-space: nowrap; ">
</div>
</body>
source
share