You are on page 1of 2

Save edited pdf Page in A4 size using itext - Stack Overflow

http://stackoverflow.co /!uestions/"#$%"&"/save-edite...

sign up

log in

tour

help

careers 2.0

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Save edited pdf Page in A4 size using itext

I need to edit a specific page from a PDF file and I have to save that page only as a separate PDF file. I have successfully completed the job. The input file is of letter size pages. But now what I need is to save the edited page in A4 size. Can anyone help me. I am waiting for the responses. Following is my code. import java.awt.Color; import java.io.FileOutputStream; import java.io.IOException; import import import import import import import import import import com.lowagie.text.Chunk; com.lowagie.text.Document; com.lowagie.text.DocumentException; com.lowagie.text.Element; com.lowagie.text.Font; com.lowagie.text.Paragraph; com.lowagie.text.pdf.ColumnText; com.lowagie.text.pdf.PdfContentByte; com.lowagie.text.pdf.PdfReader; com.lowagie.text.pdf.PdfStamper; pdfEdit { tatic tatic tatic tatic tatic String INPUTFILE = "./pdf/e g.pdf"; String !UTPUTFILE = "./pdf/o"tp"t.pdf"; String foote#$ig%t = "&e' co te t a d (e#vice("; String foote#Left = ")ll $igt%( $e(e#ved"; Document doc"me t; IOException. DocumentException {

public cla pri!ate pri!ate pri!ate pri!ate pri!ate public

tatic !oid mai *String+, a#g(- thro"

doc"me t = ne" Document*-; doc"me t.ope *-; PdfReader #eade# = ne" PdfReader*INPUTFILE-; PdfStamper (tampe# = ne" PdfStamper*#eade#. ne" FileOutputStream*!UTPUTFILE--; int editi gPage = /;

pdf

itext

page-size

edited Oct 11 '12 at 20:41 Charles 31.4k 9 43 72 Hi friends.. Please help me. 1355 Oct 20 '11 at 6:07 still I expect a reply 1355 Oct 20 '11 at 12:21

asked Oct 20 '11 at 5:57 1355 726 5 23 50

% of '

'/%#/'&%4 #:'( P)

Save edited pdf Page in A4 size using itext - Stack Overflow

http://stackoverflow.co /!uestions/"#$%"&"/save-edite...

2 Answers
try: #eade#.getPageN*I tege#.to0t#i g*editi gPage--.p"t*PdfName.1E2I)3!4. Pdf$ecta gle*567.897--; ew

answered Oct 20 '11 at 13:22 Jasper Duizendstra 1,382 5 17 Very thanks for your response. But it is not working 1355 Oct 21 '11 at 4:54 Can you be more specific? do you get an error? Jasper Duizendstra Oct 21 '11 at 7:42 No error. But pdf was not created 1355 Oct 24 '11 at 4:54

pri!ate

tatic !oid c#eateP2FFile*- thro" File#otFoundException { OutputStream o"tp"t0t#eam = ne" FileOutputStream*"./)90i:ePdf.pdf"-; Document doc"me t = ne" Document*PageSi$e.)9. 9;. 9;. 9;. 9;-; try { Pdf%riter w#ite# = Pdf%riter.getI (ta ce*doc"me t. o"tp"t0t#eam-; PdfReader #eade# = ne" PdfReader*./InputPdf.pdf-; #eade#.(et<iewe#P#efe#e ce(*editedPageNo-; PdfImportedPage page = w#ite#.getImpo#tedPage*#eade#. 6-; doc"me t.ope *-; PdfContentByte c' = w#ite#.get2i#ect=o te t*-; c'.addTemplate*page. 6.9f. ;. ;. 6.6>f. ?6/. @-; doc"me t.clo(e*-; o"tp"t0t#eam.clo(e*-; (etFoote#*-; A catch *Exception e- { e.p#i t0tacBT#ace*-; A finally { if *doc"me t.i(!pe *-doc"me t.clo(e*-; try { if *o"tp"t0t#eam C= nullo"tp"t0t#eam.clo(e*-; A catch *IOException ioe- { ioe.p#i t0tacBT#ace*-; A A

A
edited Oct 24 '11 at 5:01 answered Oct 24 '11 at 4:55 1355 726 5 23 50

Not the answer you're looking for? Browse other uestions tagged pdf itext
page!size or ask your own uestion"

' of '

'/%#/'&%4 #:'( P)

You might also like