Forum How do I...?

Are Multi-Page Invoices Possible

mark_anderson_us
Hi All

I've been looking for an OEM solution to produce quotes, invoices, etc. from XML. Today we use straightforward XSL to transform the XML to HTML. As most of you probably know, most browers don't support enough CSS for paged-media (headers, footers, page-numbering, etc.), so PDF generation is iffy at best.

I looked at several FO solutions and FO will do it, but it means all of our clients have to totally rewrite their XSL's to produce FO instead of HTML with CSS. I then stumbled across PrinceXML and have done quite a bit of testing. Based on my tests, it seems that I can change an existing XSL in about 10-15 mins to produce good PDF with headers, footers and page numbering. To convert the same XSL to FO would probably take 4-8 hours, and means all of our clients and support people need to learn a new technology.

The final hurdle I'm stuck on is headers and footers. With FO I can specify a page-layout for first, any, left, right, last and first = last (single page doc) pages. . So for a multi-page invoice (for example), it should display the following

  • First page: display the header (order details and big logo) and the first set of line items.
  • Continuation pages (except last): should display a different (smaller) header, more lne items and page numbers in the footer.
  • Last page: display the smaller header, last line items, totals and tear off remittance slip at bottom of last page
  • Single page (first page = last page): so it should show the big header, the line items, the totals and remittance slip at bottom of page.

One other minor complication: the footer (on the last page) may be a variable height. (I could probably live without this.)

I searched the forums and found a bunch of stuff pertaining to headers and footers, but I can't get my footer to appear on the last page only. I did see references to page-groups and maps, but couldn't find any documentation on these, so I'm not sure if those will help

Can anyone tell me if Prince is able to do this? It's the last thing that's stopping us pulling the trigger on it. If not, it's Apache FOP :-(

Thanks in advance

Mark
howcome
CSS doesn't have a '@page :last' feature, which would be the easiest way to resolve this. Perhaps this can be added. But there may be other ways of achieving this, too -- especially if the last page can be a named page. Could you show us a sample PDF document?
mark_anderson_us
I would if I could figure out how. Everything I try gives me a "extension not allowed" message. tried .pdf, .txt, .css, and none
howcome
I'm not sure I understand -- didn't you say you have an FO-solution that works? Does it produce a PDF you can share?

Anyway, to find a solution in CSS, I would look for an element that starts the last page and give that element a named page. E.g.:

div.foo {
page: last;
}

@page last {
....
}

If there is no such element, I don't see an obvious solution. Except for Prince to start supporting @page :last, of course.
mark_anderson_us
Hi Mike

I have a couple of PDF's I could share, but can't attach them (see my previous post). Any idea what file types I can upload?

Apache FOP works, but it means all our customers have to learn FO. This is the reason a CSS solution would be preferable.

Unfortunatley, I have no idea what will start the last page, as it will simply be an invoice line item. The only thing I can guarantee will be on the last page is the remittance slip that needs to be anchored to the bottom of the last page, but it will typically have line items as well. The only thing I can guarantee is that the totals and remittance slip will be the last data in the stream.

Looking at your example are you suggesting that if I put some content (e.g. a <br />) in a div with page: last; that whichever page that falls on will have the page name "last"

If so, that may do the trick. I know which is the last line item and I want some sapce between it and the totals/remittance slip.

Regards

Mark
mark_anderson_us
I just tried the last page thing, but it starts a new page with just the totals and remittance slip. Is there a way to just anchor the remittance slip content (a div) to the bottom of it's page (making sure it doesn;t page-break - i.e. it must fit on the page in it's entirety?
mark_anderson_us
I think I solved the footer on the last page. I just used float: bottom; and the remittance slip will start a new page if there is not enough room for it to fit on the last page of line items. Of there is enough, it anchors to bottom.

Now I'm stuck on the header. The header contains a large logo and a ton of stuff pertaining to the order (about 4" in height). The continuation pages' headers should contain a small logo on the left and the invoice number on the right (about 1" high)

I created a @page: first and an @page, but the both get the continuation page's header:

@page:first { 
	 @bottom-right {
                   		content: "Page " counter(page) " of " counter(pages) "FIRST";
                  		padding-top: 1em;
                  		vertical-align: top;
                 		}
		}
					
					
		            
		             
		             @page {
		              		size: US-Letter; 
		               		margin-top: 1in;
		               		margin-bottom: 0.75in; 
		               		margin-left: 0.5in; 
		               		margin-right: 0.5in; 
		            @top { content: "continuation page" }
		            @bottom-right {
				content: "Page " counter(page) " of " counter(pages) "CONTINUATION";
			             padding-top: 1em;
                  			vertical-align: top;
	    			}	             		
		            		}


This gives me different footers for the first page and continuation pages, but I still get the header from the @page rule on the first page.

How do I get a different header on al pages except first?

TIA

Mark
mark_anderson_us
solved it

content: normal for the top on page: first did it

Regards

mark