wpf - How to convert every page in a XPS file to an image in C#? -


Is there any way to convert every image into an XPS document using C #?

This is what I did in this blog post.

On searching the net, there are several paid / test programs that claim to do so (I have not tried any of them, so I I can not assure anyone / list) I think you want to write your own code.

Here is the 'meat' of the blog post:

  Ury Uri = new URI (string.format ("memorystream: // {0}", " File.xps ")); Fixed Document Succession Seek; Using the following methods (XpsDocument xps = New XpsDocument (pack, packaged, packaged, packaged) Normal, uri.ToString)) {Seq = xps.GetFixedDocumentSequence (); } Document Designer Pageviews = seq.DocumentPaginator; Visual visual = Pageitator.gatepage (0). Visual; // First Page - Loop for all Framework Element Fe = (Framework Element) view; RenderTargetBitmap bmp = New RenderTargetBitmap ((int) fe.ActualWidth, (int) fe.ActualHeight, 96d, 96d, PixelFormats.Default); Bmp.Render (fe); PngBitmapEncoder png = New PngBitmapEncoder (); Png.Frames.Add (BitmapFrame.Create (BMP)); (Stream stream = file. Create ("file page")) {png.Save (stream); } Public static IDisposable StorePackage (Uri uri, package package) {PackageStore.AddPackage (uri, package); Return new Disposer ((=) Package Store. Remove Package (Yuri)); }  

Comments