Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print repeating Page headers in Chrome [closed]

Does anyone have a link to an article or working example of repeating page headers/footers from Chrome specifically?

Background:
I've spent days on this with no luck, there are several Stack proposed solutions but none seem to work (in Chrome). Since we use Chrome at work I've only tested there, so a lot these below say Chrome just can't do it, but maybe I overlooked something?

I tried these Stack links (..and many more):

Print footer on every printed page from website, across all browsers (Chrome)

Is there a way to get a web page header/footer printed on every page?

How to use HTML to print header and footer on every printed page of a document?

Creating page headers and footers using CSS for print

If I can't, use repeating header/footers ...then my next idea is to count my rows in my clone object and have it break at a max number, create a new page (forced height) and start the loop again in another page in another div.

I truly appreciate any suggestions on running header/footer solution as the whole point to my app was the finished printed proposal.

like image 265
zzipper72 Avatar asked Oct 28 '13 23:10

zzipper72


People also ask

How do I stop my header from printing?

In the Chrome menu, click Print… to open the print preview screen. Click More Settings. Uncheck Headers and Footers.

How do you print all pages on Google Chrome?

1. Open the web page. 2. Press Ctrl + A 3.

How do you repeat a header on each page in HTML?

This can be done setting a CSS property for the thead element of the html table. The property that needs to be set is: display: table-header-group. The following html table will repeat the table header at the top of each pdf page when converted to pdf.


1 Answers

Ok, no takers on this one, so with a few more days of looking around and choosing not to write my own solution, here is what I found.

At the very bottom of a Stack post with no votes and no comments was this lonely little link: http://welcome.totheinter.net/columnizer-jquery-plugin/#comment-53243

This thing is awesome, it's designed to handle wide pages of content and format them into columns like a newspaper. It handles page breaks especially well and is quite flexible.

In my case, I needed a single column (width of the page) and repeating headers and footers. I used Example 10 as my base:http://welcome.totheinter.net/autocolumn/sample10.html

I simply added the link to the plug in, changed the necessary IDs and classes to suit my page, and made some minor CSS changes to heights and widths and I was able to print multi-page content with repeating headers and footers in Google Chrome! (my company's preferred browser)

TIPS:

  • One little CSS trick, I made the content div MIN-HEIGHT set so it pushed the footer down on short pages. (Don't do this if you want the user to have the option of portrait or landscape). My final print is fixed so this was great for me.

  • I tested different heights on content to see how it breaks the content, it was smooth everytime.

I did try to post my final example in JsBin and Fiddle, but it ran an error each time.

So again, Example 10 above is a great place to start as it shows before and after.

Here is my final with variable height content and repeating Headers and Footers: (this is the view when I click the browser Print Link/Button in Chrome ) enter image description here

UPDATE 7/2014: Once again Chrome is the bane of my existence with print issues. I saw the comment below about the link that I provided. He's right, it renders correctly but the print view is incorrect. Sorry about that, but it's still a good example to play with to learn the settings.

I am still using this solution, IT DOES work, but you have to adjust the CSS and the JS var for body content size. The sizing combinations are VERY Sensitive, but when you get the page height/width right and the content size right, it does work. I had to write separate functions for paper sizes legal/letter. It's limited but works for our purposes.

I also noticed that depending on my window size it did not not always look right, but the final PRINTED product was as expected with repeating headers and footers, so I used a window that went straight to print so the user didn't notice the output, but rather saw the chrome print rendering. I hate these types of workaround but with everyone in my office using Chrome, it's a necessary evil.

like image 174
zzipper72 Avatar answered Oct 03 '22 18:10

zzipper72