Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. printing the customized data through printer in vc++ 6.0 dialog based.

printing the customized data through printer in vc++ 6.0 dialog based.

Scheduled Pinned Locked Moved Managed C++/CLI
c++help
17 Posts 3 Posters 38 Views 1 Watching
  • 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.
  • U User 13192079

    I am trying to print some data from my application.It is printing the data but the page is not coming out of the printer.Please help me on this.

    HANDLE hPrinter;
    DOC_INFO_1 DocInfo;
    DWORD dwJob;
    DWORD dwBytesWritten;

    	char \*lpData="welcome to delopt";
    
    
        
    	char \*szPrinterName="CUSTOM TG2460-H";
        if( ! OpenPrinter( szPrinterName, &hPrinter, NULL ) )
          return ;
        
        DocInfo.pDocName = "My Document";
        DocInfo.pOutputFile = NULL;
        DocInfo.pDatatype = "RAW";
        
        if( (dwJob = StartDocPrinter( hPrinter, 1, (unsigned char\*)(LPSTR)&DocInfo )) == 0 )
        {
          ClosePrinter( hPrinter );
          return;
        }
        
        if( ! StartPagePrinter( hPrinter ) )
        {
          EndDocPrinter( hPrinter );
          ClosePrinter( hPrinter );
          return;
        }
        
    	int dwCount=19;
        if( !WritePrinter( hPrinter, lpData, dwCount, &dwBytesWritten ) )
        {
          EndPagePrinter( hPrinter );
          EndDocPrinter( hPrinter );
          ClosePrinter( hPrinter );
          return;
        }
    
        .
    	
        if( ! EndPagePrinter( hPrinter ) )
        {
          EndDocPrinter( hPrinter );
          ClosePrinter( hPrinter );
          return;
       
    	}
        
        if( ! EndDocPrinter( hPrinter ) )
        {
          ClosePrinter( hPrinter );
          return;
        }
        
        
       
        if( dwBytesWritten != dwCount )
          return;
    	ClosePrinter( hPrinter );
        return;
    

    this is for dialog based application.

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    You do not call EndDocPrinter function (Windows)[^] to terminate the job.

    R 1 Reply Last reply
    0
    • L Lost User

      You do not call EndDocPrinter function (Windows)[^] to terminate the job.

      R Offline
      R Offline
      rahul1995
      wrote on last edited by
      #3

      I have commented that but still the same. i will explain it once again. see when i am executing the come then after clicking on the button it is printing the message but print is not coming out of the printer. It is printing the message on the paper but the paper is not coming out of printer it is just printing the text and stopping at that particular point only.

      L 1 Reply Last reply
      0
      • R rahul1995

        I have commented that but still the same. i will explain it once again. see when i am executing the come then after clicking on the button it is printing the message but print is not coming out of the printer. It is printing the message on the paper but the paper is not coming out of printer it is just printing the text and stopping at that particular point only.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #4

        You need to use your debugger to step through the code and check exactly which of the spooler functions get called, and in which order.

        R 1 Reply Last reply
        0
        • L Lost User

          You need to use your debugger to step through the code and check exactly which of the spooler functions get called, and in which order.

          R Offline
          R Offline
          rahul1995
          wrote on last edited by
          #5

          there is only one spooler function is there in the code right n if i am wrong please explain it as for the first time i am doing that i dnt have much idea about that.

          L 3 Replies Last reply
          0
          • R rahul1995

            there is only one spooler function is there in the code right n if i am wrong please explain it as for the first time i am doing that i dnt have much idea about that.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #6

            Sorry, I have not used the spooler functions before so cannot offer any further suggestions. You could try a Google search to see if anyone has written a tutorial on the subject.

            1 Reply Last reply
            0
            • R rahul1995

              there is only one spooler function is there in the code right n if i am wrong please explain it as for the first time i am doing that i dnt have much idea about that.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #7

              See the answers at Windows: How to tell printer to issue a FormFeed during printing? - Stack Overflow[^].

              1 Reply Last reply
              0
              • R rahul1995

                there is only one spooler function is there in the code right n if i am wrong please explain it as for the first time i am doing that i dnt have much idea about that.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #8

                I just tried this on my local printer using TEXT mode rather than RAW and it works correctly.

                R 2 Replies Last reply
                0
                • L Lost User

                  I just tried this on my local printer using TEXT mode rather than RAW and it works correctly.

                  R Offline
                  R Offline
                  rahul1995
                  wrote on last edited by
                  #9

                  Thank you its working just one more help can u tell me how i can format the page which i want to print.for example: name : XYZ age : 19 . . . etc.

                  L 1 Reply Last reply
                  0
                  • L Lost User

                    I just tried this on my local printer using TEXT mode rather than RAW and it works correctly.

                    R Offline
                    R Offline
                    rahul1995
                    wrote on last edited by
                    #10

                    right now i it printing like name : xyz age : 19 but i want like this name : xyz age : 19 how do i format that

                    1 Reply Last reply
                    0
                    • R rahul1995

                      Thank you its working just one more help can u tell me how i can format the page which i want to print.for example: name : XYZ age : 19 . . . etc.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #11

                      You need to put the newline characters at the end of each string thus:

                      "This is line 1\r\n"
                      "This is line 2\r\n"
                      etc.

                      However, you would get better results by doing proper GDI based printing where you can format your pages properly.

                      R 1 Reply Last reply
                      0
                      • L Lost User

                        You need to put the newline characters at the end of each string thus:

                        "This is line 1\r\n"
                        "This is line 2\r\n"
                        etc.

                        However, you would get better results by doing proper GDI based printing where you can format your pages properly.

                        R Offline
                        R Offline
                        rahul1995
                        wrote on last edited by
                        #12

                        what i should do for formatting the page like font size,font type , print quality and how many character should be printed in that particular line.

                        L 1 Reply Last reply
                        0
                        • R rahul1995

                          what i should do for formatting the page like font size,font type , print quality and how many character should be printed in that particular line.

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #13

                          See GDI Print API (Windows)[^].

                          R 1 Reply Last reply
                          0
                          • L Lost User

                            See GDI Print API (Windows)[^].

                            R Offline
                            R Offline
                            rahul1995
                            wrote on last edited by
                            #14

                            who i can improve the print quality because the print which it is giving out is very light.

                            L 1 Reply Last reply
                            0
                            • R rahul1995

                              who i can improve the print quality because the print which it is giving out is very light.

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #15

                              Like I already told you, you will have to use proper GDI printing. Alternatively, if you know postscript and your printer supports it (which it should), you can use that and send as raw data.

                              R 1 Reply Last reply
                              0
                              • L Lost User

                                Like I already told you, you will have to use proper GDI printing. Alternatively, if you know postscript and your printer supports it (which it should), you can use that and send as raw data.

                                R Offline
                                R Offline
                                rahul1995
                                wrote on last edited by
                                #16

                                i have checked that but i have not god anything regarding the formatting of text and increasing the pixel density.

                                L 1 Reply Last reply
                                0
                                • R rahul1995

                                  i have checked that but i have not god anything regarding the formatting of text and increasing the pixel density.

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #17

                                  You need to use the Device Context GDI/GDI+ functions as described in Legacy Graphics (Windows)[^].

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups