DYMO-Printer SDK Wrapper for PureBasic
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

188 rader
4.4 KiB

; if you want to use your version of COMatePLUS include it before include DYMO
;#COMATE_NOINCLUDEATL = #True ; Works, if wanted
;XIncludeFile "COMatePLUS\COMatePLUS_Residents.pbi" ; Include this file too or use IncludePath
;XIncludeFile "COMatePLUS\COMatePLUS.pbi" ; Include COMatePLUS
; include DYMO.pbi !OR! DYMO_DLL.pbi
XIncludeFile "DYMO.pbi" ; use DYMO include (with COMatePLUS)
;XIncludeFile "DYMO_DLL.pbi" ; use DYMO32.dll / DYMO64.dll
EnableExplicit
OpenConsole("DYMO Example")
; Show Objects in current loaded .label
Procedure ShowObjects(VariableOnly = #True)
Protected NrObjects, Object.s, i
NrObjects = DYMO_ExamineObjects(VariableOnly) ; #False = we want to list all object, not only those who can be changed
If NrObjects > 0
For i = 0 To NrObjects - 1
Object = DYMO_NextObject()
PrintN(#TAB$ + "Object: " + Object + " - Value: " + DYMO_GetText(Object))
Next
Else
PrintN("NO Objects found")
EndIf
EndProcedure
Define i
; first of all we have to initialize some things
If Not DYMO_Init()
MessageRequester("Error", "DYMO-Objects couldn't be created!")
End
EndIf
; search and list printer(s)
Define NrPrinters, PName.s
NrPrinters = DYMO_ExaminePrinters()
PrintN("DYMO-Printer found: " + Str(NrPrinters))
; list all printers
If NrPrinters > 0
For i = 0 To NrPrinters - 1
PName = DYMO_NextPrinter()
Print(#TAB$ + "'" + PName + "'")
If DYMO_IsTwinTurboPrinter(PName)
PrintN(" (TwinTurbo)")
Else
PrintN("")
EndIf
Next
Else
PrintN("NO Printers found")
EndIf
PrintN(#LF$)
; select a printer
;DYMO_SelectPrinter("MyDYMOprinter")
; show selected printer
PrintN("Current selected printer: " + DYMO_GetCurrentPrinterName())
Print(#TAB$ + "Selected tray: ")
Select DYMO_GetCurrentPaperTray()
Case #DYMO_Tray_Unknown
PrintN("Unknown")
Case #DYMO_Tray_Right
PrintN("Right")
Case #DYMO_Tray_Left
PrintN("Left")
Case #DYMO_Tray_Auto
PrintN("Auto")
EndSelect
PrintN(#LF$)
; Open label file
#LabelFile = #PB_Compiler_FilePath + "Sample_101x54.label"
If DYMO_OpenLabel(#LabelFile)
PrintN("File <" + #LabelFile + "> loaded")
Else
PrintN("Can't load file <" + #LabelFile + ">")
EndIf
; Open label file from URL
#LabelURL = "file://" + #PB_Compiler_FilePath + "Sample_101x54.label"
If DYMO_OpenLabel(#LabelFile)
PrintN("File from URL <" + #LabelURL + "> loaded")
Else
PrintN("Can't load file from URL <" + #LabelURL + ">")
EndIf
; Show Objects in current loaded .label
ShowObjects(#False) ; #False = we want to list all object, not only those who can be changed
PrintN(#LF$)
; open from memory
Define *Buf, BufSize
*Buf = ?Label_Sample_89x28_Start
BufSize = ?Label_Sample_89x28_End - ?Label_Sample_89x28_Start
If DYMO_OpenMemory(*Buf, BufSize)
PrintN("new label from buffer loaded")
Else
PrintN("Can't load label from buffer")
EndIf
; Show Objects in current loaded .label
ShowObjects()
PrintN(#LF$)
; let's set some new values
DYMO_SetField("CODE39", "NEW39")
DYMO_SetField("TXT", "newText")
DYMO_SetField("EAN8", "8888888")
DYMO_SetField("ADR2", "newAddress2")
DYMO_SetAddress("new Address")
DYMO_SetAddress("new new Address2", 2)
DYMO_SetImageFile("LOGO", "Sample_Logo.bmp")
PrintN("Modified objects")
ShowObjects() ; show new values
PrintN(#LF$)
; print some labels ... uncomment DYMO_PrintLabel() to send to printer
PrintN("Print one label")
;DYMO_PrintLabel()
PrintN("Print one label using right tray")
;DYMO_PrintLabel(1, #DYMO_Tray_Right)
; create more modifications and send all together to printer, as one job
DYMO_SetPrintMode(#False) ; print faster but in lower Quality (for labels with barcode or graphic)
DYMO_StartPrintJob()
For i = 1 To 5
PrintN("Create label nr. " + Str(i))
DYMO_SetField("CODE39", Str(i))
DYMO_SetField("TXT", "more Text")
DYMO_SetField("EAN8", Str(i * 8))
DYMO_SetField("ADR2", "more Address2" + #LF$ + "new line")
DYMO_SetAddress("more Address" + #LF$ + "new line")
DYMO_PrintLabel(1, #DYMO_Tray_Auto, #True) ; Auto switch tray and show print dialog
Next
PrintN("Send job to printer")
;DYMO_StopPrintJob() ; send job to printer, uncomment to send to printer
PrintN(#LF$)
PrintN("Any key to close ...")
Repeat
Until Inkey()
; CleanUp
DYMO_Release()
; Include sample label
DataSection
Label_Sample_89x28_Start:
IncludeBinary "Sample_89x28.label"
Label_Sample_89x28_End:
EndDataSection
; ExecutableFormat = Console
; CursorPosition = 1
; FirstLine = 1
; Folding = -
; CompileSourceDirectory
; EnableCompileCount = 0
; EnableBuildCount = 0
; EnableExeConstant
; EnableUnicode

Impressum | Datenschutz