Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 2 Jahren, 7 Monaten
Letzter Beitrag:
vor 2 Jahren, 6 Monaten
Beteiligte Autoren:
Gianni Spano, DarrenF

How to use iTextSharp control ***S O L V E D ***

Startbeitrag von Gianni Spano am 23.11.2015 09:38

Hello to all

Follow my previous post on how to retrieve form fields values from a pdf file, after few attempts and researches on the web, i found a little example written in vb that is using an iTextSharp.dll library.
I have been able to load the "iTextSharp.dll" library as a .Net assembly into Windev and it shows me all the properties and methods, but i have some troubles on its use.

This is the original Vb portion of code that i would convert in Windev.


Imports iTextSharp.text.pdf

Public Function GetFormData(ByVal sourcePdf as string) as Dictionary(Of String, String)
Dim frmData As New Dictionary(Of String, String)
Try
'Open the pdf using pdfreader
Dim reader As New PdfReader(sourcePdf)
'Get the form from pdf
Dim frm as AcroFields = reader.AcroFields
'get the fields from the form
Dim fields As System.Collections.Hashtable = frm.Fields
'Extract the data from the fields
Dim data As String = String.Empty
For Each key As String In fields.Keys
data = frm.GetField(key)
frmData.Add(key, data)
Next
reader.Close ()
Catch ex As Exception
Debug.Write(ex.Message)
End Try
Return frmData
End Function


Thanks in advance.
Gianni

Antworten:

Re: How to use iTextSharp control ****S O L V E D ***

Hello to all

After few days of researches and testing, i have been able to read form fields data from a fillable Pdf file.

Here is a portion of code on how to use the "iTextSharp.dll" .net library to retrieve all the fields name and their value from a pdf.


myPDF is PdfReader(EDT_File_PDF)
myAcrofields is AcroFields dynamic
myAcrofields = myPDF.get_AcroFields()

FOR EACH MONFieldElement OF myAcrofields.Fields
Trace(MONFieldElement.Key,myAcrofields.GetFieldType(MONFieldElement.Key),myAcrofields.GetField(MONFieldElement.Key))
END



With these few lines of code now i can read each pdf attached in an e-mail sent by a web user and register their personal informations.

Hope this little solution will help other developers.

Regards
Gianni

von Gianni Spano - am 26.11.2015 15:13

Re: How to use iTextSharp control ****S O L V E D ***

Gianni,

That's great - maybe this would benefit from being added to the "solutions" area of the forum? :cheers:

von DarrenF - am 26.11.2015 16:45
Hello Darren

Thank you. Yes, it could be a good idea to post the solution on the specific area of the forum.

The idea come from a problem we had in our local health authority.
In Italy the peoples with problems with their driver license revoked, can book a new medical visit to see if they are able to drive a car after an infrigement of the law during the driving of a car.
In our web site we put a fillable pdf file that a user can download on his pc and then fill out all the informations required for the medical visit.
Then he will send the pdf to a specific e-mail address and when it arrives at the office, each e-mail is verified and the pdf attached is examined to retrieve all the informations that will be saved in our database to book the medical visit.
I had, initially, some troubles on how to read the form fields from the pdf.
This is the little solution i have tested, hoping to help other developers with the same problems.

Gianni

von Gianni Spano - am 26.11.2015 21:29
Hi,

I'm not saying give your hard work away, just outline the technique, but it's good that you outlined your requirements - sounds like a great customer focused solution. Your customer is very lucky.

von DarrenF - am 26.11.2015 22:21
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.