Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt and USB Thermal Printer
Forum Updated to NodeBB v4.3 + New Features

Qt and USB Thermal Printer

Scheduled Pinned Locked Moved Solved General and Desktop
37 Posts 6 Posters 5.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Christian EhrlicherC Christian Ehrlicher

    @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.

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #25

    @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 :)

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Damian7546
      wrote on last edited by Damian7546
      #26

      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 ?

      D 3 Replies Last reply
      0
      • D Damian7546

        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 ?

        D Offline
        D Offline
        DerReisende
        wrote on last edited by
        #27

        @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 is typedef 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 via C56Sdk_DmPrintDocument. After printing you must delete the document via C56Sdk_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.

        1 Reply Last reply
        1
        • D Damian7546

          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 ?

          D Offline
          D Offline
          DerReisende
          wrote on last edited by
          #28

          @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?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DerReisende
            wrote on last edited by DerReisende
            #29

            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);
            
            1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #30

              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...

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              D 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                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...

                D Offline
                D Offline
                DerReisende
                wrote on last edited by
                #31

                @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.

                1 Reply Last reply
                0
                • D Damian7546

                  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 ?

                  D Offline
                  D Offline
                  DerReisende
                  wrote on last edited by
                  #32

                  @Damian7546 C56SdkDemo01 example shows how to enumerate the printers in BOOL CC56SdkDemo01DlgMain::OnInitDialog.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    Damian7546
                    wrote on last edited by Damian7546
                    #33

                    @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 ?

                    D 1 Reply Last reply
                    0
                    • D Damian7546

                      @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 ?

                      D Offline
                      D Offline
                      DerReisende
                      wrote on last edited by DerReisende
                      #34

                      @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.

                      D 2 Replies Last reply
                      0
                      • D DerReisende

                        @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.

                        D Offline
                        D Offline
                        Damian7546
                        wrote on last edited by Damian7546
                        #35

                        @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

                        1 Reply Last reply
                        0
                        • D DerReisende

                          @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.

                          D Offline
                          D Offline
                          Damian7546
                          wrote on last edited by Damian7546
                          #36
                          This post is deleted!
                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            kunoichi15901
                            wrote on last edited by
                            #37
                            This post is deleted!
                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved