C# XPS-使用图像打印文档

C# XPS-使用图像打印文档,c#,wpf,xps,C#,Wpf,Xps,我以前也问过类似的问题,但从那以后,我就不喜欢解决我的问题了。我不是Xps文档方面的专家,但我成功地解决了这个问题 以下示例采用DocumentPaginator参数并简单地打印文档。 第一个示例有效,第二个示例不打印文档中嵌入的图像 // this works XpsDocumentWriter xpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(printQueue); xpsDocumentWriter.Write(documen

我以前也问过类似的问题,但从那以后,我就不喜欢解决我的问题了。我不是Xps文档方面的专家,但我成功地解决了这个问题

以下示例采用
DocumentPaginator
参数并简单地打印文档。 第一个示例有效,第二个示例不打印文档中嵌入的图像

// this works

XpsDocumentWriter xpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(printQueue);
xpsDocumentWriter.Write(document);  // where document is a DocumentPaginator

// this doesn't work (it prints but no images)

// create new doc
XpsDocument doc = new XpsDocument(package, CompressionOption.NotCompressed, "pack://TempTemporaryPackageUri.xps");

// create writer for new doc
XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);

// write document
writer.Write(document, printQueue.DefaultPrintTicket);

// create writer for print job
XpsDocumentWriter xpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(printQueue);

// i think it's here where the resources are being lost 

// write document
xpsDocumentWriter.Write(doc.GetFixedDocumentSequence());
我需要创建新文档的原因是,我需要在XpsDocument分页后对其进行管理

有人能给我指出正确的方向,让我能够将资源从一个文档复制到另一个文档吗

谢谢你的建议

提前感谢,


Sam

您可以尝试下面链接中给出的代码。它正致力于转换成XPS和PDF格式


感谢回复anshul,但我正在尝试从现有文档创建XpsDoc,但在每个页面中添加了一个额外的视觉效果。我没有使用Word或PDF。谢谢,好的。但是在这段代码中,您的需求和示例之间的区别只是将格式更改为wdExportFormatXPS,而且如果您想添加一些数据,只需通过FileStreamer编写您想要的文档文件,然后将其转换。我认为您仍然在走错路。创建分页XPS文档后,请直接修改该文档,而不是尝试复制它。然后如何将XPS文档打印到打印队列中。似乎当我从getfixeddocumentsequence创建一个新文档时,它会丢失资源,或者将它们留在orig文档中。我一定错过了一些简单的东西,这是一个很好的开始。