Inserting picture with transparency in pdf with MBSDynaPDF

I can’t recall how to do this. I have a logo.png image that I want to insert into a pdf. It keeps drawing it with a black background in the pdf, even though the image does have an alpha channel and has a transparent background.

What am I forgetting to do?

first setup somewhere the general image parameters:

call p.SetJPEGQuality(70)
call p.SetResolution(300)
call p.SetUseTransparency(false)
call p.SetCompressionFilter(p.kcfJPEG)

and than insert it as file or buffer.

call p.InsertImageEx(x, y, Width, 0.0, File, Index)

[quote=254079:@Christian Schmitz]first setup somewhere the general image parameters:

call p.SetJPEGQuality(70)
call p.SetResolution(300)
call p.SetUseTransparency(false)
call p.SetCompressionFilter(p.kcfJPEG)

and than insert it as file or buffer.

call p.InsertImageEx(x, y, Width, 0.0, File, Index)[/quote]

That didn’t do it. I thought I had this figured out before.
Do those instructions you provided work with “png” files - since is looks like they are oriented for JPEG?

Well, the PNG will be compressed.
Maybe you should ask for Flate compression: SetCompressionFilter(p.kcfFlate)

Normally we use SetSaveNewImageFormat(false), so JPEGs are passed through if possible.
But others with to high resolution (we set limit 300 normally) or otherwise not passing through are compressed. For that you can set the parameters.
SetUseTransparency disables using transparent color.

This works already here:

[code] dim ff as FolderItem = SpecialFolder.Desktop.Child(“IMAG0003.png”)
dim p as Picture = picture.Open(ff)

call d.InsertPicture(p, x, y, w, h)[/code]

with image file also:

call d.InsertImageEx(x, y, w, h, ff)

and just with this setting:
call d.SetSaveNewImageFormat(false)

This isn’t working here.

[code]Dim pf As FolderItem = appDirectoryClassic.Child(“logo48.png”)
Dim p As Picture
p=pf.OpenAsPicture

call pdf.setJPEGQuality(70)
call pdf.SetResolution(300)
call pdf.SetUseTransparency(false)
call pdf.SetCompressionFilter(pdf.kcfFlate)
call pdf.SetSaveNewImageFormat(false)
call pdf.InsertPicture(p,18, 18, 32, 32)[/code]

My picture is generated from Adobe Illustrator - Save for Web, with transparent background.

Tried this (below) as well - still getting black background. Is there some document set up for the pdf that I may not be doing correctly?

  Dim pf As FolderItem = appDirectoryClassic.Child("logo48.png")
  Dim p As Picture
  p=pf.OpenAsPicture

  call pdf.SetSaveNewImageFormat(false)
  call pdf.InsertPicture(p,18, 18, 32, 32)

I noticed I am doing this with a jpg in another program - I will generate a jpg and give that a shot…

OK - it works with .jpg - so that is ok for now - but only because I am printing on a white page.

Let me know if you can think of a reason why my png from Illustrator doesn’t work the same.
Thanks.

maybe you email me example and image file?
Could be DynaPDF has a bug for some special PNG.

Sent - Thanks.

[code] dim folder as FolderItem = GetFolderItem("").Parent

Dim f1 As FolderItem = folder.child(“arrow_down.png”)
Dim f2 As FolderItem = folder.child(“bug.png”)
Dim f3 As FolderItem = folder.child(“TT32.png”)
Dim f4 As FolderItem = folder.child(“TT32hires.jpg”)

call pdf.SetCompressionFilter(pdf.kcfFlate)
call pdf.SetSaveNewImageFormat(False)
call pdf.SetUseTransparency(false) // definitely required
call pdf.SetResolution(300) // no effect?

call pdf.InsertImageEx(100, 100, 32, 32, f1)
call pdf.InsertImageEx(100, 200, 32, 32, f2)
call pdf.InsertImageEx(200, 100, 32, 32, f3)
call pdf.InsertImageEx(200, 200, 32, 32, f4)[/code]

this inserts all images with pass through if possible.

One problem here is that Picture.Open converts cmyk not well as well as RGB with color spaces.

Thank you!!