Convert XPS to PDF using C# Streams via Aspose.Page for .NET

Hello

We are interested in using the XPS component but need a conversion to PDF. Now we realized that the conversion function cannot use a Stream, only a Filename is supported. In the .Net environment, Stream is the common file mechanism.

Could you please add this feature in a future release?

Best Regards,
Raphael

@Raphael_Affolter

Thanks for contacting support.

You may use Streams as well in order to convert XPS into PDF. Please consider using following code snippet with Aspose.XPS for .NET 19.2.

// Using Aspose.XPS
Aspose.Xps.XpsDocument doc = new Aspose.Xps.XpsDocument(new FileStream(dataDir + "sample2.xps", FileMode.Open), new Aspose.Xps.XpsLoadOptions());
// Initialize PdfSaveOptions
Aspose.Xps.PdfSaveOptions pdfSaveOptions = new Aspose.Xps.PdfSaveOptions();
// Specify TextCompression Style 
pdfSaveOptions.TextCompression = Aspose.Xps.PdfTextCompression.Flate;
// Save as PDF Document
doc.Save(dataDir + "XPStoPDF_out.pdf", pdfSaveOptions);

In case you need further assistance, please feel free to contact us.

Thanks Ali

I was not clear enough, the saving to PDF should support a Stream instead of a File:

doc.Save(new FileStream(“XPStoPDF_out.pdf”, FileMode.Write), pdfSaveOptions);

Best Regards,
Raphael

@Raphael_Affolter

Thanks for your feedback.

The feature request has been logged as XPSNET-60 in our issue tracking system and associated with this thread as well. We will definitely work to implement the required feature and let you know as soon as additional updates are available regarding its implementation. Please spare us little time.

We are sorry for the inconvenience.