Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Page Breaks

3 views
Skip to first unread message

Bill Stephenson

unread,
Mar 5, 2009, 2:25:44 PM3/5/09
to beginners cgI
Does anyone know where I can learn how to make smooth page breaks in
dynamically created HTML documents.

Most of the document is contained in a table and the number of rows is
a variable as well as the number of lines of text in each row.

I'd like to be able to know when a document has exceeded a single page
and then direct where the page break will be and format additional
pages.

Kindest Regards,

--
Bill Stephenson

Shaun Fryer

unread,
Mar 5, 2009, 2:41:52 PM3/5/09
to beginn...@perl.org
This shouldn't be that difficult if you know how many lines/rows you
want on each page. How are you generating the HTML? Are you doing it
via CGI.pm, Template::Toolkit, HTML::Template, something else? That
will be the defining factor as to how you'd go about it.

--
Shaun Fryer
http://sourcery.ca/

> --
> To unsubscribe, e-mail: beginners-cg...@perl.org
> For additional commands, e-mail: beginners...@perl.org
> http://learn.perl.org/
>
>
>

Shaun Fryer

unread,
Mar 5, 2009, 3:39:10 PM3/5/09
to Bill Stephenson, beginn...@perl.org
Without providing actual code, the approach I'd recommend is to
accumulate in a data structure something such as the following.

my $tables = [
[ # table/page 0
[ # row 0
q| line 0 of row 0 |, # this just represents a line of
user-input, presumably as obtained from Text::Wrap
q| line 1 of row 0 |,
q| line 2 of row 0 |,
],
[ # row 1
q| line 0 of row 1 |,
q| line 1 of row 1 |,
q| line 2 of row 1 |,
],
],
[ # table/page 1...
], #....
];

I'm assuming above that you have only one column of text per row.
Anyway, finally in your HTML::Template, loop through $tables and break
your text in the appropriate spots accordingly. If you need more
specific help, ask away.

--
Shaun Fryer
http://sourcery.ca/

On Thu, Mar 5, 2009 at 2:56 PM, Bill Stephenson <bi...@perlhelp.com> wrote:


> On Mar 5, 2009, at 1:40 PM, Shaun Fryer wrote:
>
>> This shouldn't be that difficult if you know how many lines/rows you
>> want on each page. How are you generating the HTML? Are you doing it
>> via CGI.pm, Template::Toolkit, HTML::Template, something else? That
>> will be the defining factor as to how you'd go about it.
>

> Thanks for the reply Shaun.
>
> I'm using CGI.pm to process forms and HTML::Template to fill in the
> processed data. For the most part it is formatted with CSS. I use Text::Wrap
> as well.
>
> Basically, right now I let user fill in as much data as they want and let
> the client side deal with page breaks, but that is pretty sloppy and I'd
> like to improve it.

Greg Jetter

unread,
Mar 5, 2009, 8:53:55 PM3/5/09
to beginn...@perl.org

you can use CSS to manage where you want the page breaks to go

something like :

hr.break {page-break-after: always; width: 0px;}

then call it in your page with something like :
<hr class="break"></hr><br>


hope this helps

Greg

Sean Davis

unread,
Mar 5, 2009, 2:47:04 PM3/5/09
to Bill Stephenson, beginners cgI
There are a number of CPAN modules for doing paging. You cannot know what
the size of the "page" is, though, in general. All you can do is to set the
number of rows per page and then page based on that.

Sean

0 new messages