Getting Image DPI in PDF files using iText

后端 未结 1 1309
轻奢々
轻奢々 2021-01-06 18:14

I \'m trying to get information about scanned images that are saved into PDF files through iText (using Java).

Using the answer and comments, I got width and height

相关标签:
1条回答
  • 2021-01-06 19:03

    Let's split this problem into two separate problems. To calculate the DPI, you need two sets of values: a number of pixels and a distance in inch.

    1. Number of pixels: you obtain the image and the image consists of pixels. You can retrieve the width and height of the image in pixels from the image. Let's say these values are wPx and wPx.
    2. Distance in inch: you obtain the matrix which gives you values expressed in points. As 72 points equal 1 inch, you need to divide these values by 72. Let's say these values are wInch and hInch.

    Now you can calculate the DPI in the x direction like this: wPx / wInch and the DPI in the y direction like this: hPx / hInch.

    0 讨论(0)
提交回复
热议问题