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