Creation of PTImage in iOS SDK from file path

Hi Aaron or anybody else.

I’m in the process of evaluation the SDK.

I have an issue when trying to stamp an image annotation onto a PDF document.

The image is a PNG with transparency.

I’m trying to do something like this:

PTImage* ptIm = [PTImage Create:[[m_pdfViewCtrl GetDoc] GetSDFDoc] filename:docsImagePath];

but have also tried just getting the image path from the bundle (without copying it into the documents directory.

Both doc directory and straight from the bundle work in the simulator, but when I try to run it on an iPad device, I get the following error from the SDK:

RioRailMap[1890:60b] File copied train.png after delete OK

libpng error: CgBI: unhandled critical chunk

If you could let me know how I might resolve this error that would be most appreciated!

(Note, I did try creating the PTImage from a UIImage but that caused the transparent background to be black and I wasn’t sure how to resolve that).

Thanks in advance,


Please make sure you’ve turned off PNG compression in your project’s settings, or Xcode will convert the PNG to a non-standard “PNG” that does not adhere to the specification (and hence cannot be processed by PDFNet). See here for details.

Note that calling Image.Create with a file path (as in the AddImage sample), instead of a UIImage, will create this soft mask.

Finally, the following post may be relevant:
Regarding the black background, this is because PDF does not directly support PNG or any other image format that supports transparency. Transparency in PDF is achieved through soft masks.