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. C / C++ / MFC
  4. Choosing a printer and init printing...

Choosing a printer and init printing...

Scheduled Pinned Locked Moved C / C++ / MFC
question
14 Posts 2 Posters 0 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.
  • C Offline
    C Offline
    Cris
    wrote on last edited by
    #1

    Hello, I need to choose a printer and init printing a document(saved on my disk), whithout a print dialog. How can I do this? []'s

    H 1 Reply Last reply
    0
    • C Cris

      Hello, I need to choose a printer and init printing a document(saved on my disk), whithout a print dialog. How can I do this? []'s

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Hope I understood your question LPPRINTER_INFO_2 m_pPrinters; LPDEVMODE m_lpdevmode; ... ... HDC hdc=CreateDC(m_pPrinters->pDriverName, (LPCTSTR)m_lpdevmode->dmDeviceName,m_pPrinters->pPortName,m_lpdevmode);_**


      **_

      whitesky


      C 1 Reply Last reply
      0
      • H Hamid Taebi

        Hope I understood your question LPPRINTER_INFO_2 m_pPrinters; LPDEVMODE m_lpdevmode; ... ... HDC hdc=CreateDC(m_pPrinters->pDriverName, (LPCTSTR)m_lpdevmode->dmDeviceName,m_pPrinters->pPortName,m_lpdevmode);_**


        **_

        whitesky


        C Offline
        C Offline
        Cris
        wrote on last edited by
        #3

        Thanks for your help. I have a printer device and a file name on hard disc. How can start a print job passing these parameters (printer and file name)? []'s

        H 1 Reply Last reply
        0
        • C Cris

          Thanks for your help. I have a printer device and a file name on hard disc. How can start a print job passing these parameters (printer and file name)? []'s

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          sorry i dont understand,you have a printer ok and you have a file in your disc now you want to print this file,yes?_**


          **_

          whitesky


          C 1 Reply Last reply
          0
          • H Hamid Taebi

            sorry i dont understand,you have a printer ok and you have a file in your disc now you want to print this file,yes?_**


            **_

            whitesky


            C Offline
            C Offline
            Cris
            wrote on last edited by
            #5

            That's right. I need to do this programatically.

            H 1 Reply Last reply
            0
            • C Cris

              That's right. I need to do this programatically.

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              when you have a hdc from printer(CreateDC)then you can read from your file in the loop and use StartPage and StartDoc use TextOutor DrawText for write to printer and the end EndPage and EndDoc (you need to check if your file is > from a page) I hope its helpful for you

              _**


              **_

              whitesky


              C 1 Reply Last reply
              0
              • H Hamid Taebi

                when you have a hdc from printer(CreateDC)then you can read from your file in the loop and use StartPage and StartDoc use TextOutor DrawText for write to printer and the end EndPage and EndDoc (you need to check if your file is > from a page) I hope its helpful for you

                _**


                **_

                whitesky


                C Offline
                C Offline
                Cris
                wrote on last edited by
                #7

                But my file can be any format, not only text file. I need to print a image too. Any other idea? []'s

                H 1 Reply Last reply
                0
                • C Cris

                  But my file can be any format, not only text file. I need to print a image too. Any other idea? []'s

                  H Offline
                  H Offline
                  Hamid Taebi
                  wrote on last edited by
                  #8

                  if you need to print a image you can draw image to dc from printer you can open your file(Image) and use from handle printer for print it.(if you have a hdc you ability to print image or text its not only for printer i think that windows programming is work with handles) I hope its helpful to you

                  _**


                  **_

                  whitesky


                  C 2 Replies Last reply
                  0
                  • H Hamid Taebi

                    if you need to print a image you can draw image to dc from printer you can open your file(Image) and use from handle printer for print it.(if you have a hdc you ability to print image or text its not only for printer i think that windows programming is work with handles) I hope its helpful to you

                    _**


                    **_

                    whitesky


                    C Offline
                    C Offline
                    Cris
                    wrote on last edited by
                    #9

                    But this file can be a .DOC file, with image included and formatted texts (bold, italic,...), then I need to build a app that the user select any file and OK. The app should send the file to a postscript printer for convert to .PS format. Can I do this, only with my app?

                    1 Reply Last reply
                    0
                    • H Hamid Taebi

                      if you need to print a image you can draw image to dc from printer you can open your file(Image) and use from handle printer for print it.(if you have a hdc you ability to print image or text its not only for printer i think that windows programming is work with handles) I hope its helpful to you

                      _**


                      **_

                      whitesky


                      C Offline
                      C Offline
                      Cris
                      wrote on last edited by
                      #10

                      It's not possible. An app cannot print a document from disc directly to printer. I should do this with the app that can read the document. :-( Thanks for your atention. []'s

                      H 1 Reply Last reply
                      0
                      • C Cris

                        It's not possible. An app cannot print a document from disc directly to printer. I should do this with the app that can read the document. :-( Thanks for your atention. []'s

                        H Offline
                        H Offline
                        Hamid Taebi
                        wrote on last edited by
                        #11

                        When you have each file (psd,3d,pdf,txt,...)first you need to read file for example a jpg file you can use from a class CImage or GDI+ or you can read directly after read you want to print (for example you need to print a psd file(photoshop) you cant use from a function for read you and print you need to a structure for read this file and convert it to a for example hbtimap(you can see a example from read psd files in codeproject) and then you can print this file.now you want to print doc file its like this you need to read this file and convert a foramt for print A app cannot to print a file from disc directly its right you need to read to file and above

                        _**


                        **_

                        WhiteSky


                        C 1 Reply Last reply
                        0
                        • H Hamid Taebi

                          When you have each file (psd,3d,pdf,txt,...)first you need to read file for example a jpg file you can use from a class CImage or GDI+ or you can read directly after read you want to print (for example you need to print a psd file(photoshop) you cant use from a function for read you and print you need to a structure for read this file and convert it to a for example hbtimap(you can see a example from read psd files in codeproject) and then you can print this file.now you want to print doc file its like this you need to read this file and convert a foramt for print A app cannot to print a file from disc directly its right you need to read to file and above

                          _**


                          **_

                          WhiteSky


                          C Offline
                          C Offline
                          Cris
                          wrote on last edited by
                          #12

                          The problem is also build a rotine for each file format.

                          H 1 Reply Last reply
                          0
                          • C Cris

                            The problem is also build a rotine for each file format.

                            H Offline
                            H Offline
                            Hamid Taebi
                            wrote on last edited by
                            #13

                            I suggest if you search in internet you can find activexes for your purpose

                            _**


                            **_

                            WhiteSky


                            C 1 Reply Last reply
                            0
                            • H Hamid Taebi

                              I suggest if you search in internet you can find activexes for your purpose

                              _**


                              **_

                              WhiteSky


                              C Offline
                              C Offline
                              Cris
                              wrote on last edited by
                              #14

                              OK, thank you again.

                              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