Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to print only the frame and not the whole page using Google Chrome

When I try to print the webpage, only the frame appears in the print when using IE or other browsers. However, through the google chrome, the whole page gets printed.

I have done a little research and found out that adding the OpenFrame plugin would do the trick. However, I am looking for the solution without the plugins. Our product is used by a number of customers and we can't ask them to install any plugins.

Can we fix this by making CSS changes or scripts.

like image 532
Praveen Narsipur Avatar asked Nov 14 '11 03:11

Praveen Narsipur


People also ask

How do I print just the frame of a page in Chrome?

You can print only the selected frame in frameset HTML page. You will see the [Print this frame...] on the context menu by right-clickking in the frame of the page that uses <frameset>. By selecting the menu item, you can print only the contents of the frame. This command does not reload the contents of the frame.

How do I print a page frame?

Right-click in the frame you want to print. Choose Print Frame from the contextual menu.

How do I print a certain part of a page?

Drag a rectangle around the area you want to print. Choose File > Print. Make sure that the Selected Graphic option is selected in the Print Range area of the Print dialog box. (Optional) To enlarge the selected text or graphic to fit the sheet of paper, choose Fit To Printable Area from the Page Scaling pop-up menu.


4 Answers

Using JavaScript you can print frames independently, e.g.

top.frames[1].print()

If you include a print button or listen to print events, you can call your print function that prints only the frame you want.

Or you can use CSS @media print to set what gets printed

like image 149
Denes Papp Avatar answered Sep 17 '22 12:09

Denes Papp


Highlight (select) what you want to print, right-click over the selected area and hit print.

p.s.: No other option worked. The add-on (Chrome app) doesn't have a print option, only open in new window and by doing so it sends a new page request and for many sites it won't work.

like image 38
Joao Leme Avatar answered Sep 17 '22 12:09

Joao Leme


The best way is to use this "Chrome App" to add a Context sub-menu to your Chrome.

After the installation right click on the frame you want to print, select [This Frame] and the select the option that fits the best with your situation, usually [Open Frame in New tab]. Once you have the frame in a new tab you simply print it with CTRL-P or Right-Click [Print].

like image 27
FrancoSF Avatar answered Sep 18 '22 12:09

FrancoSF


@media print { .div-to-not-print {display:none}}

is problematic because

  1. It's not an end-user solution; it has to be done by the page developer, and
  2. We're talking about frames, which are actually independent pages. That sort of solution wouldn't allow a user to print two frames independently.

The suggestion

Click on the File > Print , then use the option Simplify Page

may work in some circumstances, but, for me, it just removes all frames and reverts to the <noframe> content in the frameset page.

As far as I can tell, there is no decent way to print just one frame in a frameset that is already loaded. A Chrome plugin that I haven't tried called "Print This Frame" really just re-loads the frame in a new tab (with a round-trip to the server).

But, without that plugin, if the frame you want to print was created from a hyperlink within the frameset, you can usually load the frame in a separate tab or window just by right-clicking on that link and selecting "Open link in new tab" or "Open link in new window"

like image 36
Robin Richmond Avatar answered Sep 21 '22 12:09

Robin Richmond