Wiki source code of Selective PDF Export
Last modified by Admin User on 2023/06/30 10:27
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{velocity output="false"}} | ||
2 | #macro(printExcludeList $space) | ||
3 | #set($excludeDocuments = []) | ||
4 | ##exclude class documents created by app within minutes | ||
5 | #set($spaceHome = $xwiki.getDocument($space, 'WebHome')) | ||
6 | #set($livetableObjInWebHome = $spaceHome.getObject('AppWithinMinutes.LiveTableClass')) | ||
7 | #if($livetableObjInWebHome) | ||
8 | #set($classDocument = $livetableObjInWebHome.getProperty('class').value) | ||
9 | #set($discard = $excludeDocuments.add($classDocument)) | ||
10 | ## compose the names of the sheet and template and exclude | ||
11 | ## TODO: find a better way to do this | ||
12 | #set($classIndex = $classDocument.lastIndexOf('Class')) | ||
13 | #set($classPrefix = $classDocument.substring(0, $classIndex)) | ||
14 | ## add template and sheet to the excludes | ||
15 | #set($discard = $excludeDocuments.add("${classPrefix}Sheet")) | ||
16 | #set($discard = $excludeDocuments.add("${classPrefix}Template")) | ||
17 | #end | ||
18 | ## exclude webpreferences | ||
19 | #set($discard = $excludeDocuments.add("${space}.WebPreferences")) | ||
20 | #set($discard = $excludeDocuments.add("${space}.zHeader")) | ||
21 | #set($discard = $excludeDocuments.add("${space}.zSelectivePrint")) | ||
22 | #foreach($exclude in $excludeDocuments)#if($velocityCount > 1), #{end}$exclude#end | ||
23 | #end | ||
24 | {{/velocity}} | ||
25 | |||
26 | {{velocity}} | ||
27 | #set($discard = $xwiki.ssx.use("XWiki.PDFExportSheet")) | ||
28 | #if ($request.getParameterValues('pdfpages') && $request.getParameterValues('pdfpages').size() > 0) | ||
29 | ## get the name of the package to export | ||
30 | #set($packageName = "$!request.exportname") | ||
31 | #if ($packageName == "") | ||
32 | #set($packageName = "$doc.space") | ||
33 | #end | ||
34 | ## get the list of documents to export | ||
35 | #set($docsToExport = []) | ||
36 | ## create a list like this since apparently we have no other way in velocity to add all the elements from the array to the list | ||
37 | #foreach($pdfPage in $request.getParameterValues('pdfpages')) | ||
38 | #set($discard = $docsToExport.add($pdfPage)) | ||
39 | #end | ||
40 | ## find out if export should be multipages or not. By default no | ||
41 | #set($multipages = false) | ||
42 | #if("$!request.multipages" == "true") | ||
43 | #set($multipages = true) | ||
44 | #end | ||
45 | ## do not force each new document to start on recto | ||
46 | #set($startonrecto = false) | ||
47 | ## do export, we have a selection. Grab the pdf exporter and pass it the pages to export | ||
48 | $services.pdfexporter.export($packageName, $docsToExport, $multipages, $startonrecto) | ||
49 | #else | ||
50 | ## no submitted data, display the hierarchy with checkboxes to select | ||
51 | {{html clean="false" wiki="false" }} | ||
52 | <form action="" method="post" class="hierarchyexport"> | ||
53 | {{/html}} | ||
54 | #set($ExcludePages="PECOS Mobile.WebPreferences,PECOS Mobile.zSelectivePrint,PECOS Mobile.zHeader,PECOS Mobile.Tempmanual") | ||
55 | #set($Focus="Tempmanual") | ||
56 | |||
57 | {{hierarchy space="$doc.space" excludes="$ExcludePages" displayvalue="title" openNode="${doc.space}.$Focus" showcheckboxes=true checkboxexcludes="${doc.space}.WebHome" checkboxname="pdfpages" reorderable="false" /}} | ||
58 | |||
59 | {{html clean="false" wiki="false"}} | ||
60 | <fieldset> | ||
61 | |||
62 | <label for="exportname" > Document pages will be extracted from </label> | ||
63 | <input type=text readonly name="exportname" value="$doc.space" id="exportname" /> | ||
64 | |||
65 | ## some pdf settings go here | ||
66 | |||
67 | <input type="hidden" name="pdfcover" value="1" /> | ||
68 | <input type="hidden" name="pdftoc" value="1" /> | ||
69 | <input type="hidden" name="comments" value="0" /> | ||
70 | <input type="hidden" name="attachments" value="0" /> | ||
71 | <input type="hidden" name="multipages" value="true" /> | ||
72 | <input type="hidden" name="exportname" value="SelectivePrintFile" /> | ||
73 | |||
74 | <div class="buttons buttonwrapper"> | ||
75 | <a class="secondary button" href="$doc.getURL()">$msg.get('cancel')</a> | ||
76 | <input type="submit" class="button" name="export" value="$msg.get('pdfexport.doexport')" /> | ||
77 | </div> | ||
78 | </fieldset> | ||
79 | </form> | ||
80 | {{/html}} | ||
81 | #end | ||
82 | {{/velocity}} |