I don't even really see how this makes sense. I guess it makes a little eensy-weensy bit o' sense if everything on the page is absolutely positioned and sized, but the size of rendered HTML is really a function of the browser. You could, for instance, "render" it with lynx -dump and count the lines.
How do you take into account the user's screen size and resolution? Or whether they resize the browser window? Or use custom styles? Etc.
You should probably be asking yourself if you really need to do this.
-sauoq
"My two cents aren't worth a dime.";
| [reply] |
Ok, this whole thing makes about as much sense to me as it seems to be making to everyone else but here's an approach that might work.
- write the HTML out to file 'X' but before you do that,
add a JavaScript function (triggered by onLoad) and wrap the body of the page in a div with an id 'Y'
- have your script fire up a browser and on its command line give it the URL of file 'X'
- when the JavaScript function is called, have it query the height and width properties of div 'Y' and submit these details to a CGI script
- have the CGI script signal your original script that it's all over and the browser process can be killed.
With Mozilla remoting, you can instruct an already running browser process to load a particular URL so I guess you could skip steps 2 and 4. Step 1 could be done on the fly by a CGI script. You could use CSS to set the width of div 'Y' to be fixed and then measure the height.
| [reply] |
Not to mention many browsers let you resize by percentage on the fly -- size is relitive. What are you trying to do? What is the actual usable output that you are looking for.
-Waswas | [reply] |
| [reply] |
As many people have already pointed out, the 'actual' size of a page depends on the browser, the user's browser preferences, the user's display resolution, the system installed fonts, the display preferences, the user's OS platform, the font aliasing preferences, and the user's browser window size. Occasionally it depends on the phase of the moon, but only at high tide or when pluto is in the House of Aquarius.
HTML doesn't define presentation at all, and HTML with CSS makes really strong suggestions about presentation, but still doesn't define it exactly. (Assuming any browser actually completely and accurately implements the CSS specs, which none do. (Not even counting the spots in the CSS specification that aren't exact enough to definitively render))
The best you're going to be able to do is make a 90% guess. Using an existing rendering engine would be the way to do this, but if you're going to use the result to influence the design as presented to other people, you're probably better off using the IE/Windows HTML rendering engine, as it disagrees with Mozilla on quite a few things and, like it or not, is significantly more used. (And no, I have no idea how you'd do this) | [reply] |
Another way may be using something like wxPerl...I'm only guessing, but looking at the docs, it looks like it should be possible. wxHTMLWindow sets its *height* (you specify the width on creation) based on its rendered HTML, and you should then be able to use wxScrolledWindow::GetVirtualSize() to determine this.
Cheers, Ben. | [reply] |
I'm more than a little confused. My first thought was that you wanted the size of the file in bytes, but the following dicussion doesn't bear that out. Perhaps you could mention what sort of "measure it" you're refering to: inches, pixels, %of screen width, ... Some of the monks might be able to derive a better solution if you could breifly say why this is a need and where you want this info: for your eyes only, part of the HTML page, info with which to better render the page, etc.
-ted-
| [reply] |
| [reply] |