views:

29

answers:

1

How to create xps file from web page using c#? Any ideas?

+1  A: 

Yes, buy a product that does this.

There is no simple conversion. XPS documents are based on WPF controls, not web controls. That means you have to somehow convert the web document into either 1) an image or 2) a valid WPF Visual.

No. 2 is going to be the harder route. Braver souls would use a transform to convert the webpage to xaml, but of course that wouldn't work for any page that uses javascript to render content or one of probably a hundred other limitations. So, unless the webpage is very simple valid xhtml, 2 is right out.

The first option is the easiest, if you don't think about the fact that the web is filthy with people asking how to convert a webpage to an image. But, if you can get past that hurdle, its relatively simple.

The algorithm would be:
1) get the webpage as image (hard bit)
2) create Image control, set ImageSource to the image
3) Create XpsDocument and write the Image to it (as a Visual)

Will
Thank you!!!! That can be a solution.I've tried to use xslt transformation for that purpose...
CSharpered