【问题标题】:Mix landscape and portrait printing in wpf / c#在 wpf / c# 中混合横向和纵向打印
【发布时间】:2011-10-16 16:38:39
【问题描述】:

在 WPF / C# 应用程序中,我正在使用 DocumentPaginator 打印一些页面。 但是,我想在横向和纵向模式下混合 1 个打印作业页面: 例如,纵向第 1 页、横向第 2 页和纵向第 3 页。

但是,如果我更改 PageSize(从 DocumentPaginator 覆盖)以反映横向,则页面将保持纵向模式。

换句话说,在

public class PrintPaginator : DocumentPaginator
    {
        public override Size PageSize { get; set; }
        public override DocumentPage GetPage(int pageNumber)
        {
            // size values
            Size theSizeOfThePage;
            // make size orientation correct
            if (pageNumber == 2)
            {
                // landscape: width is larger then height
                theSizeOfThePage = new Size(Math.Max(PageSize.Width, PageSize.Height), Math.Min(PageSize.Width, PageSize.Height));
            }
            else
            {
                // portrait: height is larger then width
                theSizeOfThePage = new Size(Math.Min(PageSize.Width, PageSize.Height), Math.Max(PageSize.Width, PageSize.Height));
            }
            PageSize = theSizeOfThePage;

            // set the grid as the page to print
            thePage = new Grid();
            thePage.Width = PageSize.Width;
            thePage.Height = PageSize.Height;

            [...]

            // return a documentpage wrapping the grid
            return new DocumentPage(thePage);
        }

我相信我不能更早地将 Orientation 或 PageSize 设置为 Landscape,因为这取决于正在打印的页码...

在 1 个打印作业中混合纵向和横向的任何想法、建议和解决方法?

谢谢! R.

【问题讨论】:

  • 我没有对您的要求进行任何研究,但会说在大多数编程实例中,宽度大于高度基本上是无效的。像这样设置它不会旋转页面,事实上,大多数语言会简单地“修复”它感觉不正确的地方并反转这些让你保持相同的页面大小。您确实需要寻找方向或旋转命令/功能。

标签: wpf printing landscape-portrait documentpaginator


【解决方案1】:

你问了很久,我知道,但是你有没有试过直接在调用 new DocumentPage() 的构造函数中设置 PageSize?

更多详情见我的博客: http://wieser-software.blogspot.co.uk/2012/07/landscape-printing-and-preview-in-wpf.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-24
    • 1970-01-01
    • 2012-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多