Get property for PDF

Hi Team,

We have a requirement to get following property from PDF

1. Height of image in points

2. Width of image in points

3. Colorspace used in PDF


Thanking You

Priya Dharshini J P

Hello Priya,

Thanks for contacting support.

In order to get Height, Width and Colorsapce of the image, please check following code snippet and attached output.

Document
document = new Document(dataDir + “gr7-grey.pdf”);

XImage xImage = document.getPages().get_Item(1).getResources().getImages().get_Item(1);

System.out.println("Height=" + xImage.getHeight());

System.out.println("Width=" + xImage.getWidth());

switch (xImage.getColorType()) {

case ColorType.***Grayscale*** :

System.out.println("Grayscale Image");

break;

case ColorType.Rgb :

System.out.println("Colored Image");

break;
}

Furthermore, you may visit following links for more information.

In case of any further assistance, please feel free to contact us.

Best Regards,

Hi asad,


Thank you for the timely reply.

I further have a request, What unit is the height and width of image measured?

Please help me out by measuring in points.

Regards

Priya Dharshini J P

Hi Priya,


Thanks for contacting support.

The page height and width properties use points as the basic unit, where 1 inch = 72 points and 1 cm = 1/2.54 inch = 0.3937 inch = 28.3 points. Whereas when dealing with images, the conversion from point to pixel depends on an image’s DPI (dots per inch) property. For example, if an image’s DPI is 96 (96 pixels for each inch), and it is 100 points high, its height in pixels is (100 / 72) * 96 = 133.3. The general formula is: pixels = ( points / 72 ) * DPI.

Hi team,


My request is in what unit are the values of height and width measured here?

If not measured in points, please make it measured in points as we require it soon.

Regards

Priya Dharshini J P

Hello Priya,


Thanks for contacting support.

The measurement unit is Point. In case you encounter any issue, please share the input document, so that we can further investigate the scenario in our environment.