Lodop 是网页打印控件,根据 Lodop 语法,咋按它要求生成 HTM,不就可以按要求打印了。
PRINT_BARCODE()
Func PRINT_BARCODE()
PRINT_INIT()
If IsArray($CODE_Array) Then
If UBound($CODE_Array) > 2 Then
Dim $SOLen
$SOLen = _SOLen("LODOP.PREVIEW();")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.PRINT();'
EndIf
EndIf
PRINT_act()
EndFunc ;==>PRINT_BARCODE
Func PRINT_INIT()
If Not FileExists("C:\Lodop") Then DirCreate("C:\Lodop")
If Not FileExists("C:\Lodop\install_lodop32.exe") Then
If FileExists(@ScriptDir & "\Lodop\install_lodop32.exe") Then
FileCopy(@ScriptDir & "\Lodop\install_lodop32.exe", "C:\Lodop\install_lodop32.exe", 1)
EndIf
EndIf
If Not FileExists("C:\Lodop\LodopFuncs.js") Then
If FileExists(@ScriptDir & "\Lodop\LodopFuncs.js") Then
FileCopy(@ScriptDir & "\Lodop\LodopFuncs.js", "C:\Lodop\LodopFuncs.js", 1)
EndIf
EndIf
_FileCreate("C:\Lodop\Lodop.htm")
If $CODE_Array_Save[0] = "" Then
If FileExists(@ScriptDir & "\Lodop\Lodop.htm") Then
_FileReadToArray(@ScriptDir & "\Lodop\Lodop.htm", $CODE_Array_Save)
If IsArray($CODE_Array_Save) Then
If UBound($CODE_Array_Save) > 2 Then
EndIf
EndIf
EndIf
EndIf
$CODE_Array = $CODE_Array_Save
If IsArray($CODE_Array) Then
If UBound($CODE_Array) > 2 Then
Dim $SOLen, $len_h = 60, $len_hh = 0, $SETLEN = 0, $STYLEA_add = 0, $KH_Code_A, $KH_Code_B, $FontSize_add = 30
$SOLen = _SOLen("上网凭证")
If $SOLen > 0 Then
Dim $SWPZ_STR = $CODE_Array[$SOLen]
$SWPZ_STR = StringReplace($SWPZ_STR, "上网凭证", $wbName)
$CODE_Array[$SOLen] = $SWPZ_STR
EndIf
If StringLen($KH_Code) > 7 Then
$len_hh = 20
$STYLEA_add = 1
$FontSize_add = 22
$KH_Code_A = StringMid($KH_Code, 1, 10)
$KH_Code_B = StringMid($KH_Code, 11, 8)
$SOLen = _SOLen("用_户_编_号_A")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.ADD_PRINT_TEXT(15,10,170,30,"' & $KH_Code_A & '");'
$SOLen = _SOLen("用_户_编_号_B")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.ADD_PRINT_TEXT(45,10,170,30,"' & $KH_Code_B & '");'
$SOLen = _SOLen("字体大小B")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.SET_PRINT_STYLEA(4,"FontSize",' & $FontSize_add & ');'
$SOLen = _SOLen("登_录_口_令_加_粗")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.SET_PRINT_STYLEA(5,"Bold","1");'
Else
$len_hh = 0
$SOLen = _SOLen("用_户_编_号_A")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.ADD_PRINT_TEXT(15,10,170,30,"' & $KH_Code & '");'
$SOLen = _SOLen("登_录_口_令_加_粗")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.SET_PRINT_STYLEA(4,"Bold","1");'
EndIf
$SOLen = _SOLen("字体大小A")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.SET_PRINT_STYLEA(3,"FontSize",' & $FontSize_add & ');'
$SOLen = _SOLen("字体大小C")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.SET_PRINT_STYLEA(' & 7 + $STYLEA_add & ',"FontSize",14);'
$SOLen = _SOLen("登录口令")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.ADD_PRINT_TEXT(' & $len_h + $len_hh & ',10,85,20,"口令:' & $KH_PASS & '");'
$SOLen = _SOLen("预付现金")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.ADD_PRINT_TEXT(' & $len_h + $len_hh & ',95,85,20,"现金:' & $KH_YFF & '");'
$SOLen = _SOLen("开户时间")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.ADD_PRINT_TEXT(' & $len_h + 20 + $len_hh & ',10,65,20,"时间:");'
$SOLen = _SOLen("开户日期")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.ADD_PRINT_TEXT(' & $len_h + 20 + $len_hh - 4 & ',40,140,20," ' & $KH_Time & '");'
$SOLen = _SOLen("替换条形码行")
$KH_Code = StringLower($KH_Code)
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.ADD_PRINT_BARCODE(' & $len_h + 20 + 20 + $len_hh & ',1,195,' & $CodeH_SAVE & ',"' & $CodeType_SAVE & '","' & $KH_Code & '");'
$SOLen = _SOLen("ShowBarText")
If $SOLen > 0 Then $CODE_Array[$SOLen] = ' LODOP.SET_PRINT_STYLEA(' & 8 + $STYLEA_add & ',"ShowBarText",0);'
EndIf
EndIf
EndFunc ;==>PRINT_INIT
Func _SOLen($str = "")
Dim $so_codeline = _ArraySearch($CODE_Array, $str, 0, 0, 0, 1)
Return Int($so_codeline)
EndFunc ;==>_SOLen
Func PRINT_act()
_FileWriteFromArray("C:\Lodop\Lodop.htm", $CODE_Array, 1)
_IENavigate($oIE_print, "file:///C:/Lodop/Lodop.htm")
_IELoadWait($oIE_print, 1, 1000)
Dim $oIE_printText = _IEBodyReadText($oIE_print)
If StringInStr($oIE_printText, "打印控件未安装") > 0 Then
_WinSetOnTop(0)
If MsgBox(49, "Lodop", "打印控件未安装!点击确定执行安装,安装后请重新打印!") = 1 Then
If FileExists("C:\Lodop\install_lodop32.exe") Then
Run("C:\Lodop\install_lodop32.exe")
_exit()
EndIf
EndIf
_WinSetOnTop(1)
EndIf
If StringInStr($oIE_printText, "打印控件需要升级") > 0 Then
_WinSetOnTop(0)
If MsgBox(49, "Lodop", "打印控件需要升级!点击确定执行升级,安装后请重新打印!") = 1 Then
If FileExists("C:\Lodop\install_lodop32.exe") Then
Run("C:\Lodop\install_lodop32.exe")
_exit()
EndIf
EndIf
_WinSetOnTop(1)
EndIf
If StringInStr($oIE_printText, "未安装打印控件") > 0 Then
_WinSetOnTop(0)
If MsgBox(49, "Lodop", "打印控件未安装!点击确定执行安装,安装后请重新打印!") = 1 Then
If FileExists("C:\Lodop\install_lodop64.exe") Then
Run("C:\Lodop\install_lodop64.exe")
_exit()
EndIf
EndIf
_WinSetOnTop(1)
EndIf
If StringInStr($oIE_printText, "需要升级打印控件") > 0 Then
_WinSetOnTop(0)
If MsgBox(49, "Lodop", "打印控件需要升级!点击确定执行升级,安装后请重新打印!") = 1 Then
If FileExists("C:\Lodop\install_lodop64.exe") Then
Run("C:\Lodop\install_lodop64.exe")
_exit()
EndIf
EndIf
_WinSetOnTop(1)
EndIf
If StringInStr($oIE_printText, "曾安装过Lodop旧版附件") > 0 Then
_WinSetOnTop(0)
If MsgBox(49, "Lodop", '(注意:如曾安装过Lodop旧版附件npActiveXPLugin,请在【工具】->【附加组件】->【扩展】中先卸它)') = 1 Then
EndIf
_WinSetOnTop(1)
EndIf
If StringInStr($oIE_printText, "仅因浏览器升级或重安装而出问题") > 0 Then
_WinSetOnTop(0)
If MsgBox(49, "Lodop", '(如果此前正常,仅因浏览器升级或重安装而出问题,需重新执行以上安装)') = 1 Then
EndIf
_WinSetOnTop(1)
EndIf
EndFunc ;==>PRINT_act
|