@josef.auer1,
You are modifying the size of image by calculating the ratio, but still the orientation is not being changed. This is the output image of your code: test.jpg (732.9 KB), and when we saved into the image format without calculating ratio by calling the following code:
[Java]
ByteArrayOutputStream stream = new ByteArrayOutputStream();
converter.getNextImage(stream);
byte[] data = stream.toByteArray();
File file = new File(dataDir + "testwithoutRatio.jpg");
FileUtils.writeByteArrayToFile(file, data);
Image img =Image.load(new ByteArrayInputStream(data));
System.out.println(img.getWidth() + "x" + img.getHeight());
This is the output image: testwithoutRatio.jpg (802.9 KB)
In reference to ticket ID PDFJAVA-37048, please note that the PageInfo properties are being used for PDF generation only. Please, use the code snippet below for existing documents:
[Java]
String dataDir = "C:\\Pdf\\test269\\";
Document document = new Document(dataDir + "Input.pdf");
System.out.println("PageWidth " + document.getPages().get_Item(1).getRect().getWidth() /72 );
System.out.println("PageHeight " + document.getPages().get_Item(1).getRect().getHeight() /72);
if (document.getPages().get_Item(1).getRect().getWidth() > document.getPages().get_Item(1).getRect().getHeight()) {
System.out.println("Landscape");
} else {
System.out.println("Portrait");
}
PS: the linked ticket ID PDFJAVA-37048 has been closed.