In my app, I'm trying to support the creation of a PDF document where every page is generated from a Bitmap. I have the code working for this, but there are two things that concern me. The first is the amount of time this takes to complete, and the second is the resulting size of the PDF. For example, if I take the ~3.75 MB PDF file that I've attached, render each page to a Bitmap, take that bitmap and put it in a new document I've created, the new document is about 48 MB after it is saved. I believe this may be due to the fact that the original PDF is using 300 dpi grayscale images, but I don't have any tools that can tell me this for certain. Even if I could product grayscale images to use with RadaeePDF, in theory it would be 1/4th the size, or 10 MB, which is still much larger than the original. So, that leads me to the following questions:
1) I'm currently using the same code as PDFTestAct.java to build each page in the document from the bitmap. Is this the best way to do it, or is there a more efficient way I'm unaware of?
2) Is there any way I can detect if a page is using grayscale images?
3_ Is there any way I can create a page using grayscale image data without using an existing grayscale JPEG file? Would I have to build the JPEG data in code and feed that through a byte array? Is there any method in the current api that would allow 1 byte of pixel data per index in the array?
I realize that RadaeePDF supports the ability to merge existing PDF pages, and I plan to leverage this, as I imagine it will be more efficient and will keep the document size smaller. Some of the pages I will create do not come from PDFs, and instead come from Bitmaps I generate, so I need to make sure I'm using the best approach for creating pages from Android Bitmaps.
That code basically matches what I am doing. Is there any way I can easily compress the stream before adding it to the PDF? Or would I have to save out the bitmap as a compressed JPEG first, and then use the NewImageJPEG function? I imagine that would be pretty slow, but if it will significantly reduce the size of the PDF, it's probably worth it.
What about grayscale images? Is there any support for detecting or adding them? Or would I have to take an Android bitmap, convert to grayscale using a filter, then compress that to a JPEG file, and then import that into RadaeePDF?
JavaDocs aren't updated yet as the method is available in 3.5beta releases.
You should look at:
* create an image from JPEG/JPG byte array.<br/>
* supported image color space:<br/>
* a premium license is needed for this method.
* @param data byte array include whole jpg file.
* @param len byte length of data.
* @return DocImage object or null.
public DocImage NewImageByMem( byte data, int len )
long ret = newImageJPEGByArray(hand_val, data, len);
if( ret != 0 )
DocImage img = new DocImage();
img.hand = ret;
else return null;