Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

How to place image without Background

Question

We are trying to place image on a Certain location using Quick PDF library. But everytime the image is placed there is a black background behind the image.

We also tried using iTextSharp, and was successful in placing the same image in the Pdf page without any background.

Please let me know if Quick PDF is capable of placing of placing image without any background, if yes, please provide a code snippet for the same.

Answer

Quick PDF Library does support transparent images with a few different mechanisms.

The first method is using a color key mask with the functions SetImageMask and SetImageMaskCMYK. These functions add a range of colors to the image (starting RGB and ending RGB or starting CMYK and ending CMYK). When the image is drawn, any colors that are within the range will not be drawn - allowing the background through.

The second method is using the SetImageAsMask function. This works with 1-bit images only. When the image is drawn, all pixels with a value of 0 will be painted using the current fill color and all pixels with a value of 1 will be transparent. This is called a stencil mask.

The third method is using the SetImageAsMask function, this is called a soft mask. First, a grayscale image is added and the ImageID is stored by the programmer. Then, a main image is added and the SetImageAsMask function is called supplying the ImageID of the grayscale image. When the main image is drawn, each pixel will have a transparency value corresponding to the grayscale image's pixel values. For example, if an 8-bit grayscale soft mask image is used, there would be 256 possible transparency values.

Some images like GIF, TIFF and PNG contain an alpha channel directly or other transparency details directly inside the image.

At the moment Quick PDF Library supports reading the alpha channel only from PNG images. The Options parameter in functions like AddImageFromFile allows control over how the alpha channel is read.

If the PNG image contains only a fixed transparency setting rather than an alpha channel that is not yet supported by Quick PDF Library.

And transparent GIF and TIFF images are not yet supported either.


© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum