I need to process a lot of pdf-forms.
In this process I would like to extract the pdf-form data. This can be done with PDFtk (https://www.pdflabs.com/tools/pdftk-server/).
It returns a textfile (or output to variable) like this:
—
FieldType: Button
FieldName: Std-farve
FieldFlags: 49154
FieldValue: 1
FieldJustification: Left
FieldStateOption: 0
FieldStateOption: 1
FieldStateOption: Blå
FieldStateOption: Grå
FieldStateOption: Off
—
FieldType: Button
FieldName: Individuel-Dato
FieldFlags: 0
FieldJustification: Left
FieldStateOption: Off
FieldStateOption: Yes
—
FieldType: Button
FieldName: Individuel-farve
FieldFlags: 0
FieldJustification: Left
FieldStateOption: Off
FieldStateOption: Yes
—
FieldType: Choice
FieldName: Std-antal
FieldFlags: 4325378
FieldValue: 100
FieldValueDefault: 100
FieldJustification: Left
FieldStateOption: 100
FieldStateOption: 1000
FieldStateOption: 150
FieldStateOption: 200
FieldStateOption: 300
FieldStateOption: 400
FieldStateOption: 50
FieldStateOption: 500
FieldStateOption: 600
FieldStateOption: 700
FieldStateOption: 800
FieldStateOption: 900
—
FieldType: Text
FieldName: Pris i alt
FieldFlags: 1
FieldValue: Kr. 1050,-
FieldJustification: Left
—
FieldType: Text
FieldName: Individuel-farve-txt
FieldFlags: 8388608
FieldJustification: Left
—
FieldType: Text
FieldName: Individuel-øvrige-ønsker-txt
FieldFlags: 8388608
FieldJustification: Left
—
FieldType: Text
FieldName: Tlf
FieldFlags: 8388610
FieldValue: 40404040
FieldJustification: Left
—
FieldType: Text
FieldName: Leveringsadresse
FieldFlags: 8388610
FieldValue: Enghavevej 9 d
FieldJustification: Left
—
FieldType: Text
FieldName: Firmanavn
FieldFlags: 8388610
FieldValue: Registreret Revisionsanpartsselskab
FieldJustification: Left
—
FieldType: Text
FieldName: FSR-medlemsnummer
FieldFlags: 8388610
FieldValue: 554466
FieldJustification: Left
—
FieldType: Text
FieldName: Kontaktperson
FieldFlags: 8388610
FieldValue: Preben Graungaard
FieldJustification: Left
—
FieldType: Text
FieldName: Postnr
FieldFlags: 8388610
FieldValue: 7100
FieldJustification: Left
—
FieldType: Text
FieldName: Mailadresse
FieldFlags: 8388610
FieldValue: revi@g-revision.dk
FieldJustification: Left
—
FieldType: Text
FieldName: By
FieldFlags: 8388610
FieldValue: Vejle
FieldJustification: Left
—
FieldType: Text
FieldName: Bemærkninger
FieldFlags: 4096
FieldJustification: Left
—
FieldType: Button
FieldName: Individuel-øvrige-ønsker
FieldFlags: 0
FieldJustification: Left
FieldStateOption: Off
FieldStateOption: Yes
—
FieldType: Button
FieldName: Send
FieldFlags: 65536
FieldJustification: Left
What I would like was to convert each form-field to a variable.
The name of the variable should be FieldName and the value should be FieldValue.
If a FieldValue is not present for the form-field it should just be set to blank.
I do not now how to go about this.
Hope somebody has some good ideas.
I just uploaded the below macro, which provides a complete solution with options for selecting source data input.
It uses a RegEx based method, rather than a JXA script based method.
If you, or anyone, have any questions about this macro, please post in the above macro topic.