Skip to content

Commit 6a71109

Browse files
authored
Update 5-SaveDemo.au3
1 parent 8bba55c commit 6a71109

1 file changed

Lines changed: 5 additions & 54 deletions

File tree

examples/5-SaveDemo.au3

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#include "..\NetWebView2Lib.au3"
66

77
; Global objects
8-
Global $hGUI, $idLabelStatus
8+
Global $hGUI
99

10-
Main()
10+
_Example()
1111

12-
Func Main()
12+
Func _Example()
1313
Local $oMyError = ObjEvent("AutoIt.Error", __NetWebView2_COMErrFunc)
1414
#forceref $oMyError
1515

@@ -45,7 +45,7 @@ Func Main()
4545
Local $dPDF_asBase64 = _NetWebView2_PrintToPdfStream($_g_oWeb)
4646

4747
; decode Base64 encoded data do Binary
48-
Local $dBinaryDataToWrite = _Base64Decode($dPDF_asBase64)
48+
Local $dBinaryDataToWrite = _NetWebView2_DecodeB64($_g_oWeb, $dPDF_asBase64)
4949

5050
; finally save PDF to FILE
5151
Local $hFile = FileOpen($s_PDF_FileFullPath, $FO_OVERWRITE + $FO_UTF8_NOBOM + $FO_BINARY)
@@ -83,53 +83,4 @@ Func Main()
8383
#EndRegion ; GUI Loop
8484

8585
_NetWebView2_CleanUp($oWebV2M, $oJSBridge)
86-
EndFunc ;==>Main
87-
88-
; #FUNCTION# ====================================================================================================================
89-
; Name ..........: _Base64Decode
90-
; Description ...:
91-
; Syntax ........: _Base64Decode($input_string)
92-
; Parameters ....: $input_string - An integer value.
93-
; Return values .: None
94-
; Author ........: trancexx
95-
; Modified ......:
96-
; Remarks .......:
97-
; Related .......:
98-
; Link ..........: http://www.autoitscript.com/forum/topic/81332-base64encode-base64decode
99-
; Example .......: yes
100-
; ===============================================================================================================================
101-
Func _Base64Decode($input_string)
102-
103-
Local $struct = DllStructCreate("int")
104-
105-
Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
106-
"str", $input_string, _
107-
"int", 0, _
108-
"int", 1, _
109-
"ptr", 0, _
110-
"ptr", DllStructGetPtr($struct, 1), _
111-
"ptr", 0, _
112-
"ptr", 0)
113-
114-
If @error Or Not $a_Call[0] Then
115-
Return SetError(1, 0, "") ; error calculating the length of the buffer needed
116-
EndIf
117-
118-
Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
119-
120-
$a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
121-
"str", $input_string, _
122-
"int", 0, _
123-
"int", 1, _
124-
"ptr", DllStructGetPtr($a), _
125-
"ptr", DllStructGetPtr($struct, 1), _
126-
"ptr", 0, _
127-
"ptr", 0)
128-
129-
If @error Or Not $a_Call[0] Then
130-
Return SetError(2, 0, "") ; error decoding
131-
EndIf
132-
133-
Return DllStructGetData($a, 1)
134-
135-
EndFunc ;==>_Base64Decode
86+
EndFunc ;==>_Example

0 commit comments

Comments
 (0)