logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Paul Rayman Posted: Monday, March 4, 2019 9:51:02 PM(UTC)
 
seems you should save, close and reopen destination document.
stan Posted: Monday, March 4, 2019 5:42:51 AM(UTC)
 
I am needing to add pages to an existing PDF from separate documents that all have form fields on them. The existing PDF also has its own forms fields on it.
From the test I have ran it seems the fields are added (the fields are there after saving the doc) but just not seen by the FormFill.InterForm.Fields while the program is running.


Code:


// ms is a memory stream 

PdfForms forms = new PdfForms();
PdfDocument doc = PdfDocument.Load(ms, forms);

foreach(int pageIndex in listOfPageIndexes)
{
     PdfForms formsDup = new PdfForms();
     PdfDocument docDup;

     // ms2 is a memory stream
     docDup = PdfDocument.Load(ms2, formsDup);

      //This renames the fields so that it can be added with conflicting with the previous document. 

      foreach (var field in docDup.FormFill.InterForm.Fields.ToList())
      {
         string fieldName = field.Dictionary.FirstOrDefault(u => u.Key.StartsWith("T")).Value.As<PdfTypeString>().AnsiString;
         var typeString = field.Dictionary.FirstOrDefault(u => u.Key.StartsWith("T")).Value.As<PdfTypeString>();
         typeString.AnsiString = fieldName + "_" + (index + 1).ToString();
      }

     doc.Pages.ImportPages(docDup, indexToPrint.ToString(), doc.Pages.Count);
}