Thread: Printing html

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Questioner's home
    Posts
    89
    Rep Power
    12

    Printing html


    Is there a way to directly print generated html files without prompting the print setup form? Thanks in advance.
    What can change the nature of a man?
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    I'n not sure exactly what you mean here, but if your generating a HTML file and want to print the contents of that file then you would do something like:

    Code:
    >>> print file('some/path/some.html').read()
    ...
    Chances are that this isn't what you want, so a few more details about what you're doing would probably help .

    Have fun,

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    6
    Rep Power
    0
    If you want instead see the file with a browser (for ex. Mozilla), from
    which you can (if you want) see the html source...

    Code:
    import os
    os.system('mozilla some/path/some.html')
    From the running browser, you can, of course, also send the file or the html source to a printer.
    If the command succeed (that is you have the browser in the execution path and the html file is present) a "0" is returned to the function "system".
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    136
    Rep Power
    10
    Originally Posted by fiomba
    If you want instead see the file with a browser (for ex. Mozilla), from
    which you can (if you want) see the html source...

    Code:
    import os
    os.system('mozilla some/path/some.html')
    From the running browser, you can, of course, also send the file or the html source to a printer.
    If the command succeed (that is you have the browser in the execution path and the html file is present) a "0" is returned to the function "system".

    or use the webbrowser module

    Code:
    import webbrowser
    webbrowser.open_new("url")
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Questioner's home
    Posts
    89
    Rep Power
    12
    Thanks, but what I really wanted is to print (send the request to printer) without prompting the print setup dialog before the print. Let's say I'm generating a report, then after the report is done, I prompt a small message box (not print setup dialog), if ok, print immediately, else do nothing. Izzit possible?

    Thanks in advance.
    What can change the nature of a man?
  10. #6
  11. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Assuming we're talking about a windows machine here then you're best bet would be to check out Mark Hammond's win32all extensions:

    http://starship.python.net/crew/mhammond/
    programming language development: www.netytan.com Hula

  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Questioner's home
    Posts
    89
    Rep Power
    12
    I sure wish, lol, but it's in Linux, but thanks.
    What can change the nature of a man?

IMN logo majestic logo threadwatch logo seochat tools logo