Background image just for for cover page

1,235 views
Skip to first unread message

sam

unread,
Apr 19, 2009, 9:45:28 PM4/19/09
to Pisa XHTML2PDF Support
Hello,

I've just started exploring xhtml2pdf and it's producing very
attractive pdfs. I've two small points that I'm stuck on:

1. When using the @page tag I can place the background image, but I
don't want to repeat it for the whole document, I only need it for the
opening cover page. Is there a way of doing this. I've also found that
I can't center the background image - an image which is 210mm X 287mm
fits perfectly (the size of A4).

@page {
background-image: url(210x297.pdf);
size: a4 portrait;
margin: 1cm;
margin-bottom: 2.5cm;

2. Can't place an image in the footer - below doesn't work...?

@frame footer {
-pdf-frame-content: footerContent;
-pdf-frame-border: 1;
background-image: url(ip-footer-logo.jpeg);
bottom: 2cm;
margin-left: 1cm;
margin-right: 1cm;
height: 1cm;
}

Thanks in advance - Sam

sam

unread,
May 20, 2009, 12:24:56 AM5/20/09
to Pisa XHTML2PDF Support
Okay - I've been a bit slow to get all this together but it's working
like a treat so I thought that I'd share.

This is the basic structure of the HTML and CSS to produce a mulitpage
PDF doc with a cover sheet using pisa.

This CSS shows two page templates defined, the first one is for the
cover page the only thing printed on this page is the first <h1> tag
ust below the body tag in the html example.

The <pdf:nexttemplate name="maintmpl"> tag then tells pisa to use the
next page template defined in the CSS '@page maintmpl' this is the
template used for the rest of the document. I have also added a footer
that add page numbers to the bottom of each page.

Anyway I hope this helps other newbies get to grips with pisa nice and
quickly - a very useful bit of software.


CSS :
@page {
background-image: url('Cover.jpg');
top: 14cm;
left: 2cm;
right: 2cm;
height: 2cm;
}


@page maintmpl {
size: a4 portrait;
margin: 1cm;
margin-bottom: 2.5cm;
@frame footer{
-pdf-frame-content: footerContent;
bottom: 1cm;
margin-left: 1cm;
margin-right: 1cm;
height: 1cm;
}
}

HTML doc :

<html>
<body>
<h1> This is the cover page</h1>
<div>
<pdf:nexttemplate name="maintmpl">
</div>
<div>
<pdf:nextpage />
</div>
<--html page 1 -->
<div>
<pdf:nextpage />
</div>
<--html page 2 -->
<div>
<pdf:nextpage />
</div>
<--html page 3 -->
<div>
<pdf:nextpage />
</div>

<div id="footerContent">
<table class="borderless">
<tr>
<td>Customer No. 417</td><td><span id="page-num">
<pdf:pagenumber>
</span></td>
</tr>
</table>
</div>
</body>
</html>

Keith Avery

unread,
Jun 18, 2009, 2:18:27 PM6/18/09
to Pisa XHTML2PDF Support
Is there a way of pulling this off without an explicit pagebreak?

Sam

unread,
Jun 18, 2009, 5:14:41 PM6/18/09
to xhtm...@googlegroups.com
Hi Keith - can you explain in what context the solution above wouldn't
work for you. I don't really understand what your problem?

Cheers

Sam




2009/6/19 Keith Avery <keith.mars...@gmail.com>:

Keith Avery

unread,
Jun 19, 2009, 12:43:12 PM6/19/09
to xhtm...@googlegroups.com
Hello Sam;
I am obviously doing something trivial I am overlooking, as your example does work for me (filled up the page with greeked text and it pagebroke automatically just fine with the new template) I must just have something not matching up properly. Thanks for the followup.
Keith

2009/6/18 Sam <sam.bl...@gmail.com>



--

Keith Avery
keith.mars...@gmail.com

Reply all
Reply to author
Forward
0 new messages