Arshad Rehmani
Arshad Rehmani

Reputation: 2185

Create PDPage with right format using PDFBox

I'm trying to write a simple method that creates a new PDDocument and adds PDPage with the right page format as supplied by user inputs.

Input from User can be one of the following:

"A4-Portrait"
"A4-Landscape"
"A3-Portrait"
"A3-Landscape"

Expected output: If input is "A3-Landscape" , return PDPage with this format.

while I can see ways to create PDPage in A3 format using

PDPage page = new PDPage(PDRectangle.A3);

Can you help how efficiently and easily can I choose the right format and its orienatation dynamically?

Upvotes: 0

Views: 585

Answers (1)

Tilman Hausherr
Tilman Hausherr

Reputation: 18851

You can do it like this:

PDRectangle A4L = new PDRectangle(PDRectangle.A4.getHeight(), PDRectangle.A4.getWidth());

Upvotes: 1

Related Questions