Qt and USB Thermal Printer
-
@Damian7546
Your application has to be able to find theC56Sdk.dll
at runtime. Either the directory it is in must be added onto yourPATH
environment variable prior to running your executable, or copy it to the directory where your Qt executable is.I do not see a
C56Sdk.dll
in theSdk
folder you showed. I do not thinkC56ApiWrapperDotNet.dll
will do it, plus if that is required you are out of luck because that presumably requires MS .NET and Qt is not a .NET assembly. Is there someC56Sdk.dll
anywhere in the supplied SDK folder hierarchy?@JonB said in Qt and USB Thermal Printer:
@Damian7546
Your application has to be able to find the C56Sdk.dll at runtime. Either the directory it is in must be added onto your PATH environment variable prior to running your executable, or copy it to the directory where your Qt executable is.I copied my SKD directory
Lib\Printer_SDK
from project directory toC:\Users\LENOVO\Documents\qt_proj\build-AutoCash-Desktop_Qt_5_15_2_MSVC2019_32bit-Release
but still it can't find ....@JonB said in Qt and USB Thermal Printer:
I do not see a C56Sdk.dll in the Sdk folder you showed. I do not think C56ApiWrapperDotNet.dll will do it, plus if that is required you are out of luck because that presumably requires MS .NET and Qt is not a .NET assembly. Is there some C56Sdk.dll anywhere in the supplied SDK folder hierarchy?
In my qt project directory I have a SDK in
Lib\Printer_SDK
where are four files:
C56ApiWrapperDotNet.dll
C56Sdk.h
C56Sdk.lib
C56Sdk_x64.lib
-
@JonB said in Qt and USB Thermal Printer:
@Damian7546
Your application has to be able to find the C56Sdk.dll at runtime. Either the directory it is in must be added onto your PATH environment variable prior to running your executable, or copy it to the directory where your Qt executable is.I copied my SKD directory
Lib\Printer_SDK
from project directory toC:\Users\LENOVO\Documents\qt_proj\build-AutoCash-Desktop_Qt_5_15_2_MSVC2019_32bit-Release
but still it can't find ....@JonB said in Qt and USB Thermal Printer:
I do not see a C56Sdk.dll in the Sdk folder you showed. I do not think C56ApiWrapperDotNet.dll will do it, plus if that is required you are out of luck because that presumably requires MS .NET and Qt is not a .NET assembly. Is there some C56Sdk.dll anywhere in the supplied SDK folder hierarchy?
In my qt project directory I have a SDK in
Lib\Printer_SDK
where are four files:
C56ApiWrapperDotNet.dll
C56Sdk.h
C56Sdk.lib
C56Sdk_x64.lib
@Damian7546
Then if the error saysCode execution cannot continue because C56Sdk.dll was not found....
, you don't have that DLL anywhere (and you have looked thoroughly through whatever the download contained), nor even the sources to build it, and you claim there is no documentation for this SDK from the supplier, what would you like me to say here or anywhere else you are asking about this on the web? -
@JonB sorry, my mistake... I was still searching files with *.lib extensions instead *.dll .
In other directory from manufacturer : ("samples") I copied all *.dll files to directory where my Qt app is executable, and success :)
Below required libraries :
C56Sdk.dll
C56Tb.dll
-
@JonB sorry, my mistake... I was still searching files with *.lib extensions instead *.dll .
In other directory from manufacturer : ("samples") I copied all *.dll files to directory where my Qt app is executable, and success :)
Below required libraries :
C56Sdk.dll
C56Tb.dll
@Damian7546
That's why I said you needed to look carefully! :)
Well done! -
@Damian7546 said in Qt and USB Thermal Printer:
When I try run my app I got problems
No, you are not getting as far as running your program at all, are you? The error states it comes from
ld
, which is the linker....You will indeed need the
extern "C" { #include "C56Sdk.h" }
to have that
extern "C"
around it, becauseC56Sdk.h
is in C not C++.You do not say, but since you are using
ld
I would guess you are using MinGW under Windows to compile/link? Meanwhile your early screenshot showsC56Sdk.lib
&C56Sdk_x64.lib
files. But I thought MinGW uses.a
files for libraries? *Are you sure that these libraries aren't for MSVC not MinGW? It would not surprise me if a manufacturer only supplied for MSVC and not MinGW?Since all of this is down to your SDK and not Qt, you should be looking there for solutions. We don't know. Have you read through what the manufacturer's SDK says about which compiler to use?
@JonB said in Qt and USB Thermal Printer:
You do not say, but since you are using ld I would guess you are using MinGW under Windows to compile/link? Meanwhile your early screenshot shows C56Sdk.lib & C56Sdk_x64.lib files. But I thought MinGW uses .a files for libraries? *Are you sure that these libraries aren't for MSVC not MinGW? It would not surprise me if a manufacturer only supplied for MSVC and not MinGW?
When you want to use it with Qt then you have to use the Qt version compiled against MSVC since it looks like the interface only provides a MSVC import lib (C56sdk.lib).
Not that I said it in my first post...
-
@Damian7546 said in Qt and USB Thermal Printer:
It possible using this library in qtcreator ?
Why not? QtCreator is just an IDE, nothing more.
When your library has a c(++) interface (as it loks) you can use this. When you want to use it with Qt then you have to use the Qt version compiled against MSVC since it looks like the interface only provides a MSVC import lib (C56sdk.lib).
You have to read the API documentation for the printer on how to use it.@Christian-Ehrlicher said in Qt and USB Thermal Printer:
When you want to use it with Qt then you have to use the Qt version compiled against MSVC since it looks like the interface only provides a MSVC import lib (C56sdk.lib).
Yep, didn't see you had already written this :)
-
The big problem will be lack of description function in this library.
Below is a example send text to printer:
void CC56SdkDemo01DlgMain::OnBnPrintout() { CComboBox * pPrinterList; // Pointer to combo box item //-- Get printer list (dialog item combo box) if ((pPrinterList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINTER_LIST))) != NULL) { INT iPrinterSel; // Selected printer //-- Determine selected printer if ((iPrinterSel = pPrinterList->GetCurSel()) != CB_ERR) { LPSTR lpszPrinter = NULL; // Printer name //-- Allocate memory for this printer and get name from combo box if ( ((lpszPrinter = (LPSTR) malloc(pPrinterList->GetLBTextLen(iPrinterSel)+1)) != NULL) && (pPrinterList->GetLBText(iPrinterSel, lpszPrinter) != CB_ERR) ) { HANDLE hDocument; // Handle to document //-- Start this document if ((hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")) != NULL) { //-- Add print speed setup to document { CComboBox * pPrintSpeedList; //-- Get dialog item of print speed list if ((pPrintSpeedList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_SPEED))) != NULL) { //-- Set selected print speed switch (pPrintSpeedList->GetCurSel()) { case 0: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_LOW); break; case 1: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; case 2: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_1); break; case 3: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_HIGH); break; default: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; } } } //-- Add print quality setup to document { CComboBox * pPrintQualityList; //-- Get dialog item of print quality list if ((pPrintQualityList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_QUALITY))) != NULL) { //-- Set selected print quality switch (pPrintQualityList->GetCurSel()) { case 0: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; case 1: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_HIGH); break; default: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; } //-- Set impressed energy correction to ... C56Sdk_DcAddImprEnergyCorrection(hDocument, 50); } } //-- Set print mode to 8x16 (for the initial linefeed) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Set initial linefeeds to power up the motor C56Sdk_DcAddLineFeed(hDocument, 1); //-- Add text to print to document { CEdit * pTextToPrint; // Pointer to text to print box //-- Get text to print (dialog item edit box) if ((pTextToPrint = ((CEdit *) this->GetDlgItem(IDC_EDIT_TEXTTOPRINT))) != NULL) { char szTextToPrint[2000+1]; // Buffer for text //-- Get text to print if (pTextToPrint->GetWindowText(szTextToPrint, sizeof(szTextToPrint)-1) > 0) { //-- Set print mode to 8x16 (as initial text) //.. disable reverse printing //.. select primary font //.. etc. etc. etc. { C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); C56Sdk_DcAddDisableReversePrinting(hDocument); C56Sdk_DcAddExtRegCharSet(hDocument, FALSE); } //-- Add "text to print" to document data C56Sdk_DcAddText(hDocument, szTextToPrint); } } } //-- Set print mode to 8x16 (for the final linefeeds) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Add final linefeeds to get text out of the shoot C56Sdk_DcAddLineFeed(hDocument, 50); //-- Print document and get job number m_bJobNr = C56Sdk_DmPrintDocument(hDocument); //-- End of document C56Sdk_DmEndDocument(hDocument); } } //-- Free memory allocated for printer name if (lpszPrinter) free(lpszPrinter); lpszPrinter = NULL; } } }
Some functions can be confused by the name but what is
C56Sdk_DmStartDocument
Can anyone tell me what this function is for:
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
?lpszPrinter
- is a name of printer driver, and hDocument ? -
The big problem will be lack of description function in this library.
Below is a example send text to printer:
void CC56SdkDemo01DlgMain::OnBnPrintout() { CComboBox * pPrinterList; // Pointer to combo box item //-- Get printer list (dialog item combo box) if ((pPrinterList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINTER_LIST))) != NULL) { INT iPrinterSel; // Selected printer //-- Determine selected printer if ((iPrinterSel = pPrinterList->GetCurSel()) != CB_ERR) { LPSTR lpszPrinter = NULL; // Printer name //-- Allocate memory for this printer and get name from combo box if ( ((lpszPrinter = (LPSTR) malloc(pPrinterList->GetLBTextLen(iPrinterSel)+1)) != NULL) && (pPrinterList->GetLBText(iPrinterSel, lpszPrinter) != CB_ERR) ) { HANDLE hDocument; // Handle to document //-- Start this document if ((hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")) != NULL) { //-- Add print speed setup to document { CComboBox * pPrintSpeedList; //-- Get dialog item of print speed list if ((pPrintSpeedList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_SPEED))) != NULL) { //-- Set selected print speed switch (pPrintSpeedList->GetCurSel()) { case 0: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_LOW); break; case 1: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; case 2: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_1); break; case 3: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_HIGH); break; default: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; } } } //-- Add print quality setup to document { CComboBox * pPrintQualityList; //-- Get dialog item of print quality list if ((pPrintQualityList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_QUALITY))) != NULL) { //-- Set selected print quality switch (pPrintQualityList->GetCurSel()) { case 0: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; case 1: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_HIGH); break; default: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; } //-- Set impressed energy correction to ... C56Sdk_DcAddImprEnergyCorrection(hDocument, 50); } } //-- Set print mode to 8x16 (for the initial linefeed) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Set initial linefeeds to power up the motor C56Sdk_DcAddLineFeed(hDocument, 1); //-- Add text to print to document { CEdit * pTextToPrint; // Pointer to text to print box //-- Get text to print (dialog item edit box) if ((pTextToPrint = ((CEdit *) this->GetDlgItem(IDC_EDIT_TEXTTOPRINT))) != NULL) { char szTextToPrint[2000+1]; // Buffer for text //-- Get text to print if (pTextToPrint->GetWindowText(szTextToPrint, sizeof(szTextToPrint)-1) > 0) { //-- Set print mode to 8x16 (as initial text) //.. disable reverse printing //.. select primary font //.. etc. etc. etc. { C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); C56Sdk_DcAddDisableReversePrinting(hDocument); C56Sdk_DcAddExtRegCharSet(hDocument, FALSE); } //-- Add "text to print" to document data C56Sdk_DcAddText(hDocument, szTextToPrint); } } } //-- Set print mode to 8x16 (for the final linefeeds) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Add final linefeeds to get text out of the shoot C56Sdk_DcAddLineFeed(hDocument, 50); //-- Print document and get job number m_bJobNr = C56Sdk_DmPrintDocument(hDocument); //-- End of document C56Sdk_DmEndDocument(hDocument); } } //-- Free memory allocated for printer name if (lpszPrinter) free(lpszPrinter); lpszPrinter = NULL; } } }
Some functions can be confused by the name but what is
C56Sdk_DmStartDocument
Can anyone tell me what this function is for:
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
?lpszPrinter
- is a name of printer driver, and hDocument ?@Damian7546
Your sample code looks like it was writte for MFC class library. Did you try to compile and run it with Visual Studio? MFC is available in there.Besides that the example looks fairly straightforward to decipher.
lpszPrinter
is a printername displayed in the combo box (of the dialog). The type istypedef char* PSTR, *LPSTR;
which can be found here. What content is displayed: I dont know.hDocument
seems to be the internal handle for the data structure for your SDK and represents the "document" you create to send to the printer at the end viaC56Sdk_DmPrintDocument
. After printing you must delete the document viaC56Sdk_DmEndDocument
.C56Sdk_DmStartDocument
seems to initialize "a new page" that can then be prepared and sent to the printer.Aside the MFC class functions the example code seems to be fairly straightforward to be translated to Qt with a little MFC help via google. Even if you dont know MFC you can realize that a combo box is used and
GetCurSel()
for example may return an index to the current selection which is then used accordingly in the following switch to set the SDK document. -
The big problem will be lack of description function in this library.
Below is a example send text to printer:
void CC56SdkDemo01DlgMain::OnBnPrintout() { CComboBox * pPrinterList; // Pointer to combo box item //-- Get printer list (dialog item combo box) if ((pPrinterList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINTER_LIST))) != NULL) { INT iPrinterSel; // Selected printer //-- Determine selected printer if ((iPrinterSel = pPrinterList->GetCurSel()) != CB_ERR) { LPSTR lpszPrinter = NULL; // Printer name //-- Allocate memory for this printer and get name from combo box if ( ((lpszPrinter = (LPSTR) malloc(pPrinterList->GetLBTextLen(iPrinterSel)+1)) != NULL) && (pPrinterList->GetLBText(iPrinterSel, lpszPrinter) != CB_ERR) ) { HANDLE hDocument; // Handle to document //-- Start this document if ((hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")) != NULL) { //-- Add print speed setup to document { CComboBox * pPrintSpeedList; //-- Get dialog item of print speed list if ((pPrintSpeedList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_SPEED))) != NULL) { //-- Set selected print speed switch (pPrintSpeedList->GetCurSel()) { case 0: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_LOW); break; case 1: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; case 2: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_1); break; case 3: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_HIGH); break; default: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; } } } //-- Add print quality setup to document { CComboBox * pPrintQualityList; //-- Get dialog item of print quality list if ((pPrintQualityList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_QUALITY))) != NULL) { //-- Set selected print quality switch (pPrintQualityList->GetCurSel()) { case 0: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; case 1: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_HIGH); break; default: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; } //-- Set impressed energy correction to ... C56Sdk_DcAddImprEnergyCorrection(hDocument, 50); } } //-- Set print mode to 8x16 (for the initial linefeed) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Set initial linefeeds to power up the motor C56Sdk_DcAddLineFeed(hDocument, 1); //-- Add text to print to document { CEdit * pTextToPrint; // Pointer to text to print box //-- Get text to print (dialog item edit box) if ((pTextToPrint = ((CEdit *) this->GetDlgItem(IDC_EDIT_TEXTTOPRINT))) != NULL) { char szTextToPrint[2000+1]; // Buffer for text //-- Get text to print if (pTextToPrint->GetWindowText(szTextToPrint, sizeof(szTextToPrint)-1) > 0) { //-- Set print mode to 8x16 (as initial text) //.. disable reverse printing //.. select primary font //.. etc. etc. etc. { C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); C56Sdk_DcAddDisableReversePrinting(hDocument); C56Sdk_DcAddExtRegCharSet(hDocument, FALSE); } //-- Add "text to print" to document data C56Sdk_DcAddText(hDocument, szTextToPrint); } } } //-- Set print mode to 8x16 (for the final linefeeds) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Add final linefeeds to get text out of the shoot C56Sdk_DcAddLineFeed(hDocument, 50); //-- Print document and get job number m_bJobNr = C56Sdk_DmPrintDocument(hDocument); //-- End of document C56Sdk_DmEndDocument(hDocument); } } //-- Free memory allocated for printer name if (lpszPrinter) free(lpszPrinter); lpszPrinter = NULL; } } }
Some functions can be confused by the name but what is
C56Sdk_DmStartDocument
Can anyone tell me what this function is for:
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
?lpszPrinter
- is a name of printer driver, and hDocument ?@Damian7546 said in Qt and USB Thermal Printer:
Can anyone tell me what this function is for:
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
?Have you looked at the definition in the header file? what are the variable names in there?
-
I downloaded Hengstler's windows driver with the SDK and in the header file it is quite obvious that
Dm
functions are Document Manager functions,Dc
functions belong to the document.You should be able to get the printer name from above via one of those functions:
HANDLE WINAPI C56Sdk_PmStartEnumPrinter (VOID); VOID WINAPI C56Sdk_PmEndEnumPrinter (HANDLE hPrinter); LPSTR WINAPI C56Sdk_PmEnumPrinter (HANDLE hPrinter, BOOL fReset); BOOL WINAPI C56Sdk_PmEnumPrinterName (HANDLE hPrinter, char * pszBuff, WORD wBuffSize, BOOL fReset);
-
Wouldn't it be better to ask the vendor of this library instead? I mean - you bought it from them so they have to give support. We can only do wild guessing...
-
Wouldn't it be better to ask the vendor of this library instead? I mean - you bought it from them so they have to give support. We can only do wild guessing...
@Christian-Ehrlicher The driver/sdk is free, it contains exe binaries of the examples and the source code. I is only MFC or .NET code that needs to be read. It shouldn't be too difficult.
-
The big problem will be lack of description function in this library.
Below is a example send text to printer:
void CC56SdkDemo01DlgMain::OnBnPrintout() { CComboBox * pPrinterList; // Pointer to combo box item //-- Get printer list (dialog item combo box) if ((pPrinterList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINTER_LIST))) != NULL) { INT iPrinterSel; // Selected printer //-- Determine selected printer if ((iPrinterSel = pPrinterList->GetCurSel()) != CB_ERR) { LPSTR lpszPrinter = NULL; // Printer name //-- Allocate memory for this printer and get name from combo box if ( ((lpszPrinter = (LPSTR) malloc(pPrinterList->GetLBTextLen(iPrinterSel)+1)) != NULL) && (pPrinterList->GetLBText(iPrinterSel, lpszPrinter) != CB_ERR) ) { HANDLE hDocument; // Handle to document //-- Start this document if ((hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")) != NULL) { //-- Add print speed setup to document { CComboBox * pPrintSpeedList; //-- Get dialog item of print speed list if ((pPrintSpeedList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_SPEED))) != NULL) { //-- Set selected print speed switch (pPrintSpeedList->GetCurSel()) { case 0: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_LOW); break; case 1: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; case 2: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_1); break; case 3: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_HIGH); break; default: C56Sdk_DcAddPrintSpeed(hDocument, C56PS_MEDIUM_2); break; } } } //-- Add print quality setup to document { CComboBox * pPrintQualityList; //-- Get dialog item of print quality list if ((pPrintQualityList = ((CComboBox *) this->GetDlgItem(IDC_COMBO_PRINT_QUALITY))) != NULL) { //-- Set selected print quality switch (pPrintQualityList->GetCurSel()) { case 0: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; case 1: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_HIGH); break; default: C56Sdk_DcAddPrintQuality(hDocument, C56PQ_LOW); break; } //-- Set impressed energy correction to ... C56Sdk_DcAddImprEnergyCorrection(hDocument, 50); } } //-- Set print mode to 8x16 (for the initial linefeed) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Set initial linefeeds to power up the motor C56Sdk_DcAddLineFeed(hDocument, 1); //-- Add text to print to document { CEdit * pTextToPrint; // Pointer to text to print box //-- Get text to print (dialog item edit box) if ((pTextToPrint = ((CEdit *) this->GetDlgItem(IDC_EDIT_TEXTTOPRINT))) != NULL) { char szTextToPrint[2000+1]; // Buffer for text //-- Get text to print if (pTextToPrint->GetWindowText(szTextToPrint, sizeof(szTextToPrint)-1) > 0) { //-- Set print mode to 8x16 (as initial text) //.. disable reverse printing //.. select primary font //.. etc. etc. etc. { C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); C56Sdk_DcAddDisableReversePrinting(hDocument); C56Sdk_DcAddExtRegCharSet(hDocument, FALSE); } //-- Add "text to print" to document data C56Sdk_DcAddText(hDocument, szTextToPrint); } } } //-- Set print mode to 8x16 (for the final linefeeds) C56Sdk_DcAddPrintMode(hDocument, C56PM_FONT_08X16); //-- Add final linefeeds to get text out of the shoot C56Sdk_DcAddLineFeed(hDocument, 50); //-- Print document and get job number m_bJobNr = C56Sdk_DmPrintDocument(hDocument); //-- End of document C56Sdk_DmEndDocument(hDocument); } } //-- Free memory allocated for printer name if (lpszPrinter) free(lpszPrinter); lpszPrinter = NULL; } } }
Some functions can be confused by the name but what is
C56Sdk_DmStartDocument
Can anyone tell me what this function is for:
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
?lpszPrinter
- is a name of printer driver, and hDocument ?@Damian7546
C56SdkDemo01
example shows how to enumerate the printers inBOOL CC56SdkDemo01DlgMain::OnInitDialog
. -
@DerReisende I have a printer name , I published my calss , which one return printer name:
#include "c56sdkapp.h" #include <QDebug> C56SdkApp::C56SdkApp() { } void C56SdkApp::AvailablePrinters() { QString lpszPrinter; // Name of printer HANDLE hEnumPrinter; // Handle for enumeration //-- Start access SDK to go through all C-56 printers if ((hEnumPrinter = C56Sdk_PmStartEnumPrinter()) != NULL) { //-- Go through all C-56 printers for ( lpszPrinter = C56Sdk_PmEnumPrinter(hEnumPrinter, TRUE); lpszPrinter != NULL ; lpszPrinter = C56Sdk_PmEnumPrinter(hEnumPrinter, FALSE)) { //-- List printer to console qDebug()<< "Printer:" << lpszPrinter; } } }
but I askd about
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
I read name printer, but I do not know what is the second parametr"C56SdkDemo01"
To run any function we need hDocument, what is it ? -
@DerReisende I have a printer name , I published my calss , which one return printer name:
#include "c56sdkapp.h" #include <QDebug> C56SdkApp::C56SdkApp() { } void C56SdkApp::AvailablePrinters() { QString lpszPrinter; // Name of printer HANDLE hEnumPrinter; // Handle for enumeration //-- Start access SDK to go through all C-56 printers if ((hEnumPrinter = C56Sdk_PmStartEnumPrinter()) != NULL) { //-- Go through all C-56 printers for ( lpszPrinter = C56Sdk_PmEnumPrinter(hEnumPrinter, TRUE); lpszPrinter != NULL ; lpszPrinter = C56Sdk_PmEnumPrinter(hEnumPrinter, FALSE)) { //-- List printer to console qDebug()<< "Printer:" << lpszPrinter; } } }
but I askd about
hDocument = C56Sdk_DmStartDocument(lpszPrinter, "C56SdkDemo01")
I read name printer, but I do not know what is the second parametr"C56SdkDemo01"
To run any function we need hDocument, what is it ?@Damian7546 Why dont you look at the other samples?
lpszDocument
seems to be just a name for the document as it changes in all other examples as well. And by trial and error setting it to "whateverIwanttonamemydocument" this should work as well.What is a HANDLE? See https://stackoverflow.com/questions/902967/what-is-a-windows-handle for explanation and https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types for the definition. Basically it is a
void*
to a structure that is used internally. What is inside this structure is irrelevant as you have multiple functions to properly manipulate it.I can't see any problems that will prevent you from using the Sdk. Even at beginner level with all the examples it looks fairly simple to write a small demo to print something and then extend on the knowledge. Or as @Christian-Ehrlicher said: Maybe ask the vendor as I dont have such a printer but even with example 01 I really think I would be able to print a hello world on it and extend this behaviour.
-
@Damian7546 Why dont you look at the other samples?
lpszDocument
seems to be just a name for the document as it changes in all other examples as well. And by trial and error setting it to "whateverIwanttonamemydocument" this should work as well.What is a HANDLE? See https://stackoverflow.com/questions/902967/what-is-a-windows-handle for explanation and https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types for the definition. Basically it is a
void*
to a structure that is used internally. What is inside this structure is irrelevant as you have multiple functions to properly manipulate it.I can't see any problems that will prevent you from using the Sdk. Even at beginner level with all the examples it looks fairly simple to write a small demo to print something and then extend on the knowledge. Or as @Christian-Ehrlicher said: Maybe ask the vendor as I dont have such a printer but even with example 01 I really think I would be able to print a hello world on it and extend this behaviour.
@DerReisende said in Qt and USB Thermal Printer:
And by trial and error setting it to "whateverIwanttonamemydocument" this should work as well.
You are right
-
@Damian7546 Why dont you look at the other samples?
lpszDocument
seems to be just a name for the document as it changes in all other examples as well. And by trial and error setting it to "whateverIwanttonamemydocument" this should work as well.What is a HANDLE? See https://stackoverflow.com/questions/902967/what-is-a-windows-handle for explanation and https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types for the definition. Basically it is a
void*
to a structure that is used internally. What is inside this structure is irrelevant as you have multiple functions to properly manipulate it.I can't see any problems that will prevent you from using the Sdk. Even at beginner level with all the examples it looks fairly simple to write a small demo to print something and then extend on the knowledge. Or as @Christian-Ehrlicher said: Maybe ask the vendor as I dont have such a printer but even with example 01 I really think I would be able to print a hello world on it and extend this behaviour.
This post is deleted! -
This post is deleted!