On 01/27/2011 11:47 PM, Thibaut Camberlin wrote:
Hi,
I was writing a piece of code so that PDF export prints associated meta data
of a page. Since I was in PDF macros code, I worked on a PDF export options
page.
By working on the PDF export options, I am using check boxes that allows
user to choose to export or not cover page, toc page, metadata page
attachments and comments. Issue I encountered is that when a check box is
not checked it is not set and I found no way to use check boxes with actual
code from pdfhtmlheader.vm page:
#if("$!request.pdfcover" != '0')
#set($displayPdfCover = 1)
#else
#set($displayPdfCover = 0)
#end
and the same for pdftoc
You don't need to do that at all. The trick is to put:
<label><input type="checkbox" value="1"
name="pdfcover"/> Cover</label>
<input type="hidden" value="0" name="pdfcover" />
If the checkbox is selected, the browser sends both values to the
server: pdfcover=1&pdfcover=0
But request.pdfcover gets the first value it sees, 1.
If the checkbox is unselected, the browser sends only the hidden value:
pdfcover=0, so request.pdfcover will be 0.
This is how the checkbox display of object properties is implemented as
well.
But yes, displaying the PDF options is something that I wanted to do as
well, just that I never had the time for it.
(I could have put<input value="0"/>
instead but it makes more sense to have
<input value="1"/>)
Therefore I am proposing that we:
* update pdfhtmlheader.vm page so that cover and toc page are not exported
by default
* update existing pdf export button so that we keep the same behaviour
(pdfcover and pdftoc printed in PDF), meaning instead of
*page?format=pdf*it would be
*page?format=pdf&pdftoc=1&pdfcover=1*
Some UI will be needed afterward so that this page is exposed. (I am not
planning to work on this.)
The export options would be made in a template, but I put the code in this
page of the incubator so that it makes things clearer if needed:
http://incubator.myxwiki.org/xwiki/bin/view/PDFExport/ExportOptions
Thanks for your feedback on pdfhtmlheader.vm modification and on the feature
itself.
--
Thibaut
--
Sergiu Dumitriu
http://purl.org/net/sergiu/