Patagames Software Support Forum
»
Pdfium.Net SDK
»
FAQ
»
filling editable PDF fields and extracting data from them
Rank: Member
Groups: Registered
Joined: 7/14/2016(UTC) Posts: 20  Thanks: 4 times
|
I can't seem to find code snippet in SDK to fill PDF fields by fieldnames with certain values and also to open a PDF form and read the values in the fields in them. Any help would be appreciated a lot.
I use C# and my app is WPF.
Thanks.
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
The following code demonstrates how programmatically fill all editable forms in pdf document Code:
private void btnTest_Click(object sender, RoutedEventArgs e)
{
var doc = pdfViewer1.Document;
var interactiveForms = doc.FormFill.InterForm;
int i = 0;
foreach(var field in interactiveForms.Fields)
{
if(field.FieldType == Patagames.Pdf.Enums.FormFieldTypes.FPDF_FORMFIELD_TEXTFIELD)
{
field.Value = "This is a field #" + (++i);
}
}
}
the same thing without using the viewer Code:
private void btnTest_Click(object sender, RoutedEventArgs e)
{
var forms = new PdfForms();
var doc = PdfDocument.Load(@"c:\test.pdf", forms);
//doc.FormFill is equal to forms and can be used to get access to acro forms as well;
int i = 0;
foreach(var field in forms.InterForm.Fields)
{
if(field.FieldType == Patagames.Pdf.Enums.FormFieldTypes.FPDF_FORMFIELD_TEXTFIELD)
{
field.Value = "This is a field #" + (++i);
}
}
}
Edited by user Monday, August 1, 2016 6:02:08 AM(UTC)
| Reason: Not specified
|
 1 user thanked Paul Rayman for this useful post.
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/14/2016(UTC) Posts: 20  Thanks: 4 times
|
How can I attach my solution in this forum or in an email format to send it to you? I am experiencing Null Reference exception on the following line of code (eventhough it seems like the PDF file gets loaded)
var interactiveForms = doc.FormFill.InterForm;
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
|
|
|
|
|
|
Patagames Software Support Forum
»
Pdfium.Net SDK
»
FAQ
»
filling editable PDF fields and extracting data from them
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.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close