Hello,
Using jar: aspose-pdf-25.2-jdk17.jar
I don’t know why this is happening, but no matter what I do and what PDF document I open, the value I receive for isLandscape() is always “false”, even in cases where it is a true.
What am I doing wrong?
Here is my code:
import com.aspose.pdf.*;
import java.io.File;
public class IsLandscapeProblem {
public static void main(String[] args) {
System.out.println("Starting");
try {
File[] inputFiles = {
new File("test_width.pdf"),
};
for (File file : inputFiles) {
System.out.println("opening: " + file.getName());
String inputFile = file.getAbsolutePath();
Document doc = null;
try {
doc = new Document(inputFile);
} catch (Exception e) {
System.out.println("Error opening document: " + e.getMessage());
continue;
}
Page page = doc.getPages().get_Item(1);
double pageWidth = page.getPageInfo().getWidth();
double pageHeight = page.getPageInfo().getHeight();
boolean isLandscape = page.getPageInfo().isLandscape();
System.out.println("pageWidth: " + pageWidth + " pageHeight: " + pageHeight + " isLandscape: " + isLandscape);
doc.close();
}
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
System.out.println("Done.");
}
}
And it generates the following output:
Starting
opening: test_width.pdf
pageWidth: 595.0 pageHeight: 842.0 isLandscape: false
Done.
Attached is the PDF file. This is a landscape document.
Thanks a lot,
Sharon
test_width.pdf (8.3 KB)