开发者

Print 2 pages instead of 1

开发者 https://www.devze.com 2023-02-20 20:40 出处:网络
I want to create a page with, for example, static text and loop that will display a list of products. It can be longer than 开发者_运维技巧one page when I print it, but on the second I need todisplay

I want to create a page with, for example, static text and loop that will display a list of products. It can be longer than 开发者_运维技巧one page when I print it, but on the second I need to display not only the remaining products from the list, but the static text too.

for example:

First page content:

static text + list of the products from loop

Second page content (if the list is long enough):

static text + list of the remaining products from the same loop

How do I achieve this? I know this is not enough information given, but at least, can you give me a hint or concept of doing it?!


Since diferent printers might behave a bit differently, the first step I would take is to create a PDF using CF's built-in PDF tools.

If the static text is short and simple, you might get away with using a page header, which would do this automatically. Play around with this before looking at something more complicated, but be aware that (IIRC) you cannot style the page headers.

Next, I would find out how many products fit on a page. If a product can take up variable space, you have choices. You can place each in a statically sized div big enough to hold the largest product. You can make the div big enough for ost products, and use the overflow CSS property to hide the est of larger products. You can use a simple list, and hope it doesn't overflow. :-)

Between these page sections use the CSS page break attributes (eg page=break-before and page-break-after) to force page breaks exactly where you want them. Note that these cannot prevent a page break, only force one, so I would use one of the first two methods I suggested to make sure you don't overflow your page.


It's probably overkill, but the CF Report Builder (and, by extension, <cfreport>) is made specifically for this sort of thing.

You define header bands and whether they appear on every page, in every section, only at the beginning/end of the report, etc.


Ben's answer is the best you will probably find. Having worked with printing and PDFs, it can be a crap-shoot depending on the content. Sometimes the break will behave and other times it will not. Your best bet is to keep your content chunks as small as possible and the PDF/CSS page breaking will handle it well.

0

精彩评论

暂无评论...
验证码 换一张
取 消