0

我有一个处理打印功能的 wpf 应用程序,用于将多个 xps 文档合并为单个文档。工作时触发错误为“无法在只写模式下执行读取操作”。

我从内存流中加载数据

xpsDoc = new XpsDocument(pack, CompressionOption.SuperFast, inMemPackageName);

并且我使用了合并参考

FixedDocumentSequence sourceSequence = doc.GetFixedDocumentSequence();



foreach (DocumentReference dr in sourceSequence.References)                                             
{

    DocumentReference newDocumentReference = new DocumentReference();
    newDocumentReference.Source = dr.Source;
    (newDocumentReference as IUriContext).BaseUri = (dr as IUriContext).BaseUri;
    FixedDocument fd = newDocumentReference.GetDocument(true);
    newDocumentReference.SetDocument(fd);                                                seqNew.References.Add(newDocumentReference);
}

然后我用这个代码打印

XpsDocumentWriterwriter=PrintQueue.CreateXpsDocumentWriter(printQueue);                  
DocumentPaginator paginator = seqNew.DocumentPaginator;
if (paginator.PageCount == MassPrintings.Count())
{
   writer.Write(seqNew);
}

请给我一个解决方案

4

0 回答 0