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.
这似乎没有做任何事情。在定义任何打印设置之前,我仍然在打印预览中获得完全相同的输出。说实话,我不完全确定这应该如何运作。据推测,我的浏览器必须再次使用新的用户代理(???)请求页面,以使Sitecore返回页面的不同呈现...但我尝试过Firefox,Chrome和IE并获得同样的不受欢迎从我的“默认”设备输出。
Must be missing something obvious?
必须遗漏一些明显的东西?
2 个解决方案
#1
5
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.
默认情况下,当您要打印的页面上有?p = 1查询字符串值时,将使用打印设备。浏览器中的打印预览只是使用默认设备预览页面。
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.
如您所述,可以通过浏览器代理切换设备,但这在此处没有用。这主要用于移动设备检测。
#2
0
To access print device dynamically on anchor click, do following
要在锚点击时动态访问打印设备,请执行以下操作
default.aspx
Default.aspx的
<asp:HyperLink ID="hlPrintLink" runat="server">
</asp:hyperlink>
//default.aspx.cs
//default.aspx.cs
HospitalDirectionsPageItem objHospital = Sitecore.Context.Item;
string deviceName = "print";
DeviceItem deviceItem = Sitecore.Context.Database.Resources.Devices.GetAll().Where(d => d.Name.ToLower() == deviceName.ToLower()).First();
if (deviceItem != null)
{
hlPrintLink.NavigateUrl = Sitecore.Links.LinkManager.GetItemUrl(objHospital) + "?" + deviceItem.QueryString;
}
#1
5
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.
默认情况下,当您要打印的页面上有?p = 1查询字符串值时,将使用打印设备。浏览器中的打印预览只是使用默认设备预览页面。
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.
如您所述,可以通过浏览器代理切换设备,但这在此处没有用。这主要用于移动设备检测。
#2
0
To access print device dynamically on anchor click, do following
要在锚点击时动态访问打印设备,请执行以下操作
default.aspx
Default.aspx的
<asp:HyperLink ID="hlPrintLink" runat="server">
</asp:hyperlink>
//default.aspx.cs
//default.aspx.cs
HospitalDirectionsPageItem objHospital = Sitecore.Context.Item;
string deviceName = "print";
DeviceItem deviceItem = Sitecore.Context.Database.Resources.Devices.GetAll().Where(d => d.Name.ToLower() == deviceName.ToLower()).First();
if (deviceItem != null)
{
hlPrintLink.NavigateUrl = Sitecore.Links.LinkManager.GetItemUrl(objHospital) + "?" + deviceItem.QueryString;
}