合并XpsDocument进行打印

时间:2014-05-05 11:31:06

标签: wpf xpsdocument

我有一个用于打印功能的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);
}

请建议我解决方案

0 个答案:

没有答案