Forum: Ruby on Rails multi-page printing moving on

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Craig W. (Guest)
on 2006-02-28 03:08
(Received via mailing list)
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
<div> 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

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

Ben Vaughan (Guest)
on 2006-02-28 06:23
(Received via mailing list)
I guess I may be a bit unclear.  Do you have a separate css file for
media="print"?  And it's not working?

Ben Vaughan
Craig W. (Guest)
on 2006-02-28 06:27
(Received via mailing list)
NO - I just have one css file and it's set for media='all'

Does having separate css files for print and screen matter?

Ben Vaughan (Guest)
on 2006-02-28 07:09
(Received via mailing list)
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.

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

Ben Vaughan
Craig W. (Guest)
on 2006-02-28 21:05
(Received via mailing list)
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
<div> 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 W. (Guest)
on 2006-03-01 08:11
(Received via mailing list)
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 <div>
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
<img> tag - the logo. I change that to position : relative; and left
everything else set to absolute and that formed each page properly.


Ben M. (Guest)
on 2006-03-01 10:49
(Received via mailing list)
position:absolute == evil.

Craig W. (Guest)
on 2006-03-01 16:06
(Received via mailing list)
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 me Anakin.


This topic is locked and can not be replied to.