How to print a partially transparent image in a PDF canvas using Delphi?

My program should output a (fairly complex) form to the printer, including several images. Im currently doing this with Delphi (2006) s Printer.Canvas, after choosing a PDF printer (PDF995). It works as a pleasure.

However, Im now faces a problem: this is one partially transparent image that needs to be placed on top of other elements (borders, background, etc.), and parts of this text are still visible through parts of the image.

Doing this on a regular screen Canvasworks fine with regular TBitmaps using the property TransparentColor. However, when I try to do this on a printer, it does not always work; and when I try to do this on a PDF printer, it never works: the background turns black or (the best result so far) turns white, but still overwrites anything underneath.

Ive tried to achieve the same result by inserting a PNG image with alpha transparency (aka translucency) into a Word document, and then sending it to the specified PDF printer. The translucency disappears, but the transparency of the pixels remains. So at least it should be somehow possible.

Does anyone know how?

+3
source share
4 answers

You mentioned that you use the TransparentColor property, so is it correct to say that you do not need alpha transparency and you can avoid using binary transparency (transparency for each pixel is disabled or enabled)?

If so, it may be possible to create a Region from your bitmap.

Then you use this area as the clipping area and draw a bitmap.

The PDF printer can correctly handle the clipping region.

Here's an example of creating an area from a bitmap, it is used to create non-rectangular shapes, but the idea is the same: http://www.delphi-central.com/BitmapShapedForm.aspx

TCanvas: http://www.efg2.com/Lab/OtherProjects/PrinterDemo2.htm

+2

, PDF-. , VisPDF. , pdf, . , . - .

0

. , , , , , , , .

0

, PDF canvas PDF. (RTF, Radioemtric JPEG, Tables, Text ..) , . . , llPDFLib, , , .

. - .

0

Source: https://habr.com/ru/post/1709366/


All Articles