- Posts: 2
- Thank you received: 0
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Android development and PDF
Extract small part of vector PDF as bitmap
9 years 9 months ago #10763
by dsommer
Extract small part of vector PDF as bitmap was created by dsommer
Hi,
we are trying to create a Bitmap from a very small part of a vector PDF in a high resolution like this:
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?
we are trying to create a Bitmap from a very small part of a vector PDF in a high resolution like this:
Code:
@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();
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?
9 years 9 months ago #10768
by radaee
Replied by radaee on topic Extract small part of vector PDF as bitmap
sorry, what your mean quality?
is there pixels offset or others?
is there pixels offset or others?
9 years 9 months ago #10772
by dsommer
Replied by dsommer on topic Extract small part of vector PDF as bitmap
Hey,
I mean that the size of the bitmap is very small, so if I scale it up it becomes very blurry.
I wonder how to properly set the size of the resulting bitmap.
Thanks,
David
I mean that the size of the bitmap is very small, so if I scale it up it becomes very blurry.
I wonder how to properly set the size of the resulting bitmap.
Thanks,
David
9 years 9 months ago #10775
by Davide
Replied by Davide on topic Extract small part of vector PDF as bitmap
Hi,
to make the bitmap bigger you have to increase Bitmap width and height, something like that:
Let me know if it's what you are looking for..
to make the bitmap bigger you have to increase Bitmap width and height, something like that:
Code:
Bitmap bitmap = Bitmap.createBitmap(width + 100, height + 100, Bitmap.Config.ARGB_8888);
Let me know if it's what you are looking for..
Time to create page: 0.402 seconds