Log in

View Full Version : Printer Friendly pages (print preview)



Girard Ibanez
09-14-2006, 09:01 PM
I got my print.css style sheet set for a printer friendly pages.

I when I click on the Printer Friendly Button on the page, it opens up the printer screen.

Is there a way so that when you click on the print button, it opens the print preview function, then the user can see if the page fits his margins and if so, click the print button on that window?


www.myraptor.net click on one of the drop down menus to see the page.


Thanks,

Girard

mwinter
09-17-2006, 08:16 PM
I when I click on the Printer Friendly Button on the page, it opens up the printer screen.

If scripting is enabled. In my opinion, it's better to just let the user use the menu or toolbar item in their browser.



Is there a way so that when you click on the print button, it opens the print preview function, then the user can see if the page fits his margins and if so, click the print button on that window?

No, not to my knowledge.

Mike

mburt
09-17-2006, 08:50 PM
For a page without graphics and stuff:

document.write(document.body.innerText)

Girard Ibanez
09-17-2006, 09:44 PM
This is the code I am using for the printer friendly button. It pops up the printer properties (control P).


<input name="Printer Friendly" type="button" value="Printer Friendly" class="cursor" onclick="window.print()" />


I tried:
document.write(document.body.innerText)

But it keeps searching.

mburt
09-17-2006, 10:19 PM
document.write(document.body.innerText)

is for making a printer-friendly page without graphics and links and other unwanted stuff.

mwinter
09-17-2006, 10:24 PM
document.write(document.body.innerText)

is for making a printer-friendly page without graphics and links and other unwanted stuff.

No, it most certainly is not. Girard is already doing it properly by using a print style sheet.

The innerText property is proprietary feature that isn't implemented in most browsers. Moreover, preparing a printable document should never depend upon scripting.

Mike

mburt
09-17-2006, 10:28 PM
Okay, I see you're point. I think you can print directly with PHP though, can you?

Girard Ibanez
09-18-2006, 01:17 AM
So I guess there is no way to call out the "Print Preview" function.

Thanks again guys for the assistance.

blm126
09-18-2006, 02:17 AM
I think you can print directly with PHP though, can you?
No, PHP is serverside. I know of no way to print a page from PHP(unless you are talking about a printer attached to the server)

Girard Ibanez
09-18-2006, 03:13 AM
The print style sheet is working and the pages are formatted so that the user can print the web document without the navigational bar, etc. and the browser will not clip the image files.

I have a print radio button that will pull up the printer page properties but what I want is for the radio button to pull up the print preview for that browser so that he can adjust his margins and then print the page.

All this can be done at the browser menu but I created a radio button with the words "printer friendly" and wanted to make the button functional.

http://team-raptor.net/myraptor/r50v2/raptor_50v2_flybar_control_arm_tip.html



Girard

djqj
05-25-2011, 07:57 PM
You may try VIEWidget from
http://hexatech.com/viewidget

It is a javascript-programmable report & technical drawing generator and print preview control.
You may use VIEWidget to generate reports or technical drawings,
display the results in a scrolling and zooming viewer on your web page and then print it.
It is a very flexible and productive RAD tool as it lets you freely draw tables or
other objects at arbitrary x-y coordinates.
Below is a simple Hello World example with two print-preview pages generated:

//get length unit
var INCH = control1.getInch();

//create document
control1.startDoc();

control1.drawString(1*INCH, 1*INCH, "Hello World from Page 1");

//...draw other stuff here

//create 2nd page
control1.newPage();
control1.drawString(1*INCH, 1*INCH, "Hello World from Page 2");

//...draw other stuff here

//end document
control1.endDoc();

//preview first page (page index=0)
control1.setCurrentPage(0);
control1.preview();