wpf 设置自定义纸张不起作用
Posted zhiming99
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了wpf 设置自定义纸张不起作用相关的知识,希望对你有一定的参考价值。
LocalPrintServer localPrintServer = new LocalPrintServer();
var pqs = localPrintServer.GetPrintQueues();
var xpspq = pqs.FirstOrDefault(p => p.Name == "Microsoft Print to PDF");
var pt = xpspq.DefaultPrintTicket;
var pc = xpspq.GetPrintCapabilities();
//逐份打印
//if (pc.CollationCapability.Contains(Collation.Collated)) pt.Collation = Collation.Collated;
//长边翻转的双面打印
//if (pc.DuplexingCapability.Contains(Duplexing.TwoSidedLongEdge)) pt.Duplexing = Duplexing.TwoSidedLongEdge;
//沿着左边缘进行两次装订
//if (pc.StaplingCapability.Contains(Stapling.StapleDualLeft)) pt.Stapling = Stapling.StapleDualLeft;
//正序倒序
//pt.PageOrder = PageOrder.Standard;
pt.PageMediaSize = new PageMediaSize(100, 100);
//pt.PageOrientation = PageOrientation.ReverseLandscape;
//var result = xpspq.MergeAndValidatePrintTicket(xpspq.UserPrintTicket,pt);
xpspq.DefaultPrintTicket = pt;
//xpspq.Commit();
var xpsdw = PrintQueue.CreateXpsDocumentWriter(xpspq);
var sp = new StackPanel();
sp.Children.Add(new TextBlock() { Text = "1111111111", FontSize = 28 });
sp.Children.Add(new TextBlock() { Text = "2222222222", FontSize = 28 });
//打印窗口中的visual时,PageMediaSize 不起作用,起作用的是window的width和height
//grid.Children.Remove(sp);
xpsdw.WriteAsync(sp, pt);
//grid.Children.Add(sp);
//xpsdw.Write(new TextBlock() { Text = "test xpsdocumentwrite" });
以上是关于wpf 设置自定义纸张不起作用的主要内容,如果未能解决你的问题,请参考以下文章
lodop SET_PRINT_PAGESIZE设置的纸张大小对打印器不起作用
在 WPF 设置中 DragOver 中的 e.Effects 不起作用 - 为啥?