print XPS from memory stream

1.1k views Asked by At

I use c# I need to print DOCX, I send the docx to server , convert it to XPS and return XPS as memory stream. convert docx by aspose. At client I use next code:

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();

It work excellent with english, but I print documents with hebrew and arabic too. And in hebrew and arabic order of words is correct, but print every word vice versa. If I write memory stream on disk as XPS and open it , the text is correct.

0

There are 0 answers