The annotation is saved properly when using saving the document using Document_save(), however if I use Document_saveAs() the app crashes the next time the pdf is opened.
The steps I use to reproduce the issue are the following:
1. Open the original PDF file.
2. Save the a copy of the PDF file to another path.
3. Close the original PDF.
4. Open the created PDF for editing.
4. Add a bitmap annotation using the code mentioned earlier.
5. Save a copy of the created PDF file to another path.
6. Open the second copy, the app crashes.
Here are the original and generated PDFs and the crash log I'm getting when I try to open the generated PDF.
Thank you emanuele, I can confirm it is not crashing anymore. However when I add a bitmap annotation on the saved pdf the first one does not contain alpha. If I add more than one the rest hast the alpha channel set correctly.