Here is sample code to generate a new PDF using the source PDF that is attached. Change the paths as you see fit. If you load the PDF, you will see that the rendered bitmap creates a gray background on top of the PDF, even though it should be blending with white, not black. I've also included the bitmap that was generated in the code as a separate PNG. If you take that PNG, and paste it on top of a white background in something like GIMP, you will see that there is no gray background, as a partially white transparent background on a white background stays white.
// Import the first page from the test document
String inputPath = "/sdcard/DCIM/ImportTest/Alpha_Test_Orig.pdf";
String outputPath = "/sdcard/DCIM/Alpha_Test_Mod.pdf";
new File(outputPath).delete();
Document doc = new Document();
doc.Open(inputPath, "");
Document newDoc = new Document();
newDoc.Create(outputPath);
newDoc.SetCache(mActivity.getCacheDir() + "/" + new File(outputPath).getName() + ".dat");
Document.ImportContext context = newDoc.ImportStart(doc);
newDoc.ImportPage(context, 0, 0);
context.Destroy();
doc.Close();
// Render a bitmap with the word "Test" with a white background
// at 50% transparency
int bpWidth = 300, bpHeight = 300;
Bitmap bitmap = Bitmap.createBitmap(bpWidth, bpHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// Create a transparent background first
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setAlpha(0x80); // 50% transparency
paint.setTextSize(48);
paint.setTextAlign(Paint.Align.CENTER);
paint.setFlags(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
// Render the background
canvas.drawRect(0, 0, bpWidth, bpHeight, paint);
// Render the red text (also at 50% transparency)
paint.setColor(Color.RED);
canvas.drawText("Test", bpWidth / 2, bpHeight / 3, paint);
// Now add the bp to the PDF
Page page = newDoc.GetPage(0);
page.ObjsStart();
float pageHeight = newDoc.GetPageHeight(0);
float left = 100;
float top = pageHeight - 200;
// For simplicity, use bitmap annotation, but could also use PageContent for same result
page.AddAnnotBitmap(bitmap, true, new float[]{left, top - bpHeight, left + bpWidth, top});
newDoc.Save();
newDoc.Close();
Mike