Click here to Skip to main content
15,562,414 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Trying to do a simple Merge pdf files using itextshatp, however no Result/Merged file is created and no errors thrown. Am I missing anything?

What I have tried:

 private void CreateMergedPdf(object sender, DoWorkEventArgs e)
 {
using (FileStream StreamMulti=new FileStream(MergeOutputPdfName,FileMode.Create))
     {
         Document DocumentMulti = new Document();
         PdfCopy WriterMulti = new PdfCopy(DocumentMulti,StreamMulti);
         DocumentMulti.Open();

         try
         {
             foreach (string fileItem in ListBox.Items)
             {
                 PdfReader ReaderMulti = PdfReader(fileItem);
                 WriterMulti.AddDocument(ReaderMulti);
                 ReaderMulti.Close();
             }
         }
         catch (Exception Ex)
         {
             MessageBox.Show(Ex.Message," Merge Error !",MessageBoxButtons.OK,MessageBoxIcon.Error);
         }
         WriterMulti.Close();
         DocumentMulti.Close();
     }
 }
Posted
Updated 3-Feb-22 8:39am

1 solution

Here I'm giving nice link of example of merge pdf file using itextsharp and asp.net. please have a look at it.
Merge Multiple Pdfs Into A Single Pdf Using ItextSharp[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900