问题描述
我想将打印票据附加到现有的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文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!