Convert xps documents to a .NET bitmap. Supports both single and multi-paged xps documents.
This code is mostly derived from xps2img@sourceforge by Ivan Ivon.
Install-Package xps2img
- .NET Framework 4.0
- .NET Framework 4.5
- .NET Framework 4.5.1
Convert a xps document to png from disk
using (var xpsConverter = new Xps2Image("multipage.xps"))
{
var images = xpsConverter.ToBitmap(new Parameters
{
ImageType = ImageType.Png,
Dpi = 300
});
}
Convert a xps document to png from a byte array
using (var xpsConverter = new Xps2Image(File.ReadAllBytes("multipage.xps")))
{
var images = xpsConverter.ToBitmap(new Parameters
{
ImageType = ImageType.Png,
Dpi = 300
});
}
Convert a xps document to png from stream
using (var xpsConverter = new Xps2Image(new MemoryStream(File.ReadAllBytes("multipage.xps"))))
{
var images = xpsConverter.ToBitmap(new Parameters
{
ImageType = ImageType.Png,
Dpi = 300
});
}