473,240 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,240 software developers and data experts.

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.

Oct 25 '05 #1
4 3149
lk******@geocities.com wrote:
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.


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 - ju****@koivi.com
http://koivi.com
Oct 25 '05 #2


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...@geocities.com Oct 25, 10:55 am show options

Newsgroups: comp.lang.php
From: lkrub...@geocities.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.com> - 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
lkrub...@geocities.com wrote:
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.

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


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...

Oct 25 '05 #3
> 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 web browser yourself


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.

Oct 25 '05 #4
>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.


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

Oct 25 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
71
by: tomy_baseo | last post by:
I'm new to HTML and want to learn the basics by learning to code by hand (with the assistance of an HTML editor to eliminate repetitive tasks). Can anyone recommend a good, basic HTML editor that's...
50
by: Christopher Benson-Manica | last post by:
(if this isn't the place for XHTML, I'd appreciate a redirect) According to the w3's web site, some non-HTML 4 browsers won't properly interpret non-minimized boolean attributes, i.e. <option...
6
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this...
4
by: Zuel | last post by:
Hi Folks. So I have a small problem. My DoPostBack function is not writen to the HTML page nor are the asp:buttons calling the DoPostBack. My Goal is to create a totaly dynamic web page where...
3
by: Epetruk | last post by:
Hi, I'm looking for samples of ASP.NET projects where the programming has been done almost entirely using codebehind and classes with very little code in the aspx files themselves. I would...
1
by: Andrew | last post by:
I'm adding this as it to me a while to figure out all the pieces to be able to do this without using Microsoft.Office.Interop which caused me problems on the web-server. Streaming is the easy...
10
by: Jake Barnes | last post by:
This weekend I wanted to learn AJAX, so I set up a little toy page where I could experiment. The idea of this page is that you click in one of the boxes to get some controls, at which point you can...
3
by: Smithers | last post by:
Just wondering what it would take to cache a copy of the output HTML from a dynamically constructed aspx page before it is sent to the browser. Reason being: the page is constructed of a few user...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.