View Full Version : Automatic printing
01-18-2006, 03:21 PM
Every two weeks I have to print out about 100 different websites. These sites change data week to week, but not their address. At present, I am just going down the list and printing them manually; is there a java script I can use to run down this list for me? It seems there must, because it's is a fairly basic operation; click, print, next. Right now I have it set up as a frameset, links on the left panel and the target on the right panel, and it seems to work ok, but I'd much rather hit a button and have it print out every link for me.
I appreciate any help!
Nope. If there was imagine the havoc malicious haxxors could cause to unsuspecting websites.
*this has been asked before. you could always find the thread and see the various opinions for yourself, before you get flamed.
01-18-2006, 03:56 PM
Easiest way would to build a simple program with VB or something, have it loop through each address, display the site (you could use the webbrowser control in VB6 for simplicity), then print it. The move onto the next site.
Actually, that CAN be done with JS can't it? Just make it loop every 20 seconds or so, load the location into the iframe/frame, print the frame then move onto the next one?
01-18-2006, 04:10 PM
Yes, right now I am just cycling through; but there's no real gain if I just cycle every 20 seconds and hit print. I'm trying to not click anything at all once I set the script in motion. I don't know VB script, so maybe I'm just stuck printing things out myself. Right now I spend a few hours doing this; it would be really helpful if I could just hit a button, go do something else, and come back to my report printed out without intervention.
01-18-2006, 04:13 PM
I think you should be able to store each url in an array though, then every so many seconds set the frame location to that of the first url, and print, then move onto the next url in the array.
I'm sure someone more advanced with JS could code it for you.
I doubt he would get flamed, he asked a legitimate question
as did the OP in the other post from way back (long before you were here, anyway), and he defo got flamed.
01-20-2006, 01:05 PM
If you try to use any print function through js, the browser will pop-up a print dialogue box where you have to select the number of copies, etc. (sort of like doing "Print..." as opposed to "Print" in Word). Going back to Jbot's point, imagine how damaging it would be if advertising spammers could tell client computers to automatically printout a web site!
The only way to do something like this is to:
a) Run an outside programs (ie a program on your computer) that interacts with the browser to perform the "Print" operation for you. Basically the idea that mark87 proposed.
b) Run a server-side script where a web-site is unders your control. If you are actually the one hosting the site, you should be able to do this, however, if a second party hosts your site, they may not allow you to do that.
Another possibility is making some web-page that collects info from the other sites and makes a report type of page for you. This assumes that on each page, you don't necessarily need to print out the entire page, but rather are attempting to pick out certain pieces of info from each site (eg stoke quote, price of a particular item, top sales items, etc). Basically, since you said the pages don't change, just the info in them, I'm assuming that means that their structure doesn't change either (or at least not on a regular basis). Thus you could write a script that would open their site in a new frame / window and then call something like:
opener.document.getElementById('myTextBox').value = otherSite.document.getElementById('theirTextBox').value;
The script would then open the next site, get their info, etc. When the script is finished, you'd only have your page containing all of the revevant info to print out.
yeah, you could do some screen scraping using a serverside lingo like say PHP, collate the results into a report and export to a variety of formats, then print them off.
01-24-2006, 04:12 AM
I really like the idea of picking info out of every page; that would actually be preferable, as after I'm printing all of these out, I'm going through and making calculations based on what the pages contain. If I could pull data out, my life would be much, much easier (and easier yet if it was possible to export things to excel). The structure does remain unchanged. However, this data is not in a text box, it is just in a table (it's geological data, such as reservoir levels and river flows, pulled from USGS and NOAA sites). I suppose there should be a way to find the data, but I don't think I'm proficient enough in JS to do such a thing. Also, I am NOT running this off any type of server. I'm just using it as a tool on a local computer to make it easier to pull data from these internet sites; so any restrictions or complications from web servers can be disregarded.
01-24-2006, 05:32 AM
To have more control and no strict security, look into HTAs (http://msdn.microsoft.com/workshop/author/hta/overview/htaoverview.asp).