PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

XpsConverter no image in PDF
https://forum.pdfsharp.net/viewtopic.php?f=2&t=467
Page 1 of 1

Author:  MiracleMike [ Fri Sep 05, 2008 1:25 pm ]
Post subject:  XpsConverter no image in PDF

I'm using XpsConverter.

Everything from the original XPS file are converted but the images never appear.

This problem is my only show-stopper right now
Thanks for your great library. Exactly what I need.

Author:  JEllenden [ Fri Mar 26, 2010 9:29 am ]
Post subject:  Re: XpsConverter no image in PDF

There appear to be two bugs in the code for the XPS to PDF converter when including images.

The first is that when the image brush is created from the page resources, the opacity defaults to 0.0. If the image brush has no explicit opacity defined it ends up transparent. I've fixed this by a quick and dirty hack! In the method PdfSharp.Xps.Parsing.XpsParser.ParseImageBrush immediately after the brush is created add the line:
brush.Opacity = 1;

The second is that the boundary condition for drawing the brush is incorrect. In method PdfSharp.Xps.Rendering.PdfContentWriter find the section where the ImageBrush case is handled. It sets the opacity by multiplying the opacity of the path by the opacity of the brush. It then performs a bounds check - if (opacity < 1). However, this means that if both the opacity of the path and the brush are 1 the Alpha values on the state aren't set. The bounds check should be if (opacity <= 1).

These two changes make it work for me. Hope it sorts you out too.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/