Image Opacity in PdfSharp.NET

Deadly 提交于 2019-12-10 10:43:46

问题


I'm using PDFSharp.NET library to watermark a list of PDFs file. Everything works fine, the website has a lot of samples.

http://www.pdfsharp.net/wiki/Graphics-sample.ashx

The last thing I need is to add the Company Logo, which is big, in the middle of the PDF Page.

I can use a PNG, so that areas which are set as transparent do not "cover" the PDF page".

The pdf is not generated using PDFSharp, but is an "Image" PDF.

For this reason, what I need, is, in addition to the transparency, which works, be able some how to set the Image Opacity!

The code to place the image is this one:

XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append);
XImage image = XImage.FromFile(mypath);
gfx.DrawImage(image, pwidth/2-image.PixelWidth/2, pheight/2 image.PixelHeight/2);
gfx.Dispose();

Anyone has already faced with that?


回答1:


I don't know how to alter the opacity of an image while drawing it using PDFsharp (and I'm afraid this can't be done).

So instead I would just open the logo (PNG) with an image processor and set the opacity there.



来源:https://stackoverflow.com/questions/16451008/image-opacity-in-pdfsharp-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!