HI, I need to change the margins of a pdf that there previously, I've tried
PdfStamper  and also PdfCopy, but have not succeeded.

This is the code:


  private ByteArrayOutputStream formateaDocumento(ByteArrayInputStream
input)
  throws DocumentException, IOException 
  {
    ByteArrayOutputStream byteArrayOutputStreamPdf = new
ByteArrayOutputStream();
    PdfReader reader = new PdfReader(input);
    int pages_number = reader.getNumberOfPages();
    if (pages_number > 0) 
    {
      Document document = new Document(reader.getPageSizeWithRotation(1));
      document.setMargins(10, 10, 10, 10);
      
      PdfCopy copy = new PdfCopy(document, byteArrayOutputStreamPdf);
      copy.setMargins(10, 10, 10, 10);

      document.open();
      
      for (int i = 1; i <= pages_number; i++) 
      {
        PdfImportedPage page = copy.getImportedPage(reader, i);
        copy.addPage(page);
      }
      
      document.close();
      
    }
      
    return byteArrayOutputStreamPdf;
  } 




Thanks
-- 
View this message in context: 
http://itext-general.2136553.n4.nabble.com/How-can-i-change-the-margins-of-a-pdf-that-there-previously-tp3092507p3092507.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to