3. 打印
進行(xíng)相關參數(shù)設置後(指定打印機,設置模闆,設置打印數(shù)據),将指令通(tōng)過API傳給打印機。
'定義參數(shù) 數(shù)組
Dim cfgPrintSettings(40) As String
'ItemID
cfgPrintSettings(0) = m_ItemId
'ItemUID
cfgPrintSettings(1) = m_ItemUID
'ItemFUID
cfgPrintSettings(2) = m_ItemFUID
'UseDefaultPrinter
cfgPrintSettings(3) = "0"
'********************************************************************************************************************
'PrinterName 指定打印機名稱
cfgPrintSettings(4) = "Deli DL-888C"
'NotUsePagesettings
cfgPrintSettings(5) = "0"
'0-打印,3-獲取打印預覽
cfgPrintSettings(6) = "0"
'********************************************************************************************************************
'TemplateMode 模闆方式,0-客戶端模闆,1-遠程模闆,2-如果本地模闆存在,使用本地,不存在使用遠程模闆
cfgPrintSettings(7) = "1"
'TemplateURL 遠程模闆URL
cfgPrintSettings(8) = "http://img.51321.cn/web/chicore/VPrinting/API"
'cfgPrintSettings(8) = "d:\\TEMP"
'TemplateName 模闆文件名
cfgPrintSettings(9) = "987.Lblx"
'不使用模闆時(shí),自繪制(zhì)
cfgPrintSettings(10) = ""
'打印數(shù)據的類型,0-數(shù)組,1-Json數(shù)組,元素為(wèi)JSON對象,字段:值
cfgPrintSettings(11) = "1"
'打印數(shù)據
cfgPrintSettings(12) = "[{Field1:""1122344234"", Field2:""4瓶x52"",Field3:""901201251002404"", Field4:""325435""},{Field1:""1122344235"", Field2:""4瓶x52"",Field3:""901201251002405"", Field4:""325488""},{Field1:""1122344235"", Field2:""4瓶x52"",Field3:""901201251002405"", Field4:""325488""}]"
'打印內(nèi)容允許,半角逗号1-允許,0-不允許, JSON數(shù)組傳入數(shù)據時(shí),無效
cfgPrintSettings(13) = "1"
'數(shù)據的字段分隔符
cfgPrintSettings(14) = ";"
'********************************************************************************************************************
'打印範圍,0-所有(yǒu)頁,2-指定頁碼
cfgPrintSettings(15) = "0"
'指定頁碼時(shí),開(kāi)始頁碼
cfgPrintSettings(16) = "1"
'指定頁碼時(shí),結束頁碼
cfgPrintSettings(17) = "1"
'打印份數(shù)
cfgPrintSettings(18) = "1"
'是否逐份打印,0-否,1-是
cfgPrintSettings(19) = "0"
'PrintToStop
cfgPrintSettings(20) = "0"
'Save
cfgPrintSettings(21) = "0"
'雙面打印 -1 使用打印機默認的雙面設置,1 - 單面打印
cfgPrintSettings(22) = "1"
'0 自定義, 1 按名稱(如果沒有(yǒu)則自定義) ,2 按尺寸內(nèi)建紙張,尺寸必須完全相等(如果沒有(yǒu)則自定義) ,3 按內(nèi)建紙張ID (如果沒有(yǒu)則自定義)
cfgPrintSettings(23) = "0"
'按名稱時(shí)的,紙張名稱
cfgPrintSettings(24) = ""
'打印SessionId
cfgPrintSettings(25) = ""
'EnableLog
cfgPrintSettings(26) = "0"
'按指令順序打印
cfgPrintSettings(27) = "1"
Dim hr As String
'進行(xíng)打印
hr = ccprintapi.CCPrintExSync(cfgPrintSettings)