2

我使用 c# 我需要打印 DOCX,我将 docx 发送到服务器,将其转换为 XPS 并将 XPS 作为内存流返回。通过 aspose 转换 docx。在客户端,我使用下一个代码:

System.IO.Stream docStream = ...any xps as stream;
Package package = Package.Open(docStream);

//Create URI for Xps Package
//Any Uri will actually be fine here. It acts as a place holder for the
//Uri of the package inside of the PackageStore
string inMemoryPackageName = string.Format("memorystream://{0}.xps",         Guid.NewGuid());
Uri packageUri = new Uri(inMemoryPackageName);

//Add package to PackageStore
PackageStore.AddPackage(packageUri, package);

XpsDocument xpsDoc = new XpsDocument(package, CompressionOption.Maximum, inMemoryPackageName);
FixedDocumentSequence fixedDocumentSequence = xpsDoc.GetFixedDocumentSequence();

PrintDialog dlg = new PrintDialog();
        XpsDocument xpsDoc = new 
        dlg.PrintDocument(fixedDocumentSequence .DocumentPaginator, "Document title");


PackageStore.RemovePackage(packageUri);
xpsDoc.Close();

它适用于英语,但我也用希伯来语和阿拉伯语打印文档。在希伯来语和阿拉伯语中,单词的顺序是正确的,但反之亦然打印每个单词。如果我将内存流作为 XPS 写入磁盘并打开它,则文本是正确的。

4

0 回答 0