how to print pdf with python on a inkjet printer.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • krishnakant Mane

    #1

    how to print pdf with python on a inkjet printer.

    hello all.
    I am developing an ncurses based python application that will require
    to create pdf reports for printing.
    I am not using py--qt or wx python.
    it is a consol based ui application and I need to make a pdf report
    and also send it to a lazer or ink jet printer.
    is it possible to do so with python?
    or is it that I will have to use the wxpython library asuming that
    there is a print dialog which can open up the list of printers?
    if wx python and gui is the only way then it is ok but I will like to
    keep this application on the ncurses side.

    thanks.
    Krishnakant.
  • Tim Roberts

    #2
    Re: how to print pdf with python on a inkjet printer.

    "krishnakan t Mane" <researchbase@g mail.comwrote:
    >
    >hello all.
    >I am developing an ncurses based python application that will require
    >to create pdf reports for printing.
    >I am not using py--qt or wx python.
    >it is a consol based ui application and I need to make a pdf report
    >and also send it to a lazer or ink jet printer.
    >is it possible to do so with python?
    Making the PDF is easy. Go get ReportLab from www.reportlab.org. I
    consider it the best Python PDF solution.

    Printing is more complicated, because you actually need something that can
    RENDER the PDF. The most common such renderer is the Acrobat Reader, and
    you can actually call the Acrobat Reader from a command line with a
    parameter that tells it to print the file automatically. The only
    disadvantage is that using that method will only print to the "default"
    printer.
    >or is it that I will have to use the wxpython library asuming that
    >there is a print dialog which can open up the list of printers?
    Even if you got the list of printers, what would you do with it?
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

    Comment

    • Leo Kislov

      #3
      Re: how to print pdf with python on a inkjet printer.


      krishnakant Mane wrote:
      hello all.
      I am developing an ncurses based python application that will require
      to create pdf reports for printing.
      I am not using py--qt or wx python.
      it is a consol based ui application and I need to make a pdf report
      and also send it to a lazer or ink jet printer.
      is it possible to do so with python?
      or is it that I will have to use the wxpython library asuming that
      there is a print dialog which can open up the list of printers?
      if wx python and gui is the only way then it is ok but I will like to
      keep this application on the ncurses side.
      Assuming you are on a UNIX-like system, you really need to setup CUPS
      <http://www.cups.org/(or may be your system already provides CUPS).
      PDF seems to be the future intermediate format for UNIX printing
      <http://www.linux.com/article.pl?sid= 06/04/18/2114252and CUPS already
      supports printing PDF files, just run "lp your_file.pdf" to print a
      file. CUPS only have command line interface:
      <http://www.cups.org/documentation.p hp/options.html>

      -- Leo

      Comment

      • Leo Kislov

        #4
        Re: how to print pdf with python on a inkjet printer.

        Leo Kislov wrote:
        CUPS only have command line interface:
        <http://www.cups.org/documentation.p hp/options.html>
        My mistake: CUPS actually has official C API
        <http://www.cups.org/documentation.p hp/api-cups.htmland unofficial
        python bindings <http://freshmeat.net/projects/pycups/>.

        Comment

        • krishnakant Mane

          #5
          Re: how to print pdf with python on a inkjet printer.

          On 17/11/06, Tim Roberts <timr@probo.com wrote:
          Making the PDF is easy. Go get ReportLab from www.reportlab.org. I
          consider it the best Python PDF solution.
          wow! you solved my major problem before I even asked it. seams that
          python programmers also have dynamic mind reading capability *smile*.
          Printing is more complicated, because you actually need something that can
          RENDER the PDF. The most common such renderer is the Acrobat Reader, and
          you can actually call the Acrobat Reader from a command line with a
          parameter that tells it to print the file automatically. The only
          disadvantage is that using that method will only print to the "default"
          printer.
          double wow! as it is my customer wants me to print to the default printer.
          can you please help me with the command for rendering the pdf to the
          printer with acrobat using python?
          that essentially solves my most important problem.
          else I was thinking to create an excel spreadsheet as a last alternative.
          out of my curocity, I want to know if there are libraries that can
          create excel spreadsheets?

          I also wanted to know if there is a common dialog for listing out
          printers under windows?
          so in future if I make this software in GUI, I can at list help the
          user select the printer from the list.
          thanks,
          Krishnakant.

          Comment

          • Fredrik Lundh

            #6
            Re: how to print pdf with python on a inkjet printer.

            krishnakant Mane wrote:
            double wow! as it is my customer wants me to print to the default printer.
            can you please help me with the command for rendering the pdf to the
            printer with acrobat using python?
            see:



            or possibly:



            now go donate some of what the customer is paying you to solve this
            problem for him to the PSF ;-)

            </F>

            Comment

            • krishnakant Mane

              #7
              Re: how to print pdf with python on a inkjet printer.

              On 17/11/06, Fredrik Lundh <fredrik@python ware.comwrote:
              I can't figure out where is the win32api module in my system.
              I think I need to download it.
              I tried to search but did not find it.
              what is the url for this module and does it also have documentation.
              thanking you.
              Krishnakant.

              Comment

              • Fredrik Lundh

                #8
                Re: how to print pdf with python on a inkjet printer.

                krishnakant Mane wrote:
                I can't figure out where is the win32api module in my system.
                I think I need to download it.
                I tried to search but did not find it.
                googling for "python win32api" gives you:

                http://sourceforge.net/project/showf...group_id=78018

                among the first few hits. as for documentation, it's just a binding for
                the win32 api:s, which are extensively documented over at microsoft.com.

                </F>

                Comment

                • Tim Roberts

                  #9
                  Re: how to print pdf with python on a inkjet printer.

                  krishnakant Mane wrote:
                  >>
                  double wow! as it is my customer wants me to print to the default
                  printer.
                  can you please help me with the command for rendering the pdf to the
                  printer with acrobat using python?
                  You'll have to use the registry to find "acrord32", but once you find
                  it, you just do:
                  os.system( "\\Program Files\\Adobe\\A crobat 7.0\\Reader\acr ord32.exe
                  /p xxx.pdf" )
                  The /p switch requests printing.

                  that essentially solves my most important problem.
                  else I was thinking to create an excel spreadsheet as a last alternative.
                  out of my curocity, I want to know if there are libraries that can
                  create excel spreadsheets?
                  There are several ways. One way is to just bring up Excel itself and
                  send it commands via COM. Several times, I've written my data as a
                  comma-separated file (which Excel understands), then brought up Excel as
                  a COM component, loaded the file, then used Excel commands to format the
                  columns.

                  There are also a couple of Python modules which purport to be able to
                  read and write .xls files directly. There's xlrd, but there's a newer
                  one whose name escapes me. I thought it was a pun, like "xlerator," but
                  that's not right.

                  I also wanted to know if there is a common dialog for listing out
                  printers under windows?
                  so in future if I make this software in GUI, I can at list help the
                  user select the printer from the list.
                  Yes, there is a standard "print" dialog for Windows that shows you the
                  familiar dialog, with the list of printers and all of the options. In
                  wxPython, I believe it is called wx.PrintDialog.

                  In Pywin32, win32print.Enum Printers can give you the list of available
                  printers.

                  --
                  Tim Roberts, timr@probo.com
                  Providenza & Boekelheide, Inc.

                  Comment

                  • Gabriel Genellina

                    #10
                    Re: how to print pdf with python on a inkjet printer.

                    At Friday 17/11/2006 17:40, Tim Roberts wrote:
                    double wow! as it is my customer wants me to print to the default
                    printer.
                    can you please help me with the command for rendering the pdf to the
                    printer with acrobat using python?
                    >
                    >You'll have to use the registry to find "acrord32", but once you find
                    >it, you just do:
                    os.system( "\\Program Files\\Adobe\\A crobat 7.0\\Reader\acr ord32.exe
                    >/p xxx.pdf" )
                    >The /p switch requests printing.
                    Or just let Windows do the dirty work of locating Adobe Reader,
                    figuring out the parameters and such:

                    import win32api
                    win32api.ShellE xecute(0, "print", path/to/document.pdf, None, None, 0)


                    --
                    Gabriel Genellina
                    Softlab SRL

                    _______________ _______________ _______________ _____
                    Correo Yahoo!
                    Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
                    ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar

                    Comment

                    • Thomas Heller

                      #11
                      Re: how to print pdf with python on a inkjet printer.

                      Gabriel Genellina schrieb:
                      At Friday 17/11/2006 17:40, Tim Roberts wrote:
                      >
                      double wow! as it is my customer wants me to print to the default
                      printer.
                      can you please help me with the command for rendering the pdf to the
                      printer with acrobat using python?
                      >>
                      >>You'll have to use the registry to find "acrord32", but once you find
                      >>it, you just do:
                      > os.system( "\\Program Files\\Adobe\\A crobat 7.0\\Reader\acr ord32.exe
                      >>/p xxx.pdf" )
                      >>The /p switch requests printing.
                      >
                      Or just let Windows do the dirty work of locating Adobe Reader,
                      figuring out the parameters and such:
                      >
                      import win32api
                      win32api.ShellE xecute(0, "print", path/to/document.pdf, None, None, 0)
                      >
                      Note that in Pyhton2.5, os.startfile was extended to accept an optional
                      second parameter; so
                      os.startfile(pa th/to/document.pdf, "print")
                      should also work.

                      Thomas

                      Comment

                      Working...