PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 9:50 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jan 25, 2010 2:34 pm 
Offline

Joined: Mon Jan 25, 2010 2:25 pm
Posts: 1
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 26, 2010 9:28 am 
Offline

Joined: Fri Mar 26, 2010 9:17 am
Posts: 4
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.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 11, 2018 1:13 pm 
Offline

Joined: Tue Dec 11, 2018 1:09 pm
Posts: 1
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 138 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group