Extract small part of vector PDF as bitmap - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1

TOPIC: Extract small part of vector PDF as bitmap

Extract small part of vector PDF as bitmap 2 years 9 months ago #10763

  • dsommer
  • dsommer's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0
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?

Please Log in or Create an account to join the conversation.

Extract small part of vector PDF as bitmap 2 years 9 months ago #10768

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 860
  • Karma: 43
  • Thank you received: 13
sorry, what your mean quality?
is there pixels offset or others?

Please Log in or Create an account to join the conversation.

Extract small part of vector PDF as bitmap 2 years 9 months ago #10772

  • dsommer
  • dsommer's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0
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

Please Log in or Create an account to join the conversation.

Extract small part of vector PDF as bitmap 2 years 9 months ago #10775

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Karma: 18
  • Thank you received: 65
Hi,
to make the bitmap bigger you have to increase Bitmap width and height, something like that:
Bitmap bitmap = Bitmap.createBitmap(width + 100, height + 100, Bitmap.Config.ARGB_8888);

Let me know if it's what you are looking for..

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum