在这里,我们将给大家分享关于css–SilverlightHTMLBridge打印window.print()空白页面的知识,同时也会涉及到如何更有效地c#–SilverlightProgrammat
在这里,我们将给大家分享关于css – Silverlight HTML Bridge打印window.print()空白页面的知识,同时也会涉及到如何更有效地c# – Silverlight Programmatical Drawing(从Windows Forms转换为Silverlight)、html5 – HTML 5 CSS 3> = Microsoft Silverlight、Javascript创建Silverlight Plugin以及自定义nonSilverlight和lowSilverlight样式_javascript技巧、Mobilize.Net Silverlight bridge to Windows 10 UWP的内容。
本文目录一览:- css – Silverlight HTML Bridge打印window.print()空白页面
- c# – Silverlight Programmatical Drawing(从Windows Forms转换为Silverlight)
- html5 – HTML 5 CSS 3> = Microsoft Silverlight
- Javascript创建Silverlight Plugin以及自定义nonSilverlight和lowSilverlight样式_javascript技巧
- Mobilize.Net Silverlight bridge to Windows 10 UWP
css – Silverlight HTML Bridge打印window.print()空白页面
客户说它正在打印空白页面.
我们只能在他们的机器上重现它.
这是xaml中的代码,它将一个页面中的所有页面组合在一起并打印出来.
此代码适用于我并打印所有页面.我们只在IE上需要这个
我使用的是Windows 8和IE 10.但是对于客户端,它会打印一个带有页眉和页脚URL的空白页面.如果他打印当前页面或从头到尾打印所有页面,它可以正常工作.
但如果他试图打印范围,23-30,它只打印23-27左右.
有时它只打印一个带有页眉和页脚URL的空白页面.不幸的是,这些都不会发生在我的机器上客户说他们在IE 8,IE 9和IE 11上尝试过它.
有人可以建议我有什么选择或者我可以注意什么
Page.xaml.cs Dictionary<int,List<string>> AllPages = new Dictionary<int,List<string>>(); --code to add to AllPages // Load all pages onto page 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; /* the margin on the content before printing */ 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; /* auto is the current printer page size */ margin: 0mm; /* this affects the margin in the printer settings */ } #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
<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"https://www.jb51.cc/tag/Now/" target="_blank">Nowrap; "> </div> </body>
解决方法
>首先,这是一个HTML问题,与Silverlight无关.您应该能够生成原始HTML文件,以在客户端站点上重现该问题.
>其次,您应该尝试打印到不同的纸张尺寸.美国A4尺寸略短于国际A4.
>您应该探索使用CSS分页符指令:
div#PAGE {page-break-after: always;}
>更新如果您希望支持页面方向,则可以在CSS中使用media queries.
@media print and (orientation: landscape) { /* landscape styles */ } @media print and (orientation: portrait) { /* portrait styles */ div#PAGE {page-break-after: always;} }
>由于我们的贫穷开发者仍然需要支持(咳嗽)IE8 – 试用polyfill.它们是提供IE8媒体查询支持的JavaScript库.见respond.js或modernizr.
c# – Silverlight Programmatical Drawing(从Windows Forms转换为Silverlight)
bmp = new Bitmap(columns*32,rows*32); graphics = Graphics.FromImage(bmp); pictureBox1.Size = new Size(columns * 32,rows * 32); pictureBox1.Image = bmp;
这我用来填充Windows窗体中的图形,
private void drawImageInBox(Image src,int BoxX,int BoxY,int Offset = 0) { graphics.DrawImage(src,new Point((BoxY * 32) + Offset,(BoxX * 32) + Offset)); }
当所有操作完成后我只刷新PictureBox,
pictureBox1.Refresh();
我如何在Silverlight xaml中实现这一目标?
解决方法
在你的XAML中:
<Grid x:Name="world_grid" Width="100" Height="100"> <Grid.RowDeFinitions> <RowDeFinition Height="*" /> <!--Repeat this for however many rows you need --> </Grid.RowDeFinitions> <Grid.ColumnDeFinitions> <ColumnDeFinition Width="*" /> <!--Same here,for columns--> </Grid.ColumnDeFinitions> </Grid>
在你的代码隐藏中:
for each image you need to add: Image img = new Image(); img.source = new Uri("some/dir/img.png"); // coding in-place,can't remember Syntax world_grid.Children.Add(img); Grid.SetRow(img,0); // places this image in row 0 Grid.SetColumn(img,5); // places this image in column 5
一个非常重要的注意事项:每次“刷新”您的“世界”时,请确保在重新添加之前删除相应的图像!更好的是,您可以在某些数组中跟踪这些图像,并更改其行/列.如果需要,可以将图像的可见性设置为隐藏/折叠.
html5 – HTML 5 CSS 3> = Microsoft Silverlight
解决方法
纯HTML CSS(即使它是HTML5和CSS3)只会产生网站,除非你在它们后面添加一些代码/框架.
因此,虽然在视觉上它们可能看起来相似但它们是幕后的两个完全独立的东西
Javascript创建Silverlight Plugin以及自定义nonSilverlight和lowSilverlight样式_javascript技巧
默认情况下,生成的页面代码可能与下面的代码类似:
我们可以给object对象传递不同的参数,如xap包的加载地址,onLoad或onError事件句柄,背景色,最小版本号支持等等,完整的参数信息读者可以参考Silverlight 3中param参数列表汇总。object对象中一般会包含一段标记,是用来显示当客户端浏览器未安装Silverlight插件时要显示的内容的,我们可以自定义其中的内容,如: