add opacity to doc.image options#1709
Conversation
|
This change adds an opacity for the whole page. It is not specific for image. Can already be achieved with doc |
|
Sorry, I know it is not technically changing the image and simply layering an opacity layer over it, but I don't think it is doing it to the whole page? In my tests, I have used the png.js: Now, because of where we push that opacity operator on Please let me know if I'm wrong, I very well could be - but from my understanding, this shouldn't be covering the whole page, but just our image. |
|
I actually did not tested. I relied on doOpacity implementation that add the dictionary to page I will reevaluate |
|
Many thanks. I confirmed it works fine |
|
Multumesc, Andrei! :) |
|
No problem my friend! :) Would need to be tested, but probably yes? As far as I'm aware, even though the opacity is set as a layer on top, the PDF document should get rasterised into a bitmap for the printer by the driver, so any opacity should result in lighter pixels and therefore less toner usage. However, some printers also have a minimum toner floor, so savings may not be linear. Especially in laser printers, you cannot really vary the amount of ink per dot so to simulate lightness, it does vary the density of dots across an area. So for example a 10% reduction in opacity would in theory save 10% toner on that area, but in reality you're more likely to see closer to 5% or even less savings due to how the printer ends up halftoning the image. |
Feature
What kind of change does this PR introduce?
This PR introduces an
opacityoption todoc.image()which reuses the existing_doOpacitymechanism (ExtGStatewithcaset to the opacity value).I think this would be helpful in order to control transparency of images on-the-fly, for example #837 wanted to add a watermark and one of the best options is to simply add an image directly on the page, but you would need the image with the alpha channel already set. With this, you could just have your watermark (e.g. could be your company's logo that you already use on your website) and chuck it into the middle of the page and make it transparent with ease.
Checklist: