java - Creating PDF document with different page sizes -
i want create pdf document different page sizes. able create document pages of same size. i.e. a4 using htmlworker, pass entire html content input. read same pdf , trying generate response should have different page sizes. response generated has different page sizes...but page content not shown. please suggest missing here.
file tempfile = new file(temppdfname); pdfcontentbyte canvas = finalpdfwriter.getdirectcontent(); pdfreader pdfreader = new pdfreader(new fileinputstream(tempfile)); int totalpages = pdfreader.getnumberofpages(); pdfimportedpage page; (int currentpage = 0 ; currentpage < totalpages ; currentpage++) { page = finalpdfwriter.getimportedpage(pdfreader, currentpage); if (currentpage < 2) { canvas.addtemplate(page, pagesize.a4.width(), pagesize.a4.height()); finalpdfdoc.setpagesize(pagesize.a4); finalpdfdoc.newpage(); } else { canvas.addtemplate(page, pagesize.legal.width(), pagesize.legal.height()); finalpdfdoc.setpagesize(pagesize.legal); finalpdfdoc.newpage(); } } finalpdfdoc.close();
Comments
Post a Comment