You also have to make attention to the crop box. In the next version I'll
try to put some automated way to duplicate the page dimensions.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]
> Sent: Wednesday, June 18, 2003 11:10
> To:   [EMAIL PROTECTED]
> Subject:      [iText-questions] Splitting / Copying pdf
> 
> Hello,
> 
> I have a pdf with 110 pages and want to have 110 
> pdfs with 1 page. The original hat 1.3MByte.
> 
> I use the following code (using snipplets from 
> concat and split):
> 8< ------------------
> PdfReader reader = null;
> try {
>     reader = new PdfReader(m_source.getAbsolutePath
> ());
>     m_noPages = reader.getNumberOfPages();
> } catch (IOException e) {
>     e.printStackTrace();
> }
> 
> for(int i=1; i<= m_noPages; i++) {
>     Document destination = new Document
> (reader.getPageSizeWithRotation(i));
>     
>     PdfWriter writer = null;
>     try {
>         writer = PdfWriter.getInstance(destination, 
> new FileOutputStream(new File(m_destFolder, i + "_" 
> + m_source.getName())));
>         destination.open();
>         PdfContentByte cb = writer.getDirectContent
> ();
>         destination.setMargins(0,0,0,0);
>         destination.newPage();
> 
>         PdfImportedPage page = 
> writer.getImportedPage(reader, i);
>         
>         int rotation = reader.getPageRotation(i);
>         if (rotation == 90 || rotation == 270) {
>             cb.addTemplate(page, 0, -1f, 1f, 0, 0, 
> reader.getPageSizeWithRotation(i).height());
>         }
>         else {
>             cb.addTemplate(page, 1f, 0, 0, 1f, 0, 
> 0);
>             destination.setMargins(0,0,0,0);
>         }
>     } catch (Exception e) {
>         e.printStackTrace();
>     }
>     destination.close();
> }
> 
> ------------------ >8
> 
> The resulting pdfs have a size of 11MByte, which is 
> quite ok for me. The java-program is really fast.
> There is one major drawback: The Pages do not look 
> exactly like the original especially the margins, 
> so I tried PdfCopy instead:
> 
> 8< ------------------
> PdfReader reader = null;
> try {
>     reader = new PdfReader(m_source.getAbsolutePath
> ());
>     m_noPages = reader.getNumberOfPages();
> } catch (IOException e) {
>     e.printStackTrace();
> }
> 
> for(int i=1; i<= m_noPages; i++) {
>     Document destination = new Document
> (reader.getPageSizeWithRotation(i));
>     
>     PdfCopy writer = null;
>     try {
>         writer = new PdfCopy(destination, new 
> FileOutputStream(new File(m_destFolder, i + "_" + 
> m_source.getName())));
>         destination.open();
> 
>         PdfImportedPage page = 
> writer.getImportedPage(reader, i);
>         writer.addPage(page);
>         
>     } catch (Exception e) {
>         // TODO: handle exception
>         e.printStackTrace();
>     }
>     destination.close();
> }
> ------------------ >8
> 
> The result is much better, the margins are ok. The 
> disadvantages here: the program needs much more 
> time and the resulting pdfs have more than 100MB.
> How can I get the output from source 2 with the 
> file-size from source 1?
> 
> Thank you in advance,
> Norman
> 
> 
> 
> ---------------------------------------------------
> Sichern Sie sich jetzt Ihre E-Mail-Adresse von Aral:
> http://www.aral.de/mail
> http://www.bikerclub.de/mail
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions


-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to