This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Print Preview instead of print page

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript just has window.print() out of the box so nope. You could look into ActiveX, but that limits you to IE only.

Eric
 
Marshal
Posts: 67366
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Sahana Hegde
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried retaining only this code to check if it finishes loading.

Still the same, keeps loading the page.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
works thanks a lot.
 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!