Use custom PDFTemplate by default


I customized PDF export with this way:

I attached xhtml2fo.xsl and use$xwiki.getDocument(‘MyApp.PDFTemplate’).getAttachment(‘xhtml2fo-myapp.xsl’).contentAsString like Anca said: Loading...

PDF export use my PDFTemplate if I use URL: http://yourserver/xwiki/bin/export/XWiki/PDFTemplate?format=pdf&pdftemplate=XWiki.PDFTemplate but I want that all my PDF export use my PDFTemplate.

For this I edited ./templates/pdf.vm file :

#if ($request.pdftemplate)
  #set ($pdfdoc = $xwiki.getDocument($request.pdftemplate))
  ## set($pdfdoc = $tdoc)
  #set ($pdfdoc = $xwiki.getDocument("XWiki.PDFTemplate"))

but it doesn’t work (on xwiki 8.4.4 version)

Any ideas?

(BTW it will be great if we could use xhtml2fo.xsl in filesytem like pdf.css file)

Pascal B

Just answering on this point: you can put a modified version of this file in your WEB-INF/classes directory and XWiki should pick your version instead of the default one from the oldcore JAR. Note that you can also override it in a wiki page as an xhtmlxsl xproperty of class XWiki.PDFClass.

yes I used this way but it doesn’t work with export menu (with url it’s working well).
I will test a file under WEB-INF/classes directory (and soon edit your PDF documentation)

yes it’s working well, ty :slight_smile: