XAceX Posted June 4, 2007 Share Posted June 4, 2007 I don't have much experience with Java Script. But I was wondering. Is it possible to make a print button that doesn't print the entire page. Like say I had a table with some documents that are both HTML and PDF. I have two sets of check boxes one set to select PDF versions of the documents and the other set for html. I need to make one button that will print only the html and one for the PDF. Kinda looks like this(sorry it's so crappy lol): Link to comment Share on other sites More sharing options...
justsomeguy Posted June 5, 2007 Share Posted June 5, 2007 You're not able to print a specific document that is not open. You would have to open the document first and then print it, which you can all do from the parent window. You could do something like this: //first open the document in a new windowprint_obj = window.open("document.pdf", "print_window", "");//now call the print method on the new windowprint_obj.print();//if that doesnt work, do it this wayprint_obj.window.print();//you can even close the window from the parentprint_obj.close(); For static HTML that is pretty easy, the user would see the window open, a print box pop up, they hit Ok or Print, the window closes and the document prints. For things like PDF files that require a plugin for the browser to use them, I'm actually not even sure if window.print works in that situation since it is calling the print function of the web browser and not necessarily the print function of the document plugin. Hopefully that made sense. Link to comment Share on other sites More sharing options...
XAceX Posted June 6, 2007 Author Share Posted June 6, 2007 It made sense haha thank you so much for your help! You're not able to print a specific document that is not open. You would have to open the document first and then print it, which you can all do from the parent window. You could do something like this://first open the document in a new windowprint_obj = window.open("document.pdf", "print_window", "");//now call the print method on the new windowprint_obj.print();//if that doesnt work, do it this wayprint_obj.window.print();//you can even close the window from the parentprint_obj.close(); For static HTML that is pretty easy, the user would see the window open, a print box pop up, they hit Ok or Print, the window closes and the document prints. For things like PDF files that require a plugin for the browser to use them, I'm actually not even sure if window.print works in that situation since it is calling the print function of the web browser and not necessarily the print function of the document plugin. Hopefully that made sense. Link to comment Share on other sites More sharing options...
XAceX Posted June 6, 2007 Author Share Posted June 6, 2007 ooo actually I do have another question though. Rather than it opening in a new window and poping up with the print button, how would I have it just open in a new window? or rather the user can click the check boxes for which ever documents they would like to open. Then click some button im not sure what it will be and it just opens the documents. There are already print page buttons on each document. I think your right in the fact that you need plug ins and stuff for the pdfs. They will obviously have a different printing option. All I need now is a way to use the check boxes to just open the Docs in new windows. Link to comment Share on other sites More sharing options...
aspnetguy Posted June 6, 2007 Share Posted June 6, 2007 just do the same thing except one for every documentprint_obj1 = window.open("url1", "print_window1", "");print_obj2 = window.open("url2", "print_window2", "");etc,etc Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.