PDF Printing support from Python

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

    PDF Printing support from Python

    Hi all... Is there a way to print a PDF file directly from Python
    without having Acrobat installed? I know about ReportLab. It's a python
    module that lets you create almost any PDF document, but I still don't
    know if it supports printing, so I'm looking for a Python module that
    could do it. I want to print a PDF file just like if I were doing it
    from Acrobat.

    Daniel.

  • Grant Edwards

    #2
    Re: PDF Printing support from Python

    On 2005-04-22, dcrespo <dcrespo@gmail. com> wrote:
    [color=blue]
    > Hi all... Is there a way to print a PDF file directly from
    > Python without having Acrobat installed?[/color]

    Assuming your printing system was setup competently:

    os.system("lpr %s" % filename)
    [color=blue]
    > I know about ReportLab. It's a python module that lets you
    > create almost any PDF document, but I still don't know if it
    > supports printing, so I'm looking for a Python module that
    > could do it. I want to print a PDF file just like if I were
    > doing it from Acrobat.[/color]

    Not sure what you mean by "just like if I were doing it from
    Acrobat".

    --
    Grant Edwards grante Yow! I have seen these
    at EGG EXTENDERS in my
    visi.com Supermarket... I have read
    theINSTRUCTIONS ...

    Comment

    • dcrespo

      #3
      Re: PDF Printing support from Python

      Hi Grant Edwards...

      Your solution requires a previous installation of Acrobat. Internally,
      the OS is sending the pdf file to the Acrobat PDF Driver and then it is
      sent to the printer. So you have to have Acrobat installed. Don't you?
      I want to avoid it installing a module that could do it (maybe I'm
      dreaming:( ). If there's no solution, then I will be very sad :-S

      This is what exactly I need to do:
      Generate an invoice of 216cm width and 93cm height (1/3 of the height
      of a letter paper size), and print it respecting these dimensions. So,
      when I print this page on a dot matrix printer, it stops at those 93cm
      of height for continuous printing.

      What I tried:
      I created a pdf file manually with these dimensions, and right-click on
      the pdf file, and selected "print". It just work under Windows XP with
      Acrobat Reader 7.0, but I want to do it from a Win98 as well.
      Unfortunately, there's no Acrobat version under Win98 (the maximun is
      5.1) that supports this kind of printing (what I had seen until now).
      It prints, but the all paper at letter size :(

      Any help? Any other tools? Any one like Cristal Report but for Python?
      I heard that wxPython supports some kind of reporting, but I don't know
      it. Anyone knows?

      Daniel

      Comment

      • Harry George

        #4
        Re: PDF Printing support from Python

        "dcrespo" <dcrespo@gmail. com> writes:
        [color=blue]
        > Hi Grant Edwards...
        >
        > Your solution requires a previous installation of Acrobat. Internally,
        > the OS is sending the pdf file to the Acrobat PDF Driver and then it is
        > sent to the printer. So you have to have Acrobat installed. Don't you?
        > I want to avoid it installing a module that could do it (maybe I'm
        > dreaming:( ). If there's no solution, then I will be very sad :-S
        >
        > This is what exactly I need to do:
        > Generate an invoice of 216cm width and 93cm height (1/3 of the height
        > of a letter paper size), and print it respecting these dimensions. So,
        > when I print this page on a dot matrix printer, it stops at those 93cm
        > of height for continuous printing.
        >
        > What I tried:
        > I created a pdf file manually with these dimensions, and right-click on
        > the pdf file, and selected "print". It just work under Windows XP with
        > Acrobat Reader 7.0, but I want to do it from a Win98 as well.
        > Unfortunately, there's no Acrobat version under Win98 (the maximun is
        > 5.1) that supports this kind of printing (what I had seen until now).
        > It prints, but the all paper at letter size :(
        >
        > Any help? Any other tools? Any one like Cristal Report but for Python?
        > I heard that wxPython supports some kind of reporting, but I don't know
        > it. Anyone knows?
        >
        > Daniel
        >[/color]


        When you say "OS", are you talking MS Windows by any chance? On *NIX
        (e.g., CUPS+ghostview+ foomatic), PDF printing is not via Adobe code.

        You could also consider pdf2ps, pdftops, and XPDF.


        --
        harry.g.george@ boeing.com
        6-6M21 BCA CompArch Design Engineering
        Phone: (425) 294-4718

        Comment

        • Grant Edwards

          #5
          Re: PDF Printing support from Python

          On 2005-04-22, dcrespo <dcrespo@gmail. com> wrote:
          [color=blue]
          > Your solution requires a previous installation of Acrobat.[/color]

          Probably not. Most printing systems I'm familiar with use
          ghostscript to render PDF into either postscript (the case on
          my machines at home) or whatever raster format the printer
          desires (the case at my office).
          [color=blue]
          > Internally, the OS is sending the pdf file to the Acrobat PDF
          > Driver and then it is sent to the printer.[/color]

          Nope. It's usnig the foomatic print filters which in turn use
          ghostscript to render PDF.
          [color=blue]
          > So you have to have Acrobat installed. Don't you?[/color]

          No you just need a good printing system. CUPS + foomatic works
          great for me. It knows what to do with postcript, text, PDF,
          dvi, and a whole boatload of other fileformats that I don't
          ever use.
          [color=blue]
          > I want to avoid it installing a module that could do it (maybe
          > I'm dreaming:( ). If there's no solution, then I will be very
          > sad :-S
          >
          > This is what exactly I need to do: Generate an invoice of
          > 216cm width and 93cm height (1/3 of the height of a letter
          > paper size), and print it respecting these dimensions. So,
          > when I print this page on a dot matrix printer, it stops at
          > those 93cm of height for continuous printing.
          >
          > What I tried: I created a pdf file manually with these
          > dimensions, and right-click on the pdf file, and selected
          > "print". It just work under Windows XP with Acrobat Reader
          > 7.0, but I want to do it from a Win98 as well.[/color]

          Ah. You're using Windows. I didn't know that. I've no clue
          what to do under Windows.

          --
          Grant Edwards grante Yow! .. someone in DAYTON,
          at Ohio is selling USED
          visi.com CARPETS to a SERBO-CROATIAN

          Comment

          • Peter Herndon

            #6
            Re: PDF Printing support from Python

            Grant's example is not for Windows, Daniel, but it does illustrate a
            certain principle: if you have a printer driver that understands PDF,
            or some other external software such as Acrobat Reader that understands
            PDF, then printing the PDF is as simple as telling the OS to just print
            the file.

            If you are looking for some software that acts as a PDF-understanding
            interpreter, that must run under Windows 98, I don't know of any
            written in Python. However, you might want to research some of the
            available non-Python utilities. Ghostscript, for example, is available
            at http://www.cs.wisc.edu/~ghost/ and has a version for Win32. You
            could easily use Python to drive GhostScript.

            Does that fit your needs?

            ---Peter

            Comment

            • John J. Lee

              #7
              Re: PDF Printing support from Python

              "dcrespo" <dcrespo@gmail. com> writes:
              [color=blue]
              > Hi Grant Edwards...
              >
              > Your solution requires a previous installation of Acrobat. Internally,
              > the OS is sending the pdf file to the Acrobat PDF Driver and then it is
              > sent to the printer. So you have to have Acrobat installed. Don't you?
              > I want to avoid it installing a module that could do it (maybe I'm
              > dreaming:( ). If there's no solution, then I will be very sad :-S[/color]
              [...][color=blue]
              > Acrobat Reader 7.0, but I want to do it from a Win98 as well.
              > Unfortunately, there's no Acrobat version under Win98 (the maximun is
              > 5.1) that supports this kind of printing (what I had seen until now).
              > It prints, but the all paper at letter size :([/color]

              That doesn't sound like a fundamental problem with AR 5.1 to me --
              sounds like you just need to ask it more nicely ;-)

              Have you tried the latest version of APFL ghostscript, though (8.51)?

              [color=blue]
              > Any help? Any other tools? Any one like Cristal Report but for Python?
              > I heard that wxPython supports some kind of reporting, but I don't know
              > it. Anyone knows?[/color]

              First, decide what qualities you need from your output format, then
              decide which format you want, and how to generate and print it. Is it
              important that you have one, other, or both of bitmap or vector
              output, for example?


              John

              Comment

              • dcrespo

                #8
                Re: PDF Printing support from Python

                Thanks a lot... I'm attemping to give it a try :)

                Comment

                • dcrespo

                  #9
                  Re: PDF Printing support from Python

                  > That doesn't sound like a fundamental problem with AR 5.1 to me --
                  sounds like you just need to ask it more nicely ;-)

                  AR 7.0 has the function to print exactly the page size you set. AR 5.1
                  doesn't. Instead, it print it on an existing page size like letter, but
                  without changing the relative layout of the each line of text respect
                  each other.

                  Daniel

                  Comment

                  • dcrespo

                    #10
                    Re: PDF Printing support from Python

                    >> Your solution requires a previous installation of Acrobat.
                    [color=blue]
                    > Probably not. Most printing systems I'm familiar with use
                    > ghostscript to render PDF into either postscript (the case on
                    > my machines at home) or whatever raster format the printer
                    > desires (the case at my office).[/color]

                    Acrobat (windows) and Ghostscript are PDF drivers.
                    [color=blue][color=green]
                    >> Internally, the OS is sending the pdf file to the Acrobat PDF
                    >> Driver and then it is sent to the printer.[/color][/color]
                    [color=blue]
                    > Nope. It's usnig the foomatic print filters which in turn use
                    > ghostscript to render PDF.[/color]

                    What I mean is that the pdf file is sent to a pdf driver (some program
                    to interpret it)... In your case is ghostscript, and in my case is
                    Acrobat.
                    [color=blue]
                    > No you just need a good printing system. CUPS + foomatic works
                    > great for me. It knows what to do with postcript, text, PDF,
                    > dvi, and a whole boatload of other fileformats that I don't
                    > ever use.[/color]

                    CUPS + foomatic are the whole megadriver... So it's just a manner of
                    saying PDF Driver for my study case.

                    Really thanks for all the information :) I didn't know about
                    Ghostscript.

                    Daniel

                    Comment

                    • Grant Edwards

                      #11
                      Re: PDF Printing support from Python

                      On 2005-04-22, dcrespo <dcrespo@gmail. com> wrote:[color=blue][color=green][color=darkred]
                      >>> Your solution requires a previous installation of Acrobat.[/color][/color]
                      >[color=green]
                      >> Probably not. Most printing systems I'm familiar with use
                      >> ghostscript to render PDF into either postscript (the case on
                      >> my machines at home) or whatever raster format the printer
                      >> desires (the case at my office).[/color]
                      >
                      > Acrobat (windows) and Ghostscript are PDF drivers.[/color]

                      No, ghostscript isn't a "driver". it's a normal user-space
                      application, but I'm not sure what you're point is. My
                      statement that printing PDF doesn't depend on Acrobat is true
                      regardless of whether ghostscript is a driver or application.
                      [color=blue][color=green][color=darkred]
                      >>> Internally, the OS is sending the pdf file to the Acrobat PDF
                      >>> Driver and then it is sent to the printer.[/color][/color]
                      >[color=green]
                      >> Nope. It's usnig the foomatic print filters which in turn use
                      >> ghostscript to render PDF.[/color]
                      >
                      > What I mean is that the pdf file is sent to a pdf driver (some
                      > program to interpret it)... In your case is ghostscript, and
                      > in my case is Acrobat.[/color]

                      That's not a driver. At least not in my world. Drivers live
                      in kernel space. Acrobat and ghostscript are just applications
                      that run in user-space.
                      [color=blue][color=green]
                      >> No you just need a good printing system. CUPS + foomatic works
                      >> great for me. It knows what to do with postcript, text, PDF,
                      >> dvi, and a whole boatload of other fileformats that I don't
                      >> ever use.[/color]
                      >
                      > CUPS + foomatic are the whole megadriver... So it's just a
                      > manner of saying PDF Driver for my study case.[/color]

                      You're use of the word "driver" is one with which I'm not
                      familiar. But I don't really "do windows" so it's probably a
                      Widnowism.
                      [color=blue]
                      > Really thanks for all the information :) I didn't know about
                      > Ghostscript.[/color]

                      I'm sure you can use ghostscript to do the same thing under
                      Windows (render PDF into the raster format preferred by your
                      printer), but I've no idea how one would go about it.

                      --
                      Grant Edwards grante Yow! Hmmm... a CRIPPLED
                      at ACCOUNTANT with a FALAFEL
                      visi.com sandwich is HIT by a
                      TROLLEY-CAR...

                      Comment

                      • Mike Meyer

                        #12
                        Re: PDF Printing support from Python

                        "dcrespo" <dcrespo@gmail. com> writes:
                        [color=blue]
                        > Hi Grant Edwards...
                        >
                        > Your solution requires a previous installation of Acrobat. Internally,
                        > the OS is sending the pdf file to the Acrobat PDF Driver and then it is
                        > sent to the printer. So you have to have Acrobat installed. Don't you?[/color]

                        No, you don't. My print system does that, and I don't have acrobat
                        installed. I have ghostscript installed, which includes pdf2ps - which
                        handles this particular translation.
                        [color=blue]
                        > This is what exactly I need to do:
                        > Generate an invoice of 216cm width and 93cm height (1/3 of the height
                        > of a letter paper size), and print it respecting these dimensions. So,
                        > when I print this page on a dot matrix printer, it stops at those 93cm
                        > of height for continuous printing.[/color]

                        Ok, I'm a masochist. When I have problems like this (i.e. - printing
                        CD labels, addressing envelopes, etc) I just have the python generate
                        raw postscript. That gives you more than enough control over the
                        output to solve the problem. Integrating it with a GUI is another
                        matter, though.

                        <mike
                        --
                        Mike Meyer <mwm@mired.or g> http://www.mired.org/home/mwm/
                        Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

                        Comment

                        • Diez B. Roggisch

                          #13
                          Re: PDF Printing support from Python

                          > You're use of the word "driver" is one with which I'm not[color=blue]
                          > familiar. But I don't really "do windows" so it's probably a
                          > Widnowism.[/color]

                          It could be that he means that creating PDFs on windows is done using a fake
                          printer that will produce the pdf when being printed to - and that fake
                          printer is implemented as a driver.

                          And traditionally in printing one often speaks of printer drivers - even if
                          they are mere filters that can't be considered drivers in the kernel driver
                          way.
                          --
                          Regards,

                          Diez B. Roggisch

                          Comment

                          • Grant Edwards

                            #14
                            Re: PDF Printing support from Python

                            On 2005-04-23, Diez B. Roggisch <deetsNOSPAM@we b.de> wrote:
                            [color=blue][color=green]
                            >> You're use of the word "driver" is one with which I'm not
                            >> familiar. But I don't really "do windows" so it's probably a
                            >> Widnowism.[/color]
                            >
                            > It could be that he means that creating PDFs on windows is
                            > done using a fake printer that will produce the pdf when being
                            > printed to - and that fake printer is implemented as a driver.
                            >
                            > And traditionally in printing one often speaks of printer
                            > drivers - even if they are mere filters that can't be
                            > considered drivers in the kernel driver way.[/color]

                            I think it's the latter. I believe he wants to know how to
                            print a PDF file without using any external programs (or
                            "drivers") like Acrobat Reader or ghostscript that understand
                            PDF. AFAIK, the only way to do what he wants would be for him
                            to write a PDF engine in Python that renders PDF into whatever
                            raw format is understood by his printer.

                            --
                            Grant Edwards grante Yow! I'LL get it!! It's
                            at probably a FEW of my
                            visi.com ITALIAN GIRL-FRIENDS!!

                            Comment

                            • Dennis Lee Bieber

                              #15
                              Re: PDF Printing support from Python

                              On Fri, 22 Apr 2005 17:41:22 -0500, Mike Meyer <mwm@mired.or g> declaimed
                              the following in comp.lang.pytho n:
                              [color=blue]
                              > No, you don't. My print system does that, and I don't have acrobat
                              > installed. I have ghostscript installed, which includes pdf2ps - which
                              > handles this particular translation.
                              >[/color]
                              Okay, so you've converted one page layout language (PDF) to
                              another (PS)... To actually print it you still need a RIP. A PostScript
                              laser printer has the RIP built-in, but consumer level Windows printers
                              do not have a PostScript RIP -- and some printers don't even have their
                              own specific RIP built-in ("winprinter s" put the RIP into the software
                              driver that runs on the Windows machine, rather than sending drawing
                              commands to the printer for rendering).

                              --[color=blue]
                              > =============== =============== =============== =============== == <
                              > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
                              > wulfraed@dm.net | Bestiaria Support Staff <
                              > =============== =============== =============== =============== == <
                              > Home Page: <http://www.dm.net/~wulfraed/> <
                              > Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color]

                              Comment

                              Working...