PDF Export with Template and Title over Cover Image

Hi,

I am using the PDF Export Application to export a single page using a custom PDF Template to specify a custom cover image.

The preview of the template looks good in xwiki. But when I invoke the PDF Export then I get an empty first page and my cover image is on the second page.

It seems like the default cover is somewhat still retained:
grafik

Is there a way to get rid of the original default cover page?

Wish you a good time
secbob

1 Like

I use this velocity template in the cover property of the template class:

{{velocity}}
{{html clean="false"}}
<div style="position: relative; width: 100%;">
  <img style="width:100%;" src="$xwiki.getAttachmentURL("MyPage.WebHome", "Cover.png")" />
  <h1 style="position: absolute; width: 100%; text-align: center; top: 23%; left: 50%; transform: translate(-50%, -50%); color: #fff;">$escapetool.xml($tdoc.plainTitle)</h1>
</div>
{{/html}}
{{/velocity}}

This is a lot of code for just a background-image, but I don’t know if it is possible to have the same functionality but with less code.

Have you tried to use these steps to investigate the problem https://extensions.xwiki.org/xwiki/bin/view/Extension/PDF%20Export%20Application/#HUnexpectedPDFOutput ?

I really doubt it. Whatever you put in the “cover” field of your custom PDF template is rendered instead of the default cover.

Are you sure this is just for the background image? I see also a heading there. You can make the cover page as complex as you wish. Having only a background image on the cover page is just one use case, that could be solved with wiki syntax:

[[image:Some.Page@cover.png||style="..."]]

But for more complex cover pages you may need scripting.

Hope this helps,
Marius

Thanks for mentioning the Unexpected PDF Output section. Inspecting the iframe is very helpful!

I found my mistake as I could also reproduce this behavior with the wiki syntax for the image.

I opened the PDF Template page with the object editor and saw that there was an XWiki.StyleSheetExtension with some styles that I didn’t need, I think they were generated when I added the Template:

grafik

Once I deleted it, everything was working as expected :relaxed:

Thanks for reading, have a nice day!