I'm trying to create a PDF document with more than 2 pages in portrait and others in landscape, I found that both page and text rotates to landscape I need to prevent page content rotation. am using following code
Document document = new Document(PageSize.A4, 36, 36, 36, 72);
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(outPutDirectory + indexID + ".pdf"));
writer.setPageEvent(new Orientation(orientation));
document.open();
XMLWorkerHelper.getInstance().parseXHtml(writer,document, new ByteArrayInputStream(parserXHtml(page.getPageContent()).getBytes()))
document.close();
my expected result should be like this
Instead of using a page event, you have to change the page size.
For instance:
Be aware of the fact that the page size only changes on the next page. The order of
setPageSize()
andnewPage()
is important.