本文介绍了如何使用Print Ticket创建新的xps文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将打印票据附加到现有的xps文件中,但我不知道如何将其序列化为新的xps文件;

XpsDocument doc = new XpsDocument(" C:\\input.xps",FileAccess.ReadWrite);
XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);

PrintTicket pt = new PrintTicket();
pt.OutputColor = OutputColor.Grayscale;
//这里必须是使用pt Print Ticket保存文件的代码

I want to attach a Print Ticket to the existing xps-file, but I don't know how to serialize it to the new xps-file;

XpsDocument doc = new XpsDocument("C:\\input.xps", FileAccess.ReadWrite);
                XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);

                PrintTicket pt = new PrintTicket();
                pt.OutputColor = OutputColor.Grayscale;
                // Here must be code to save the file with pt Print Ticket

推荐答案

using (XpsDocument doc = new XpsDocument("C:\\temp\\input.xps", FileAccess.ReadWrite))
{
  using (Package container = Package.Open("C:\\temp\\outputPT.xps", FileMode.Create))
  {
    using (XpsDocument xpsDoc = new XpsDocument(container))
    {
      XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);
      PrintTicket pt = new PrintTicket();
      pt.OutputColor = OutputColor.Grayscale;

      xpsWriter.Write(doc.GetFixedDocumentSequence(), pt);
    }
  }
}



希望这有点帮助......

hope this helps a bit...


这篇关于如何使用Print Ticket创建新的xps文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 10:10