How use itext to change existing pdf pagesize? -
i have pdf, beyond current page, there content not being displayed. want change pagesize of content can displayed. there way itext?
public pdfreader changepdfpagesize(string inpdf,string outpdf,float vertical,float horizontal) { try { pdfreader reader = new pdfreader(inpdf); pdfstamper stamper = new pdfstamper(reader, new fileoutputstream(outpdf)); (int curpagenum = 1; curpagenum <= reader.getnumberofpages(); ++curpagenum) { pdfdictionary pagedict = reader.getpagen(curpagenum); pdfarray mediabox = pagedict.getasarray(pdfname.mediabox); mediabox.set(0, new pdfnumber(mediabox.getasnumber(0).intvalue()-horizontal));//left add mediabox.set(1, new pdfnumber(mediabox.getasnumber(1).intvalue()-vertical));//down mediabox.set(2, new pdfnumber(mediabox.getasnumber(2).intvalue()+horizontal));//right mediabox.set(3, new pdfnumber(mediabox.getasnumber(3).intvalue()+vertical));//up } stamper.close(); return new pdfreader(outpdf); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (documentexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } return null; }
Comments
Post a Comment