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



Go to last post Go to first unread
#1 Posted : Monday, March 4, 2019 8:42:51 AM(UTC)

Rank: Newbie

Groups: Registered
Joined: 2/21/2019(UTC)
Posts: 8

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.


// 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);

Edited by user Monday, March 4, 2019 9:31:42 AM(UTC)  | Reason: Not specified

Paul Rayman  
#2 Posted : Tuesday, March 5, 2019 12:51:02 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 779

Thanks: 1 times
Was thanked: 97 time(s) in 95 post(s)
seems you should save, close and reopen destination document.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.