# Multi-page printing moving on

**URL:** <https://www.ruby-forum.com/t/multi-page-printing-moving-on/74482>\
**Category:** Rails\
**Created:** [February 28, 2006, 2:08am UTC](https://www.ruby-forum.com/t/multi-page-printing-moving-on/74482 "2006-02-28T02:08:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 28, 2006, 2:08am UTC](https://www.ruby-forum.com/t/multi-page-printing-moving-on/74482/1 "2006-02-28T02:08:04Z")

</div>

I have some nice forms done using stylesheets. I currently have them  
displaying on screen and the user could simply just print.

This works when there is only one form (facility) to be viewed/printed.

I have created the looping code necessary to print for all facilities  
but that doesn’t work for me because each page uses stylesheets with

 that do absolute positioning and thus each form overlays the previous forms and it becomes a blurry mess.

When using css, there are styles strictly for printing that allow the  
use of ‘page breaks’ but given the format I am doing (viewing on screen  
and then printing), this clearly doesn’t work.

So I looked at other methodologies…

HTMLDOC doesn’t support stylesheets

PdfWriter has it’s own markup code

PDF::Writer has it’s own markup code

I suppose the only thing I can do is simply render to print and I  
haven’t a clue on how to do that (client side javascript?) or render to  
file.

Anybody doing something like this that can push me in a direction?

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 28, 2006, 5:23am UTC](https://www.ruby-forum.com/t/multi-page-printing-moving-on/74482/2 "2006-02-28T05:23:56Z")

</div>

I guess I may be a bit unclear. Do you have a separate css file for  
media=“print”? And it’s not working?

Regards,  
Ben Vaughan

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 28, 2006, 5:27am UTC](https://www.ruby-forum.com/t/multi-page-printing-moving-on/74482/3 "2006-02-28T05:27:50Z")

</div>

NO - I just have one css file and it’s set for media=‘all’

Does having separate css files for print and screen matter?

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 28, 2006, 6:09am UTC](https://www.ruby-forum.com/t/multi-page-printing-moving-on/74482/4 "2006-02-28T06:09:06Z")

</div>

Definately. If you try to combine your screen layout rules with your  
print rules, I’m not surprised it’s not working. Best practice is to  
create a separate stylesheet just for print. There’s a good write up  
from Eric Meyer (one of CSS’s creators) at A List Apart.

> **[CSS Design: Going to Print](https://alistapart.com/article/goingtoprint/)**
>
> Say no to “printer-friendly” versions and yes to printer-specific style sheets. CSS expert Eric Meyer shows how to conceive and design print style sheets that automatically format web c…

It might not be a perfect fit for your situation, but it’ll help out  
with a lot of the basics.

Regards,  
Ben Vaughan

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 28, 2006, 8:05pm UTC](https://www.ruby-forum.com/t/multi-page-printing-moving-on/74482/5 "2006-02-28T20:05:18Z")

</div>

I still haven’t verified the issue and I will later on - I was able to  
get the page break to function not when I split the stylesheets into  
separate stylesheets for screen & print but when I made the very first

 object on the page NOT use position : absolute; - this is all very hair splitting stuff.

I do plan on getting back to this and nailing it all down once and for  
all and I just wanted to say thanks for the guidance and the direction  
to the the interesting information at alistapart.

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [March 1, 2006, 9:49am UTC](https://www.ruby-forum.com/t/multi-page-printing-moving-on/74482/6 "2006-03-01T09:49:28Z")

</div>

position:absolute == evil.

b

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [March 1, 2006, 3:06pm UTC](https://www.ruby-forum.com/t/multi-page-printing-moving-on/74482/7 "2006-03-01T15:06:46Z")

</div>

On Wed, 2006-03-01 at 00:51 -0800, Ben M. wrote:

> position:absolute == evil.

* * *

excepting of course, when it works. 😉

I’m new at this…I’m learning and yes, I have discovered the dark  
side…call me Anakin.

😉

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [March 1, 2006, 7:11am UTC](https://www.ruby-forum.com/t/multi-page-printing-moving-on/74482/8 "2006-03-01T07:11:55Z")

</div>

As it turned out, it really didn’t matter if the media rules were  
separate for screen/print or if they were the same and I set the media  
type ‘all’, once I fixed the issue of page breaks, it pretty much worked  
for both.

The issue turned out to be ‘positioning’ as I had set all the

  
elements to be absolute positioning which meant that page breaks created  
new blank pages as opposed to to rendering each form on it’s own page.

The way that I ultimately solved it seemed rather innocuous but it was  
effective. The first element to be printed/viewed on the page was an  
 ![]() tag - the logo. I change that to position : relative; and left  
everything else set to absolute and that formed each page properly.

Thanks

Craig
