如何让 Sitecore(和我的浏览器)使用打印布局?
我添加了一些支持,以便以适合打印机的格式打印网站的特定页面。所以我做的第一件事就是创建一个或多或少的空白布局,我可以将内容放入其中。然后我转到内容页面并将此布局分配给“演示文稿详细信息”中的“打印”设备。
这似乎没有做任何事情。我仍然在打印预览中获得与定义任何打印设置之前看到的完全相同的输出。老实说,我不完全确定这应该如何运作。据推测,我的浏览器必须使用新的用户代理(???)再次请求该页面,以使 Sitecore 返回不同的页面呈现...但我尝试过 Firefox、Chrome 和 IE,但得到了相同的不良结果我的“默认”设备的输出。
一定缺少一些明显的东西吗?
I am adding some support to print specific pages of my site in a nice printer-friendly format. So the first thing I did was create a more-or-less blank Layout that I can drop content into. Then I went to a content page and assigned this layout to the "Print" device in Presentation Details.
That does not seem to do anything. I'm still getting the exact same output on Print Preview that I saw before I defined any Print settings. To be honest, I'm not entirely sure how this should work. Presumably, my browser has to request the page again with a new user agent (???) to get Sitecore to return a different rendering of the page... but I've tried Firefox, Chrome, and IE and get the same undesired output from my "Default" device.
Must be missing something obvious?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
默认情况下,当您要打印的页面上存在
?p=1
查询字符串值时,将使用打印设备。浏览器中的打印预览只是使用默认设备预览页面。尝试将该查询字符串放入地址中,看看是否获得了您期望的布局。
正如您所指出的,可以通过浏览器代理切换设备,但这在这里没有用。这主要用于移动设备检测。
The Print device, by default, will be used when there is a
?p=1
querystring value on the page you want to print. The print preview in the browser is simply previewing the page with the Default device.Try putting that querystring in the address and see if you get the layout you are expecting.
As you noted, there is the ability to switch Device via a Browser Agent, but that won't be useful here. That would mainly be used for mobile device detection.
要在锚点单击时动态访问打印设备,请执行以下操作
default.aspx
//default.aspx.cs
To access print device dynamically on anchor click, do following
default.aspx
//default.aspx.cs