Changing the page size of an existing pdf must be done in another way.

PdfReader reader = ....;
PdfDictionary dic = reader.getPageN(1);
dic.put(PdfName.MEDIABOX, new PdfArray(new float[]{0, 0,
PageSize.LEGAL.width(), PageSize.LEGAL.height()}));

Use PdfStamper to output the result.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]
> Sent: Monday, November 03, 2003 13:04
> To:   [EMAIL PROTECTED]
> Subject:      [iText-questions] (no subject)
> 
> Hi, this is my method to convert LETTER size page to LEGAL.
> 
>   public void changerPageSizePourLegal(String newFile, Log log)
>   {
>     PdfContentByte        pdfcbContenuFichierPDF;
>     PdfReader             pdfrDocumentPDF;
>     PdfWriter             pdfwDocumentPDF;
>     ByteArrayOutputStream baosDocumentPDF = new ByteArrayOutputStream();
>     Document              documentPDF = new Document();
>     
>     try
>     {
>       int intNombrePageDocumentPDF;
>       pdfrDocumentPDF = new PdfReader( RetournerContenuFichier( new File
> ("test.pdf"), log ).getBytes( "ISO-8859-1" ) );
>       pdfwDocumentPDF = PdfWriter.getInstance( documentPDF,
> baosDocumentPDF );
>       intNombrePageDocumentPDF = pdfrDocumentPDF.getNumberOfPages();
> 
>       documentPDF.setPageSize(PageSize.LEGAL);
>       documentPDF.open();
>      
>       pdfcbContenuFichierPDF = pdfwDocumentPDF.getDirectContent();
> 
>       for( int intNombrePage = 1; intNombrePage <= 1; intNombrePage++ )
>       {
>         documentPDF.newPage();
>         documentPDF.setPageSize(PageSize.LEGAL);        
>         PdfImportedPage pdfipPage = pdfwDocumentPDF.getImportedPage( 
> pdfrDocumentPDF, intNombrePage );
>         pdfcbContenuFichierPDF.addTemplate( pdfipPage, 0, 0 );
>       }
>         
>     }
>     catch(DocumentException de) {
>       System.out.println(de.getMessage());
>     }
>     catch(IOException ioe) {
>       System.out.println(ioe.getMessage());
>     }
>     
>     documentPDF.close();    
>   }
> 
> Is it possible to tell me why the page size always stay LETTER ?  The
> test.pdf 
> file is a good one because I look inside before running code and I can
> read it 
> with acrobatReader.
> Thank's
> R�mi
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive?  Does it
> help you create better code?   SHARE THE LOVE, and help us help
> YOU!  Click Here: http://sourceforge.net/donate/
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to