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

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
stan  
#1 Posted : Monday, March 4, 2019 5:42:51 AM(UTC)
Quote
stan

Rank: Member

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

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

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

Paul Rayman  
#2 Posted : Monday, March 4, 2019 9:51:02 PM(UTC)
Quote
Paul Rayman

Rank: Administration

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

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
seems you should save, close and reopen destination document.
Quick Reply Show Quick Reply
Users browsing this topic
Guest
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.