Title: RE: [iText-questions] questions about change pagesize

PdfCopy only copies, it doesn't change page sizes or content.

Best Regards,
Paulo Soares

    -----Original Message-----
    From:   [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED] On Behalf Of li hongbin

    Sent:   Tuesday, December 30, 2003 2:43
    To:     [EMAIL PROTECTED]
    Subject:        [iText-questions] questions about change pagesize

    hi,
       Now I meet with a question about changing the pagesize as following:
       firstly I use a existing pdf as a template,such as "aaa.pdf",and it's
    pagesize is A4,and i use the template to generate a new pdf "ccc.pdf",which
    include "aaa.pdf" many times,i wish to change the pagesize of the generated
    pdf "ccc.pdf",i used setpagesize() to do that,but it doesn't work well! the
    code is following:
       //////////////////////////////////////////////
    import com.lowagie.text.*;
    import com.lowagie.text.pdf.*;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
    import com.lowagie.text.Rectangle;

    public class test
    {
       public static void main(String args[])
      {  
            PdfCopy  writer1 = null;
            //Document document=new Document(PageSize.A4.rotate());
            Rectangle pageSize = new Rectangle(300, 300);
            Document document = new Document(pageSize);
           
            System.out.println("Beginning generate pdf......");
            try
            {
              String  str[]={"aaaaaa","bbbbb","cccccc","dddddd"};
              writer1 = new PdfCopy(document, new FileOutputStream("ccc.pdf"));
             //writer1.setPageSize(pageSize);
             document.open();
                     for(int i=0;i<str.length;i++)
              {
               PdfReader reader = new PdfReader("aaa.pdf");
               PdfStamper stamp = new PdfStamper(reader, new
    FileOutputStream("bbb.pdf"));
                  AcroFields form = stamp.getAcroFields();
               form.setField("a12",str[i]);
               form.setField("a21",str[i]);
               form.setField("a22",str[i]);
               form.setField("a31",str[i]);
               stamp.setFormFlattening(true);
               stamp.close();      
                  PdfReader reader1 = new PdfReader("bbb.pdf");
               PdfImportedPage page=writer1.getImportedPage(reader1, 1);
               writer1.addPage(page);
                 }
                          
              }
              catch(DocumentException de)
              {
                System.err.println(de.getMessage());
               }
              catch(IOException ioe)
              {
                System.err.println(ioe.getMessage());
               }
             document.close();
            System.out.println("ending generate pdf......");
         }
    }
    //////////////////////////////////////////////////////////////////////////////


    this is the code I have written,but I can't change the pagesize of the
    generated pdf "ccc.pdf",how shoud i do?
    I alse want to change the pagesize of the pdf document after it has
    generate,in other words,i want to change the pagesize of a existing pdf
    document,but i also don't know how to do.Would you  please give me some
    ideas or some example codes!
    thanks for any help!I am looking forward to hearing from you!

    _________________________________________________________________
    与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn 



    -------------------------------------------------------
    This SF.net email is sponsored by: IBM Linux Tutorials.
    Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
    Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
    Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
    _______________________________________________
    iText-questions mailing list
    [EMAIL PROTECTED]
    https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to