MozillaZine

Printing selection

User Help for Mozilla Firefox
Kejpa
Guest
 

Post Posted January 24th, 2007, 8:03 am

Hey!
When I'm trying to print the selection of a website I get it wrong :(
I want to have it at the left edge of the paper, no matter where it's placed on the web page.

I'm currently using FF version 2.0.0.1 this is what the About box says...
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1

Thanx!
/Kejpa

jscher2000

User avatar
 
Posts: 10752
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA

Post Posted January 24th, 2007, 1:00 pm

I think Print Selection has always worked that way. Sometimes you can change your selection and get slightly different results, but it's hit or miss. I'm not sure why that is, but I suspect it might not be easy to fix or it would have been fixed long ago. :-)

I have read about one or more extensions that let you tweak the appearance of a web site. For example, you could click on a wide elements on the left side of the page and make it disappear. This won't always change the way a page prints, because a page often has a print-specific stylesheet, but maybe it will help in some cases. Sorry, I don't remember the name of that extension.

kejpa
Guest
 

Post Posted January 24th, 2007, 2:03 pm

I'm most certain that it has, I'm however not a fan of it.
I used to use IE and there it's not working that way.

I find it most frustrating and I sure hope it's fixed as soon as possible!

jscher2000

User avatar
 
Posts: 10752
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA

Post Posted January 25th, 2007, 1:11 am

Edit: Updated to version 0.2 on 25 Jan 2007 12:40AM PST

Here's an idea. Rather than use Print>Selection, you can use a little JavaScript to grab the selection and position it at the top left. The quickest way to do this is a "bookmarklet". The following is some pretty rough "beta" code, but it works in my little test so far. (In Firefox; not tested elsewhere.) After printing, you have to reload the page to return it to normal.

Here's how you can install it:
  • Open the Bookmarks Manager dialog (Bookmarks>Organize Bookmarks...)
  • Click Bookmarks at the top of the "tree" in the left column, then click the New Bookmark button
  • Copy and paste this into the Name space, or choose a Name you like:
    Code: Select all
    Crop4Print v0.2
  • Copy and paste the following into the Location space:
    Code: Select all
    javascript:var sel=window.getSelection(); if(!sel.isCollapsed){var rng=sel.getRangeAt(0); if(!rng.collapsed){var docfrag=rng.cloneContents(); var rng2=document.createRange(); rng2.selectNodeContents(document.body); var myContainer=document.createElement(%22DIV%22); rng2.surroundContents(myContainer); myContainer.setAttribute(%22id%22, %22hideMe%22); myContainer.style.display=%22none%22; rng2.detach(); document.body.appendChild(docfrag); rng.detach();}} void 0;
  • Copy and paste the following into the Description space (it's the URL to this thread, in case problems or questions come up in the future):
    Code: Select all
    http://forums.mozillazine.org/viewtopic.php?t=513572
  • Click OK to save it
The way bookmarks sort in the Bookmarks Manager and on the menu is somewhat unpredictable. It should be there somewhere. :-D

To test it out, select something on a page and then run the bookmarklet. It should move the selected material to the left side and "white out" the rest of the page. Sometimes it takes 5-8 seconds, for no apparent reason. It's possible that there will be color problems because the selection is taken out of its original context... I look forward to feedback.

jscher2000

User avatar
 
Posts: 10752
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA

Post Posted January 26th, 2007, 12:12 am

Edit: Updated to version 0.5 on 25 Jan 2007 at 11:35 PM

How about a new version. A (non-printing) button appears below your selection. Click the button to restore the page. Note that repeated use of the bookmarklet without reloading may cause some errors. But at least you don't have to reload just to keep reading the rest of the page.

Here's how you can install it:
  • Open the Bookmarks Manager dialog (Bookmarks>Organize Bookmarks...)
  • Click Bookmarks at the top of the "tree" in the left column, then click the New Bookmark button
  • Copy and paste this into the Name space, or choose a Name you like:
    Code: Select all
    Crop4Print v0.5
  • Copy and paste the following into the Location space:
    Code: Select all
    javascript:var sel=window.getSelection(); if(!sel.isCollapsed){var rng=sel.getRangeAt(0); if(!rng.collapsed){var docfrag=rng.cloneContents(); if(!document.getElementById(%22divHideMe%22)){var rng2=document.createRange(); rng2.selectNodeContents(document.body); var myContainer=document.createElement(%22DIV%22); rng2.surroundContents(myContainer); myContainer.setAttribute(%22id%22,%22divHideMe%22); rng2.detach();} myContainer.style.display=%22none%22; if(document.getElementById(%22printFrag%22)){var myFrag=document.getElementById(%22printFrag%22); while(myFrag.firstChild) {myFrag.removeChild(myFrag.firstChild);} myFrag.style.display=%22block%22;}else{var myFrag=document.createElement(%22DIV%22); myFrag.setAttribute(%22id%22,%22printFrag%22); document.body.appendChild(myFrag);} myFrag.appendChild(docfrag); rng.detach(); var myP=document.createElement(%22P%22); myFrag.appendChild(myP); myP.setAttribute(%22id%22,%22killBtn%22); var myBtn=document.createElement(%22INPUT%22); myP.appendChild(myBtn); myBtn.setAttribute(%22type%22,%22button%22); myBtn.setAttribute(%22value%22,%22Return to Page%22); myBtn.setAttribute(%22onclick%22,%22document.getElementById(%27divHideMe%27).style.display=%27block%27; document.getElementById(%27printFrag%27).style.display=%27none%27;%22); myStyle=document.createElement(%22STYLE%22); myFrag.appendChild(myStyle); myStyle.setAttribute(%22type%22,%22text/css%22); myStyle.setAttribute(%22media%22,%22print%22); myStyle.innerHTML=%22#killBtn{display:none}%22;}} void 0;
  • Copy and paste the following into the Description space (it's the URL to this thread, in case problems or questions come up in the future):
    Code: Select all
    http://forums.mozillazine.org/viewtopic.php?t=513572
  • Click OK to save it
  • To place the new bookmark on the Bookmarks toolbar, drag it into Bookmarks Toolbar Folder

Enjoy, or report your non-enjoyment, as the case may be.
Last edited by jscher2000 on February 13th, 2007, 5:33 pm, edited 1 time in total.

Geoff K
 
Posts: 8
Joined: November 23rd, 2005, 9:53 am

Post Posted January 26th, 2007, 11:18 am

Off to work now, but I had time to try it on your instructions. It Worked! Thanks much. Now, for a dumb question; why is there a "print selection" check box if it is always going to be grey?

Geoff
Geoff Kloster

jscher2000

User avatar
 
Posts: 10752
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA

Post Posted January 26th, 2007, 9:19 pm

Geoff K wrote:...why is there a "print selection" check box if it is always going to be grey?

It works on my Windows system. Not sure what could be wrong on your system, sorry.

retep_rellek
 
Posts: 1
Joined: January 11th, 2008, 9:48 am

Post Posted January 11th, 2008, 9:51 am

This is the coolest trick ever, thanks sooo much!

NJPete
Guest
 

Post Posted January 18th, 2011, 8:30 pm

Worked in Firefox on Mac OS 10.5.8

Really cool, thanks for that. It helped me print out my daily agenda that was in Google Calendar. I wasn't able to print my agenda for the day, including the details. I had selected all the events, but the bottom always got cut-off. This code worked. Certainly not laid out as pretty with the alignment, but I get everything I need in the print-out. Thanks.

Return to Firefox Support


Who is online

Users browsing this forum: No registered users and 14 guests