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

Images not Displaying in Adobe Reader
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1033
Page 1 of 1

Author:  tigger17 [ Mon Jan 25, 2010 2:34 pm ]
Post subject:  Images not Displaying in Adobe Reader

Hi there

I am using PdfSharp 1.31 to convert an xps file to pdf in a WPF application.
The pdf renders perfectly after conversion the only problem is that the image in the xps file are not displayed in Adobe Reader.
I opened up the pdf in another reader (foxit pdf reader) and the images and the pdf displays perfectly.

Why are my images not displaying in Adobe reader but it displayes in other pdf readers?

Thanks
A.

Author:  JEllenden [ Fri Mar 26, 2010 9:28 am ]
Post subject:  Re: Images not Displaying in Adobe Reader

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.

Author:  jespa007 [ Tue Dec 11, 2018 1:13 pm ]
Post subject:  Re: Images not Displaying in Adobe Reader

JEllenden wrote:
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.


JEllenden! I have registered here to say thank you to share the solution of this issue. I was about to be crazy... I supposed that the problem was by the adobe reader.

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