This is in C# windows application. Source code used below

---

public static void MergeFiles(string destinationFile, string[] sourceFiles)
        {
            try
            {
                int f = 0;
                // we create a reader for a certain document            
                PdfReader reader = new PdfReader(sourceFiles[f]);
                // we retrieve the total number of pages        
                int n = reader.NumberOfPages;
                //Console.WriteLine("There are " + n + " pages in the original 
file.");         
                // step 1: creation of a document-object                
                Document document = new 
Document(reader.GetPageSizeWithRotation(1));
                // step 2: we create a writer that listens to the document      
        
                PdfWriter writer = PdfWriter.GetInstance(document, new 
FileStream(destinationFile, FileMode.Create));
                // step 3: we open the document                 
                document.Open();
                PdfContentByte cb = writer.DirectContent;
                PdfImportedPage page;
                int rotation;
                // step 4: we add content       
                while (f < sourceFiles.Length)
                {
                    int i = 0;
                    while (i < n)
                    {
                        i++;
                        document.SetPageSize(reader.GetPageSizeWithRotation(i));
                        document.NewPage();
                        page = writer.GetImportedPage(reader, i);
                        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);
                        }
                        //Console.WriteLine("Processed page " + i);             
                    }
                    f++;
                    if (f < sourceFiles.Length)
                    {
                        reader = new PdfReader(sourceFiles[f]);
                        // we retrieve the total number of pages        
                        n = reader.NumberOfPages;
                        //Console.WriteLine("There are " + n + " pages in the 
original file.");         
                    }
                }
                // step 5: we close the document                
                document.Close();
            }
            catch (Exception e)
            {
                string strOb = e.Message;
            }
        }

---

Michael Chernecki
Senior ECM Systems Specialist 
CriticalControl Solutions Inc.
555 Madison Street
Winnipeg, Manitoba  R3H 0L6
T 204.975.2713  F 204 989 0317
www.criticalcontrol.com
 
 
NOTICE: This privileged and confidential email is intended only for the 
individual or entity to whom it is addressed.  With regard to all others, any 
action related with this email as well as any reading, reproduction, 
transmission and/or dissemination in whole or in part of the information 
included in this email is prohibited.  If you are not the addressee, 
immediately return the email to sender prior to destroying all copies.  
 
P   Please consider the environment before printing this email.
 

Message: 4
Date: Tue, 29 Mar 2011 15:56:55 +0100
From: Paulo Soares <[email protected]>
Subject: Re: [iText-questions] Corrupt PDF after merging many pages
To: Post all your questions about iText here
        <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Is that in ASP.NET?

Paulo 

-----Original Message-----
From: Michael Chernecki [mailto:[email protected]] 
Sent: Tuesday, March 29, 2011 3:08 PM
To: [email protected]
Subject: Re: [iText-questions] Corrupt PDF after merging many pages

I can't provide the original document as it contains client data. I will see if 
I can provide a sample without client data. I downloaded the latest iTextSharp 
DLL yesterday and retested with the same problem, I believe the version was 
5.0.6.


Date: Mon, 28 Mar 2011 17:15:00 -0700
From: "Mark Storer" <[email protected]>
Subject: Re: [iText-questions] Corrupt PDF after merging many pages
To: "Post all your questions about iText here"
<[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain;charset="us-ascii"

What version of iTextSharp are you using?  Can we see one of these PDFs?

--Mark Storer
  Senior Software Engineer
  Cardiff.com
 
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
 
 

> -----Original Message-----
> From: Michael Chernecki 
> [mailto:[email protected]] 
> Sent: Monday, March 28, 2011 3:46 PM
> To: [email protected]
> Subject: [iText-questions] Corrupt PDF after merging many pages
> 
> I am using iTextSharp to merge several 1-page/2-page pdf 
> files into one large document. When merging a few files, 
> everything is fine. For larger documents (128 pages in one 
> example) I get the error on opening "An error exists on this 
> page. Acrobat may not display correctly. Please contact the 
> person who created the PDF document to correct the problem." 
> The page count is correct, but all pages are blank. Each PDF 
> page is of a TIFF file output to PDF from the scanner. I 
> don't know the document page size when failure occurs. A 
> second document displays the same, but it is not as large as 
> this one. 
>  
> Has anyone experienced this problem? Is there a work around?
>  
> Thanks
>  
> Mike C
> 
> 
------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.




------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
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