views:

3103

answers:

4

I have XPS documents being generated from XAML User Controls that act as templates. I want to convert the XPS documents into alternative formats, mainly PDF, programmatically with a .NET based API.

What is the best way to do this?

+1  A: 

The way I have done this in the past is print my XPS file to a PDF printer. I use cutePDF for this. So when you select to print, you print to cutePDF which prints a PDF version.

I am not sure if this will meet your needs but it has worked well for me in the past.

northpole
I am looking for a way to do this programmatically using a .NET based API.
markti
For those of us that needed a file conversion tool, thanks!
Shannon Nelson
+1  A: 

After much searching, I found this SDK:

NiXPS

Its kindof expensive but works wonderfully. Goodbye fop!

markti
+2  A: 

You can also use ABCpdf PDF Component for .NET . Version 7 can serve your purpose. see http://www.websupergoo.com/abcpdf-12.htm.

it provides fully funtional trial version unlike NiXPS and almost equally as fast as NiXPS.

Alas, we already purchased NiXPS, but NiXPS trial seemed fully functional aside from the red "TRIAL" that was on all my documents :-)The only technical issue we have with it is when constructing PDFs from a XPS byte[] you need to create a buffer larger than the expected PDF byte[] array you are generating...kind of lame... but you can work around it
markti
Our trial version is indeed fully functional - aside from the trial watermark on output.markti: could you contact our support people about the that buffer issue
nixps
already have, they said they would look into enhancing that operation
markti
A: 

You can use pdftron.PDF.Convert.FromXPS(...) to convert from XPS/XAML/FloawDocument and pdftron.PDF.Convert.ToXPS(...) to convert from PDF to XPS.

As a sample check out Xaml2PDF and Convert samples in PDFTron PDFNet SDK: http://www.pdftron.com/pdfnet/samplecode.html#Xaml2PDF

Nick

Ivan
Forgot to comare PDFTron with the other options. It uses direct conversion (unlike priter direver approach which frequently results in bloated, buggy output). Also PDFNet supports XPS to PDF and vice-versa in a single package, and the conversion quality/relaibility/robustness beats anything else.Nick PDFTron
Ivan