PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Oct 16, 2019 4:17 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Aug 22, 2018 5:13 am 
Offline

Joined: Wed Aug 22, 2018 5:01 am
Posts: 3
Hello.
So I can't find any example on how to add a partially transparent image to PDF (like a watermark of sort). I know that quite some time ago it was possible (via a bug) to set the opacity with the XBrush value, but sadly it was a bug and even more sadly it is fixed.. There is an example called "Draw a PNG image with transparency", but it does not say on whether it's just the "white background transparent" image or it is with opacity with for example 10% opaque, and more so it uses a comment-less helper method which does much more then I require...

Thanks beforehand! :)

EDIT 1:
Also I am aware that System.Drawing allows to change color matrix for Bitmap image - to be able to draw images with opacity with floating point from 0 to 1... Which as it seems is not supported by PdfSharp.


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 22, 2018 8:06 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2980
Location: Cologne, Germany
Hi!

You can download the source code and search this:
Code:
// The transparency set for a brush also applies to images. Set opacity to 100% so image will be drawn without transparency.
_gfxState.RealizeNonStrokeTransparency(1, _colorMode);


It's a matter of minutes to add a property for the opacity and use that property instead of the value "1" in the second line.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 22, 2018 8:32 am 
Offline

Joined: Wed Aug 22, 2018 5:01 am
Posts: 3
Why is it hard-coded in the first place?

I can't edit the source - as I am using Nugget version of the PdfSharp.. And even if I could - it would be overridden by the first nugget update..


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 22, 2018 8:45 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2980
Location: Cologne, Germany
AssassinLV wrote:
I can't edit the source - as I am using Nugget version of the PdfSharp.. And even if I could - it would be overridden by the first nugget update..
Anybody who can handle Notepad.exe can edit the source.
NuGet won't overwrite anything if you compile the assemblies on your own computer and use them.

I cannot say why the API is as it is.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 332 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