如何使用混合页面方向打印 FlowDocument 而无需旋转?
我有一个在 FlowDocument 中定义的报告。在该报告中,我有一些部分想要以横向模式打印。 为了做到这一点,我编写了一个肮脏的 DocumentPaginator hack,它为标记为横向的部分创建一个面向横向的 FlowDocument。
public override DocumentPage GetPage(int pageNumber)
{
// some code
if (section.Name.Equals("landscapePage"))
{
var landscapeDocument = new FlowDocument();
landscapeDocument.PageWidth = document.PageHeight;
landscapeDocument.ColumnWidth = document.PageWidth - 50;
landscapeDocument.PageHeight = document.PageWidth;
landscapeDocument.Blocks.Add(section);
var landscapePaginator = ((IDocumentPaginatorSource)landscapeDocument).DocumentPaginator;
var landscapePage = landscapePaginator.GetPage(0);
return landscapePage;
}
// more code
如果我打印到 XPS 文档,这看起来就像预期的那样。横向标记的页面在 XPS 查看器中以横向模式显示。但是,如果我直接打印文档或从 XPS 查看器打印文档,打印机不会旋转横向页面,并且内容的右侧会被裁剪。
我还尝试在 Word 中制作混合模式文档,该文档按预期打印,但如果我将同一文档保存为 XPS 并使用 XPS 查看器打印它,则横向页面会被裁剪。这让我想知道 XPS 是否支持混合页面方向。
我知道我可以从页面中提取视觉对象并添加 90 度旋转变换。我已经尝试过,打印时效果很好,但如果保存为 XPS 或 PDF,页面显然会旋转,这在显示器上查看打印时效果不佳。
有没有一种方法可以在不使用旋转变换的情况下以混合方向打印 FlowDocuments?
I have a report defined in a FlowDocument. In that report I have some sections that I want to print in landscape mode.
In order to do that I have written a dirty DocumentPaginator hack that creates a landscape oriented FlowDocument for sections marked as landscape.
public override DocumentPage GetPage(int pageNumber)
{
// some code
if (section.Name.Equals("landscapePage"))
{
var landscapeDocument = new FlowDocument();
landscapeDocument.PageWidth = document.PageHeight;
landscapeDocument.ColumnWidth = document.PageWidth - 50;
landscapeDocument.PageHeight = document.PageWidth;
landscapeDocument.Blocks.Add(section);
var landscapePaginator = ((IDocumentPaginatorSource)landscapeDocument).DocumentPaginator;
var landscapePage = landscapePaginator.GetPage(0);
return landscapePage;
}
// more code
This looks just as expected if I print to an XPS document. The landscape marked pages are shown in landscape mode in the XPS Viewer. However if I print the document either directly or from the XPS Viewer the printer doesn't rotate the landscape page and the right side of the content is cropped.
I also tried to make a mixed mode document in Word, that prints as expected, but if I save the same document as XPS and print it using the XPS Viewer, the landscape pages get cropped. This makes me wonder if XPS supports mixed page orientations at all.
I know that I could extract a Visual from the page and add a 90 degree rotation transform. I have tried that and it works fine when printing, but if saved as XPS or PDF the pages are obviously rotated which is less than optimal when the print is viewed on a monitor.
Is there a way to print FlowDocuments in mixed orientations without using a rotate transform?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论