0

this is my first post here in stackoverflow,but I followed too much about my favourite vb.net articles... now I want to share my little experience and ask another one that I can't do... I have precompiled pdf file with some field, textbox and checkbox. My goal is after user filling, open the pdf file with my software that can read text value from textbox and state form check box. The first is done, check the following code:

Imports iTextSharp
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports iTextSharp.text.xml
'open file dialog code...
Dim pdfTemplate As String = lbl_file.Text
Dim readerPDF As New PdfReader(pdfTemplate)
Dim name As Object = readerPDF.AcroFields.GetField("name")
Try
txt_name.Text = name
Catch Ex As Exception
End Try

This part of code, search a textbox called "name" and put here text proprieties into my text box. WOW...but to check a checkbox state?do you have any idea please? Thank's in advance for all.

1 Answers1

0

maybe i found a way to do...check this and, what do you think about?

Dim male As Object = readerPDF.AcroFields.GetField("male")
If male = "On" Then
cmb_male.Checked = True
End If

I saw in acrobat default output value from checkbox is "On" than is enough check it and change checkbox value as needed.

  • There is no guarantee that the *on value* will be `"On"`. It could be `"Yes"` or `"true"` or `"1"` or `"male"` or whatever was defined in the PDF. The only thing you can be sure of, is that the *off value* is `"Off"` because that's how it's defined in ISO-32000-1. See http://stackoverflow.com/questions/23254617/ – Bruno Lowagie Feb 10 '15 at 11:16