DYMO-Printer SDK Wrapper for PureBasic
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
4.4 KiB

  1. ; if you want to use your version of COMatePLUS include it before include DYMO
  2. ;#COMATE_NOINCLUDEATL = #True ; Works, if wanted
  3. ;XIncludeFile "COMatePLUS\COMatePLUS_Residents.pbi" ; Include this file too or use IncludePath
  4. ;XIncludeFile "COMatePLUS\COMatePLUS.pbi" ; Include COMatePLUS
  5. ; include DYMO.pbi !OR! DYMO_DLL.pbi
  6. XIncludeFile "DYMO.pbi" ; use DYMO include (with COMatePLUS)
  7. ;XIncludeFile "DYMO_DLL.pbi" ; use DYMO32.dll / DYMO64.dll
  8. EnableExplicit
  9. OpenConsole("DYMO Example")
  10. ; Show Objects in current loaded .label
  11. Procedure ShowObjects(VariableOnly = #True)
  12. Protected NrObjects, Object.s, i
  13. NrObjects = DYMO_ExamineObjects(VariableOnly) ; #False = we want to list all object, not only those who can be changed
  14. If NrObjects > 0
  15. For i = 0 To NrObjects - 1
  16. Object = DYMO_NextObject()
  17. PrintN(#TAB$ + "Object: " + Object + " - Value: " + DYMO_GetText(Object))
  18. Next
  19. Else
  20. PrintN("NO Objects found")
  21. EndIf
  22. EndProcedure
  23. Define i
  24. ; first of all we have to initialize some things
  25. If Not DYMO_Init()
  26. MessageRequester("Error", "DYMO-Objects couldn't be created!")
  27. End
  28. EndIf
  29. ; search and list printer(s)
  30. Define NrPrinters, PName.s
  31. NrPrinters = DYMO_ExaminePrinters()
  32. PrintN("DYMO-Printer found: " + Str(NrPrinters))
  33. ; list all printers
  34. If NrPrinters > 0
  35. For i = 0 To NrPrinters - 1
  36. PName = DYMO_NextPrinter()
  37. Print(#TAB$ + "'" + PName + "'")
  38. If DYMO_IsTwinTurboPrinter(PName)
  39. PrintN(" (TwinTurbo)")
  40. Else
  41. PrintN("")
  42. EndIf
  43. Next
  44. Else
  45. PrintN("NO Printers found")
  46. EndIf
  47. PrintN(#LF$)
  48. ; select a printer
  49. ;DYMO_SelectPrinter("MyDYMOprinter")
  50. ; show selected printer
  51. PrintN("Current selected printer: " + DYMO_GetCurrentPrinterName())
  52. Print(#TAB$ + "Selected tray: ")
  53. Select DYMO_GetCurrentPaperTray()
  54. Case #DYMO_Tray_Unknown
  55. PrintN("Unknown")
  56. Case #DYMO_Tray_Right
  57. PrintN("Right")
  58. Case #DYMO_Tray_Left
  59. PrintN("Left")
  60. Case #DYMO_Tray_Auto
  61. PrintN("Auto")
  62. EndSelect
  63. PrintN(#LF$)
  64. ; Open label file
  65. #LabelFile = #PB_Compiler_FilePath + "Sample_101x54.label"
  66. If DYMO_OpenLabel(#LabelFile)
  67. PrintN("File <" + #LabelFile + "> loaded")
  68. Else
  69. PrintN("Can't load file <" + #LabelFile + ">")
  70. EndIf
  71. ; Open label file from URL
  72. #LabelURL = "file://" + #PB_Compiler_FilePath + "Sample_101x54.label"
  73. If DYMO_OpenLabel(#LabelFile)
  74. PrintN("File from URL <" + #LabelURL + "> loaded")
  75. Else
  76. PrintN("Can't load file from URL <" + #LabelURL + ">")
  77. EndIf
  78. ; Show Objects in current loaded .label
  79. ShowObjects(#False) ; #False = we want to list all object, not only those who can be changed
  80. PrintN(#LF$)
  81. ; open from memory
  82. Define *Buf, BufSize
  83. *Buf = ?Label_Sample_89x28_Start
  84. BufSize = ?Label_Sample_89x28_End - ?Label_Sample_89x28_Start
  85. If DYMO_OpenMemory(*Buf, BufSize)
  86. PrintN("new label from buffer loaded")
  87. Else
  88. PrintN("Can't load label from buffer")
  89. EndIf
  90. ; Show Objects in current loaded .label
  91. ShowObjects()
  92. PrintN(#LF$)
  93. ; let's set some new values
  94. DYMO_SetField("CODE39", "NEW39")
  95. DYMO_SetField("TXT", "newText")
  96. DYMO_SetField("EAN8", "8888888")
  97. DYMO_SetField("ADR2", "newAddress2")
  98. DYMO_SetAddress("new Address")
  99. DYMO_SetAddress("new new Address2", 2)
  100. DYMO_SetImageFile("LOGO", "Sample_Logo.bmp")
  101. PrintN("Modified objects")
  102. ShowObjects() ; show new values
  103. PrintN(#LF$)
  104. ; print some labels ... uncomment DYMO_PrintLabel() to send to printer
  105. PrintN("Print one label")
  106. ;DYMO_PrintLabel()
  107. PrintN("Print one label using right tray")
  108. ;DYMO_PrintLabel(1, #DYMO_Tray_Right)
  109. ; create more modifications and send all together to printer, as one job
  110. DYMO_SetPrintMode(#False) ; print faster but in lower Quality (for labels with barcode or graphic)
  111. DYMO_StartPrintJob()
  112. For i = 1 To 5
  113. PrintN("Create label nr. " + Str(i))
  114. DYMO_SetField("CODE39", Str(i))
  115. DYMO_SetField("TXT", "more Text")
  116. DYMO_SetField("EAN8", Str(i * 8))
  117. DYMO_SetField("ADR2", "more Address2" + #LF$ + "new line")
  118. DYMO_SetAddress("more Address" + #LF$ + "new line")
  119. DYMO_PrintLabel(1, #DYMO_Tray_Auto, #True) ; Auto switch tray and show print dialog
  120. Next
  121. PrintN("Send job to printer")
  122. ;DYMO_StopPrintJob() ; send job to printer, uncomment to send to printer
  123. PrintN(#LF$)
  124. PrintN("Any key to close ...")
  125. Repeat
  126. Until Inkey()
  127. ; CleanUp
  128. DYMO_Release()
  129. ; Include sample label
  130. DataSection
  131. Label_Sample_89x28_Start:
  132. IncludeBinary "Sample_89x28.label"
  133. Label_Sample_89x28_End:
  134. EndDataSection
  135. ; ExecutableFormat = Console
  136. ; CursorPosition = 1
  137. ; FirstLine = 1
  138. ; Folding = -
  139. ; CompileSourceDirectory
  140. ; EnableCompileCount = 0
  141. ; EnableBuildCount = 0
  142. ; EnableExeConstant
  143. ; EnableUnicode

Impressum | Datenschutz