Hi,
we are trying to create a Bitmap from a very small part of a vector PDF in a high resolution like this:
@NonNull
private Bitmap getBitmapForRect(Page page, int widthpa, float heightpa) {
int x = 500;
int y = 700;
Rect rect = new Rect(x, x, y, y);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
Document m_doc = document;
int pageWidth = Math.round(document.GetPageWidth(0));
int pageHeight = Math.round(document.GetPageHeight(0));
float scaleX = (float)pageWidth / (float)m_doc.GetPageWidth(0);
float scaleY = -scaleX;
float originX = -rect.left;
float originY = pageHeight - rect.top;
Matrix matrix = new Matrix(scaleX, scaleY, originX, originY);
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.eraseColor(Color.WHITE);
page.RenderToBmp(bitmap, matrix);
matrix.Destroy();
This works and allows to generate a PDF from a specified area.
However, the size of the resulting Bitmap seems to be determined by the original size of the PDF and the quality is not very good.
Is there any way to extract parts of a Vector PDF in high quality?