aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Print Preview instead of print page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Print Preview instead of print page" Watch "Print Preview instead of print page" New topic
Author

Print Preview instead of print page

Sahana Hegde
Ranch Hand

Joined: Jan 27, 2008
Posts: 67
Hi guys,

Is there any way in which I can get the print preview of the page using a javascript.

I am using this function now.

Can I get the print preview of this instead of print?

Thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
JavaScript just has window.print() out of the box so nope. You could look into ActiveX, but that limits you to IE only.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60080
    
  65

The browser provides print preview (as provided by the print architecture of the underlying OS). Why do you need something more than the browser provides?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sahana Hegde
Ranch Hand

Joined: Jan 27, 2008
Posts: 67
If thats not possible then I have another question. When I open the content in the above code in a new window. It keeps loading.The loading of the page does not stop. When I try to go to print preview from the menu it hangs.
Sometimes it does not hang, when I go to print preview gives message "Please try after the page loads"
How can I correct this?
[ December 01, 2008: Message edited by: Sahana Hegde ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
When the window is hanging are you removing the line myWin.document.close();? That line is important and does not close the browser window.

You should swap the print line too:



to



Eric
Sahana Hegde
Ranch Hand

Joined: Jan 27, 2008
Posts: 67
I tried retaining only this code to check if it finishes loading.

Still the same, keeps loading the page.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You did not close the document like I said had to be done in my last post.

You need the myWin.document.close() in there.

Eric
Sahana Hegde
Ranch Hand

Joined: Jan 27, 2008
Posts: 67
works thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Print Preview instead of print page
 
Similar Threads
Printing with DIV tags
Javascript error :object expected
How to include css in new window using javascript
Update OutputText using Java Script.
javascript to insert table and its data into html div tag