In the comments, I claimed that your original image does have a border. You claim it doesn't have a border. Now that you've shared the image, we can check the facts to see who is right.
As it turns out, I was right. When I open the image in GIMP, I clearly see a transparent border:
Maybe you don't see it, because you are looking at the image in Paint or maybe you consider "transparent" and "white" to be the same color. Obviously that assumption is wrong.
I created a PDF containing the image you shared and when I open this PDF using iText RUPS, I see something like this:
PNG is not supported in ISO-32000-1 (aka the PDF specification), hence software that wants to introduce a PNG into a PDF file needs to convert that PNG to another format. In the case of iText, "normal" PNGs are converted to a bitmap with filter /FlateDecode
.
In your case, you have a PNG with tranparency. In ISO-32000-1, transparent images are always stored as two images: you have the opaque image (in my screen shot, /Img1
with object number 2) and the image mask (in my screen shot, /Img0
with object number 1).
If you look closely at the image mask (the image that makes the opaque image transparent), you see that it's a black and white image that shows a very small border. This image is shown in the lower-right panel where it says "Stream" (this is where the image stream is rendered). This very small border is the transparent border we can also see in the GIMP (or other image viewers that support transparent images).
If this border is transparent, then why do you see it in a PDF viewer? Well, this border is treated as a line with zero width. In PDF viewers, a line with zero width is shown using the smallest width that can be shown on the device that is being used to view the PDF. If you zoom into the PDF, you'll notice that the width of the line remains constant.
Summarized: you claimed that your image didn't have any border, and that a border was added by iText. I have proven you wrong: the image does have a transparent border and iText correctly introduces this transparent border as a mask. The PDF viewer shows this border as a zero-width line in accordance with ISO-32000-1.
You can solve your problem by removing the transparent border in the original image. For example: I flattened the image using the GIMP. The result is this image:
This image no longer has a transparent border and when you introduce it into a PDF, no border is shown, and no mask is added to the PDF: