Hi,
I am using following piece of code to regenerate the pdf.
one.pdf is the pdf that is read.
two.pdf is the pdf that is regenerated using iText.
one.pdf when viewed in Acrobat Reader ver.7.0 is a landscape size of 11.69*8.26
two.pdf when viewed in same Acrobat Reader ver.7.0 is a portrait size of 8.26*11.69
These sizes are seen from the document properties of the Acrobat Reader 7.0
The iText version that I am using is iText 1.4.3.
Why is this happening? As I am just regenerating the pdf should not it generate the replica of it ? I haven't used any rotate in the code. The portion of the code is attached below:

try {
                        PdfReader reader = new PdfReader("C:\\test\\one.pdf");
                        int n = reader.getNumberOfPages();
                        Rectangle psize = reader.getPageSize(1);
                        float width = psize.width();
                        System.out.println("one width >>"+width);
                        float height = psize.height();
                        System.out.println(" one height >>"+height);
                           Document document = new Document(psize,0,0,0,0);
                        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:\\test\\two.pdf"));
                        document.open();
                        PdfContentByte cb = writer.getDirectContent();
                        int i = 0;
                        int p = 0;
                        System.out.println("There are " + n + " pages in the document.");
                        while (i < n) {
                                document.newPage();
                                p++;
                                i++;
                                PdfImportedPage page1 = writer.getImportedPage(reader, i);
                                cb.addTemplate(page1, 1.0f, 0, 0, 1.0f, 0, 0);
                        }
                        document.close();
                        PdfReader reader2 = new PdfReader("c:\\test\\two.pdf");
                        Rectangle p2size = reader2.getPageSize(1);
                        System.out.println("two width >>"+p2size.width());
                        System.out.println("two height >>"+p2size.height());

Regards,
Triloke

************************************************************
HSBC Software Development (India) Pvt Ltd
HSBC Center Riverside,West Avenue ,
25 B Kalyani Nagar Pune  411 006 INDIA

Telephone: +91 20 26683000
Fax: +91 20 26681030
************************************************************




*******************************************************************
This e-mail is confidential. It may also be legally privileged.
If you are not the addressee you may not copy, forward, disclose
or use any part of it. If you have received this message in error,
please delete it and all copies from your system and notify the
sender immediately by return e-mail.

Internet communications cannot be guaranteed to be timely,
secure, error or virus-free. The sender does not accept liability
for any errors or omissions.
*******************************************************************
"SAVE PAPER - THINK BEFORE YOU PRINT!"

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to