PDF Rasterizer does not keep transparency

Hi, I am using PDFNet to open a pdf and the rasterize it to allow zooming. However, it does not keep the original transparency of the pdf. It draws the background white instead.
Here is my code:

PDFDoc pdfDoc = pdfSecurity.unlock(path);
Page page = getPdf({path}).getPage(1);
mRasterizer.rasterize(page, mPixels, WIDTH, HEIGHT, true, matrix, rect);

Every pixel returned by rasterizer is opaque, although the original PDF is transparent, and I haven’t found any method in PDFDoc, Page or PDFRasterizer to keep transparency.

Thank you very much.

Currently there is not a way to do this through the PDFRasterizer class, but there is through the PDFDraw class. Unless you need arbitrary rotations, the PDFDraw class is usually sufficient for users.

For PDFDraw use PDFDraw.setPageTransparent

I am trying to use pdfDraw using the following code:

PDFDraw pdfDraw = new PDFDraw();
pdfDraw.setPageTransparent(true);
myPdf.getPage().setCropBox(myPdf.getRectTRON());
Bitmap bitmap = pdfDraw.getBitmap(myPdf.getPage());

(myPdf is the object that keeps the information of the pdf that I am trying to draw)

But, in this case, it is not cropping / scaling my pdf correctly. The cropbox size is 10241024 but the returned bitmap is 13081308
El martes, 21 de marzo de 2017, 0:35:11 (UTC+1), Ryan escribió:

Currently there is not a way to do this through the PDFRasterizer class, but there is through the PDFDraw class. Unless you need arbitrary rotations, the PDFDraw class is usually sufficient for users.

For PDFDraw use PDFDraw.setPageTransparent

The actual size of the image generated depends on whether you are running in DPI mode (default), or you explicitly set a size, using PDFDraw.SetImageSize.

SetImageSize is the preferred way, as if you set the DPI to a high value, and happen to rasterize a PDF page that has large dimensions, say an engineering/architecture drawing, you can end up with very large memory consumption and a very large image output.

If you do use DPI, then PDF are in 1/72 scale. A default PDF page is 612, 792, which is 8.5"x11". So PDFDraw.SetDPI(300) would result in a image that is 2550x3300 pixels, or ~8MP.