How do I Combine/Merge PDFs with Fillable Form Fields using iTextSharp?

前端 未结 2 1440
旧时难觅i
旧时难觅i 2020-12-20 20:53

Using iTextSharp, how can I merge multiple PDFs into one PDF without losing the Form Fields and their properties in each individual PDF?

(I would prefer

2条回答
  •  我在风中等你
    2020-12-20 21:15

    you can also use this code.... it will merge all the pdf file without losing field value..

        Document document = new Document();
        try
            {         
               string destinationfile = desktopPath.Replace(@"d:\outputfile.pdf");
               PdfCopyFields copier = new PdfCopyFields(new FileStream(destinationfile,     FileMode.Create));
                PdfImportedPage page;
    
                //Loops for each file that has been listed
                foreach (string filename in fileList)
                {
                    flag++;
                    try
                    {
                        //The current file path
                        string filePath = sourcefolder + filename;
    
                        PdfReader reader = new PdfReader(filePath);
                        copier.AddDocument(reader);
    
                    }
                    catch
                    {
    
                    }
                }
                copier.Close();
            }
    

提交回复
热议问题