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" });

  • 相关阅读:
    LeetCode: 389 Find the Difference(easy)
    LeetCode: 669 Trim a Binary Search Tree(easy)
    C++: 内联函数
    C++: STL迭代器及迭代器失效问题
    LeetCode: 371 Sum of Two Integers(easy)
    etcdctl命令
    Etcd介绍
    docker基础镜像打包
    docker常见问题总结
    更改容器内时区
  • 原文地址:https://www.cnblogs.com/zhiming99/p/14886168.html
Copyright © 2011-2022 走看看