-
Notifications
You must be signed in to change notification settings - Fork 0
/
PDF-FormData-Helper.au3
79 lines (56 loc) · 1.66 KB
/
PDF-FormData-Helper.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#region Includes
#include <File.au3>
#include <Misc.au3>
#endregion Includes
#cs
V2.0.0
PDF-FormData-Helper
2022 by Thorsten Willert
www.thorsten-willert.de
To use with Form_Data.js to export formdata from Adobe Acrobat Reader
#ce
Global Const $__DEBUG__ = False ;#__DEBUG__
_Singleton("FormData-Helper")
Global $sFileName = ""
While Sleep(1000)
$hWnd = WinWaitActive("JavaScript-Debugger")
$xml = ControlGetText($hWnd, "", "RICHEDIT50W1")
If $__DEBUG__ Then ConsoleWrite($xml & @CRLF) EndIf
WinClose($hWnd)
If StringLen($xml) > 10 Then
$aFile = StringRegExp($xml, "/([\w\d-_]*?\.pdf)", 1)
If Not @error Then
$sFileName = $aFile[0]
EndIf
If StringInStr($xml, '<xfdf xmlns="http://ns.adobe.com/xfdf/') Then
Save($sFileName, "xfdf", 2)
ElseIf StringInStr($xml, '%FDF') Then
Save($sFileName, "fdf", 18)
EndIf
EndIf
$xml = ""
WEnd
#cs
Die temporaere Datei beim Speichern ist vorerst notwendig.
Ein anschliessendes Importieren der Daten ist sonst unmoeglich, da hier
Datei-Rechte durcheinander kommen, die verhindern, dass der
Acrobat Reader die Daten wieder lesen kann.
#ce
Func Save($sName, $sType, $iMode)
$sName = StringReplace($sName, ".pdf", "." & $sType)
$sTmpFile = _TempFile()
If $__DEBUG__ Then ConsoleWrite($sTmpFile & @CRLF) EndIf
$hFile = FileSaveDialog("Save as ...", _
"::{450D8FBA-AD25-11D0-98A8-0800361B1103}", _ ; MyDocuments
StringUpper($sType) & " (*." & $sType & ")", _
16, _
$sName)
If Not @error Then
FileOpen($sTmpFile, $iMode)
FileWrite($sTmpFile, $xml)
FileClose($sTmpFile)
FileCopy($sTmpFile, $hFile)
EndIf
FileDelete($sTmpFile)
If $__DEBUG__ Then ConsoleWrite($sName & @CRLF) EndIf
EndFunc ;==>Save