Open GoogleCodeExporter opened 9 years ago
One important requirement in above is to be able to specify different page size
and margin for each page from Java code.
e.g. Page 1: size=A5, Margin=100,100,100,100 and Page 2: size=A3,
Margin=150,50,50,200
Updated code for MyPDFPageEvents
public class MyPDFPageEvents extends PdfPageEventHelper {
...//not all methods are listed here
public void onStartPage(PdfWriter writer, Document document) {
Rectangle pageSize = PageSize.A4;
float ml = 50, mr = 50, mt = 50, mb = 50;
int pageNo = document.getPageNumber() % 5;
switch (pageNo) {
case 1:
pageSize = PageSize.A4;
ml = 200;
mr = 100;
mt = 200;
mb = 100;
break;
case 2:
pageSize = PageSize.A4;
pageSize = pageSize.rotate();// portrait to landscape
ml = 250;
mr = 250;
mt = 50;
mb = 50;
break;
case 3:
...// more page configurations...
break;
...// more page configurations...
default:
pageSize = PageSize.A4;
ml = 50;
mr = 50;
mt = 50;
mb = 50;
}
document.setPageSize(pageSize);
document.setMargins(ml, mr, mt, mb);
}
...
}
Original comment by j4jite...@gmail.com
on 10 Mar 2015 at 8:09
I do have the same issue. Did you find a solution for the problem?
Hi there! Any news here about this problem? I'm running the same situation, I reproduced the MyPDFPageEvents code and had no effect on my margins. Is there another approach to set my margins and pageSizes up?
Original issue reported on code.google.com by
j4jite...@gmail.com
on 10 Mar 2015 at 7:14