横向打印时win10和以前版本之间的区别 [英] Difference between win10 and previous versions when printing in landscape

查看:85
本文介绍了横向打印时win10和以前版本之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我注意到与以前的版本相比,在Win10中打印页面有所不同.

在Win7中执行此代码,无论哪个更大(如果Width或高度),只需设置横向属性就足以使打印机以横向方向打印.

在Win10中执行相同的代码,我需要定义宽度始终大于高度.如果不是,则将其打印为纵向.

这是正常行为吗?我的意思是,您是否根据宽度/高度来决定纸张方向?

这是我正在使用的代码:

 var w = 793.92;
            var h = 1122.24;

            var fixedDocument = new FixedDocument();
            fixedDocument.DocumentPaginator.PageSize = new Size(w,h);
            
            var page = new PageContent();
            var fixedPage = new FixedPage {宽度= w,高度= h};

            var text = new TextBlock()
                {
                    FontSize = 12
                    文字=这应该是横向的. W: + w +"高: +小时,
                };

            FixedPage.SetLeft(text,100);
            FixedPage.SetTop(text,100);

            fixedPage.Children.Add(text);
            page.Child = fixedPage;
            fixedDocument.Pages.Add(page);
            var paginator = fixedDocument.DocumentPaginator;
            
            PrintDialog对话框= new PrintDialog();
            如果(dialog.ShowDialog()== true)
            {
                dialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Landscape;

                var size = dialog.PrintQueue.GetPrintCapabilities().PageMediaSizeCapability;
                
                foreach(大小为var)
{
                    如果(s.PageMediaSizeName.HasValue& s.PageMediaSizeName == PageMediaSizeName.ISOA4)
                    {
                        dialog.PrintTicket.PageMediaSize = s;
                    }
}

                dialog.PrintDocument(paginator,"Test");
            } 

解决方案

您好Andrés

这是围绕景观的已知问题.该线程应提供有关如何解决该问题的详细信息.

https://social.msdn.microsoft.com/Forums/vstudio/en-US/56fb78b1-efc2-4ff7-aa2c-73c198a790b4/issue- with-landscape-printing-using-printvisual?forum = wpf

此线程可能也对您有帮助.

http://stackoverflow.com/questions/27999769/cannot-print-a-document-with-landscape-orientation-under-windows-8-wpf-net-4


Hi Guys,

I noticed a difference between printing a page in Win10 than previous versions.

Executing this code in Win7, no matter which is greater (if Width or Height), just setting landscape property is enough to make printer print in landscape orientation.

Executing the same code in Win10, I need to define always width greater than height. If not it’s printed as portrait.

Is that a normal behavior? I mean, are you taking decisions on paper orientation based on width/height?

This is the code I’m using:

            var w = 793.92;
            var h = 1122.24;

            var fixedDocument = new FixedDocument();
            fixedDocument.DocumentPaginator.PageSize = new Size(w, h);
            
            var page = new PageContent();
            var fixedPage = new FixedPage { Width = w, Height = h };

            var text = new TextBlock()
                {
                    FontSize = 12,
                    Text = "This should be landscape. W: " + w + " H: " + h,
                };

            FixedPage.SetLeft(text, 100);
            FixedPage.SetTop(text, 100);

            fixedPage.Children.Add(text);
            page.Child = fixedPage;
            fixedDocument.Pages.Add(page);
            var paginator = fixedDocument.DocumentPaginator;
            
            PrintDialog dialog = new PrintDialog();
            if (dialog.ShowDialog() == true)
            {
                dialog.PrintTicket.PageOrientation = System.Printing.PageOrientation.Landscape;

                var sizes = dialog.PrintQueue.GetPrintCapabilities().PageMediaSizeCapability;
                
                foreach (var s in sizes)
	            {
                    if (s.PageMediaSizeName.HasValue && s.PageMediaSizeName == PageMediaSizeName.ISOA4)
                    {
                        dialog.PrintTicket.PageMediaSize = s;
                    }
	            }

                dialog.PrintDocument(paginator, "Test");
            }

解决方案

Hi Andrés,

This is a known issue around landscape. This thread should be provide details on how to address it.

https://social.msdn.microsoft.com/Forums/vstudio/en-US/56fb78b1-efc2-4ff7-aa2c-73c198a790b4/issue-with-landscape-printing-using-printvisual?forum=wpf

This thread might be also helpful to you.

http://stackoverflow.com/questions/27999769/cannot-print-a-document-with-landscape-orientation-under-windows-8-wpf-net-4


这篇关于横向打印时win10和以前版本之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆