Jump to content

Recommended Posts

Hey there,

 

We have a pretty specific challenge & would love thoughts about how to overcome. The challenge is that we have several web pages of unknown length, and need to calculate how many printable pages they will result in if printed. We calculate that each printable page can contain about 600 vertical pixels of content.

 

Does anyone have any idea of how to construct a function that would tell us how many printable pages an html page might be (if run through the function) and/or a way to show thumbnails thereof?  Or any good starting points - those would be great as well!

 

Thanks for any insights you have!

--Dave / Public Learning Media Labs

 

 

just make all pages needed printer friendly.



<link href="/css/screen.css" rel="stylesheet" media="screen" type="text/css" id="screencss" />
<link href="/css/print.css" rel="stylesheet" media="print" type="text/css" id="printcss" />

//And use this javascript to toggle:

function togglecss() {
var screencss = document.getElementById('screencss');
var printcss = document.getElementById('printcss');
if (screencss.flag == true) {
screencss.href = screencss.oldhref;
screencss.flag = false;
//alert('When you are done printing, just click the \'printer Friendly\' link again.');
} else {
screencss.oldhref = screencss.href;
screencss.href = printcss.href;
screencss.flag = true;
}
}

//And a link like so:

<a href="#" onclick="togglecss();return false;">printer Friendly</a> 

He wants us to find the begging of a webpage to the end of a web page, then he wants to calculate.

how many pages the web page would take to print to a printer.

 

but there no real way in doing that because everybody got different printer drivers to print pages.

 

also will the user care how long the page's are.

 

when you print a document the printer driver tills you how many pages there are to be printed.

 

you don't tell it.

the only way you could do this if it a dedicated printer and computer and only that printer is printing the web pages in question.

 

but saying that you got me thinking, maybe a big maybe you can use exec to open the file tab on a browser then exec print preview then get that info to the user maybe.

 

big project and time theo.

 

 

 

 

 

 

 

 

 

Hey Guys,

 

Yep, I know. But imagine if you could create a low-rez pdf of the page - actually, maybe that's the way to do it? run a script to convert the page to PDF, and then count PDF pages? Would that be possible?

 

--Dave

 

 

He wants us to find the begging of a webpage to the end of a web page, then he wants to calculate.

how many pages the web page would take to print to a printer.

 

but there no real way in doing that because everybody got different printer drivers to print pages.

 

also will the user care how long the page's are.

 

when you print a document the printer driver tills you how many pages there are to be printed.

 

you dont tell it.

 

 

 

 

sounds like a great idea dhcrusoe, i think it would def get the job done! :-)

 

http://www.rustyparts.com/pdf.php

http://www.digitaljunkies.ca/dompdf/

 

there plenty of html to pdf scripts out there... i haven't ever needed one so i don't know which one is best...

 

ie only print preview

 

<html>
<head>
<title>Print Preview</title>
<script>
function printpr()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}
</script>
</head>
<body>
<form>
<input type='button' value="Print Preview" onclick="printpr();">
</form>
</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.