zoukankan      html  css  js  c++  java
  • 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 不起作用,起作用的是容器(这里是grid) 的width和height
    //grid.Children.Remove(sp);
    xpsdw.WriteAsync(sp, pt);
    //grid.Children.Add(sp);
    //xpsdw.Write(new TextBlock() { Text = "test xpsdocumentwrite" });

  • 相关阅读:
    HOWTO re
    数据类型
    字符串
    最大公约数
    this
    tip 2:找最小公倍数之Boost
    tip 1:一个简单的将int型转换成char的方法
    Item47
    成员函数模板
    item44:将与参数无关的代码抽离template
  • 原文地址:https://www.cnblogs.com/zhiming99/p/14886168.html
Copyright © 2011-2022 走看看