is there a way to take an html string and render it as a web browser would, from the command line?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lkrubner@geocities.com

    is there a way to take an html string and render it as a web browser would, from the command line?


    I'd like to write a PHP script to be used from the command line on a
    Unix machine. I'd like for the script to put together a string, turn it
    into a web page, print it, then return control the command line.

    Obviously it is quite easy to make a string that is valid HTML and send
    it to the printer. The tough part is making look like a web page. In
    particular, image tags should print out as images, not image tags.

    Does anyone have an idea about how this is done?

    Many thanks in advance.

  • Justin Koivisto

    #2
    Re: is there a way to take an html string and render it as a webbrowser would, from the command line?

    lkrubner@geocit ies.com wrote:[color=blue]
    > I'd like to write a PHP script to be used from the command line on a
    > Unix machine. I'd like for the script to put together a string, turn it
    > into a web page, print it, then return control the command line.
    >
    > Obviously it is quite easy to make a string that is valid HTML and send
    > it to the printer. The tough part is making look like a web page. In
    > particular, image tags should print out as images, not image tags.
    >
    > Does anyone have an idea about how this is done?
    >
    > Many thanks in advance.
    >[/color]

    What kind of system are you running on (linux, windows, mac, etc)?

    My first thought would be to have the system call a web browser's print
    function, but that may be a bit too complex since it would amost
    certainly involve some kind of shell scripting or creating a simple
    browser yourself...

    --
    Justin Koivisto, ZCE - justin@koivi.co m

    Comment

    • lkrubner@geocities.com

      #3
      Re: is there a way to take an html string and render it as a web browser would, from the command line?



      Fixed font - Proportional font


      is there a way to take an html string and render it as a web browser
      would, from the command line?
      All 2 messages in topic - view as tree
      lkrub...@geocit ies.com Oct 25, 10:55 am show options

      Newsgroups: comp.lang.php
      From: lkrub...@geocit ies.com - Find messages by this author
      Date: 25 Oct 2005 07:55:47 -0700
      Local: Tues, Oct 25 2005 10:55 am
      Subject: is there a way to take an html string and render it as a web
      browser would, from the command line?
      Reply | Reply to Author | Forward | Print | Individual Message | Show
      original | Remove | Report Abuse


      I'd like to write a PHP script to be used from the command line on a
      Unix machine. I'd like for the script to put together a string, turn it

      into a web page, print it, then return control the command line.


      Obviously it is quite easy to make a string that is valid HTML and send

      it to the printer. The tough part is making look like a web page. In
      particular, image tags should print out as images, not image tags.


      Does anyone have an idea about how this is done?


      Many thanks in advance.


      Reply





      Justin Koivisto Oct 25, 11:22 am show options

      Newsgroups: comp.lang.php
      From: Justin Koivisto <jus...@koivi.c om> - Find messages by this author

      Date: Tue, 25 Oct 2005 10:22:55 -0500
      Local: Tues, Oct 25 2005 11:22 am
      Subject: Re: is there a way to take an html string and render it as a
      web browser would, from the command line?
      Reply | Reply to Author | Forward | Print | Individual Message | Show
      original | Report Abuse


      [color=blue]
      >lkrub...@geoci ties.com wrote:[color=green]
      >> I'd like to write a PHP script to be used from the command line on a
      >> Unix machine. I'd like for the script to put together a string, turn it
      >> into a web page, print it, then return control the command line.[/color][/color]
      [color=blue][color=green]
      >> Obviously it is quite easy to make a string that is valid HTML and send
      >> it to the printer. The tough part is making look like a web page. In
      >> particular, image tags should print out as images, not image tags.[/color][/color]

      [color=blue]
      > What kind of system are you running on (linux, windows,
      > mac, etc)?
      > My first thought would be to have the system call a web
      > browser's print
      > function, but that may be a bit too complex since it would amost
      > certainly involve some kind of shell scripting or creating a
      > simple[/color]

      I'm sorry that I was not more clear before. I want to write a shell
      script in PHP or Perl that will run on an HP Unix system. The script
      should build up a string of HTML, turn it into a rendered web page,
      send that to the printer, then return control the command line. When I
      say "turn the string into a web page" I mean that HTML image tags
      should print out as images, not HTML image tags.

      I'm wondering how people would do this. Someone suggested I invoke the
      rendering engine on mozilla, but I'm not clear on how this is done.




      browser yourself...

      Comment

      • lkrubner@geocities.com

        #4
        Re: is there a way to take an html string and render it as a web browser would, from the command line?

        > What kind of system are you running on (linux, windows,[color=blue]
        > mac, etc)?
        > My first thought would be to have the system call a web
        > browser's print
        > function, but that may be a bit too complex since it would amost
        > certainly involve some kind of shell scripting or creating a
        > simple web browser yourself[/color]

        I'm sorry that I was not more clear before. I want to write a shell
        script in PHP or Perl that will run on an HP Unix system. The script
        should build up a string of HTML, turn it into a rendered web page,
        send that to the printer, then return control the command line. When I
        say "turn the string into a web page" I mean that HTML image tags
        should print out as images, not HTML image tags.

        I'm wondering how people would do this. Someone suggested I invoke the
        rendering engine on mozilla, but I'm not clear on how this is done.

        Comment

        • Gordon Burditt

          #5
          Re: is there a way to take an html string and render it as a web browser would, from the command line?

          >I'm sorry that I was not more clear before. I want to write a shell[color=blue]
          >script in PHP or Perl that will run on an HP Unix system. The script
          >should build up a string of HTML, turn it into a rendered web page,
          >send that to the printer, then return control the command line. When I
          >say "turn the string into a web page" I mean that HTML image tags
          >should print out as images, not HTML image tags.[/color]

          There's a FreeBSD port/package (and I'm sure it's not unique to
          FreeBSD) called "html2ps". I think it does what you want it to -
          turn HTML into rendered Postscript. No guarantees about what it's
          written in. If you don't have a Postscript printer, also install
          the 'ghostscript' package, which emulates one. You might need a
          wrapper script to actually send the output to a printer.

          Gordon L. Burditt

          Comment

          Working...