@jsreport/jsreport-libreoffice 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/index.js +7 -0
- package/jsreport.config.js +24 -0
- package/lib/main.js +72 -0
- package/lib/worker.js +427 -0
- package/package.json +58 -0
- package/studio/LibreOfficePdfExportOptionsEditor.js +603 -0
- package/studio/LibreOfficePdfExportOptionsTitle.js +3 -0
- package/studio/LibreOfficeProperties.js +69 -0
- package/studio/constants.js +2 -0
- package/studio/main.css +19 -0
- package/studio/main.css.map +1 -0
- package/studio/main.js +859 -0
- package/studio/main.js.map +1 -0
- package/studio/main_dev.js +11 -0
- package/studio/styles.css +19 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 jsreport
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# @jsreport/jsreport-libreoffice
|
2
|
+
|
3
|
+
**jsreport extension using LibreOffice to convert outputs to the supported formats like pdf**
|
4
|
+
|
5
|
+
See https://jsreport.net/learn/libreoffice
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
> **npm install @jsreport/jsreport-libreoffice**
|
10
|
+
|
11
|
+
## Changelog
|
12
|
+
|
13
|
+
### 1.0.0
|
14
|
+
|
15
|
+
- initial release
|
package/index.js
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
module.exports = {
|
3
|
+
name: 'libreoffice',
|
4
|
+
main: 'lib/main.js',
|
5
|
+
worker: 'lib/worker.js',
|
6
|
+
dependencies: ['templates', 'assets'],
|
7
|
+
requires: {
|
8
|
+
core: '4.7.x',
|
9
|
+
studio: '4.x.x'
|
10
|
+
},
|
11
|
+
optionsSchema: {
|
12
|
+
extensions: {
|
13
|
+
libreoffice: {
|
14
|
+
type: 'object',
|
15
|
+
properties: {
|
16
|
+
sofficePath: {
|
17
|
+
type: ['string'],
|
18
|
+
description: 'Specify path to soffice binary. The default is to search for soffice in default paths.'
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
package/lib/main.js
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module.exports = function (reporter, definition) {
|
2
|
+
reporter.documentStore.registerComplexType('LibreOfficeType', {
|
3
|
+
format: { type: 'Edm.String' },
|
4
|
+
enabled: { type: 'Edm.Boolean' },
|
5
|
+
print: { type: 'Edm.String' },
|
6
|
+
/* general */
|
7
|
+
pdfExportPageRange: { type: 'Edm.String' },
|
8
|
+
pdfExportUseLosslessCompression: { type: 'Edm.Boolean' },
|
9
|
+
pdfExportQuality: { type: 'Edm.Decimal' },
|
10
|
+
pdfExportReduceImageResolution: { type: 'Edm.Boolean' },
|
11
|
+
pdfExportMaxImageResolution: { type: 'Edm.Decimal' },
|
12
|
+
pdfExportSelectPdfVersion: { type: 'Edm.Decimal' },
|
13
|
+
pdfExportPDFUACompliance: { type: 'Edm.Boolean' },
|
14
|
+
pdfExportUseTaggedPDF: { type: 'Edm.Boolean' },
|
15
|
+
pdfExportExportFormFields: { type: 'Edm.Boolean' },
|
16
|
+
pdfExportFormsType: { type: 'Edm.Decimal' },
|
17
|
+
pdfExportAllowDuplicateFieldNames: { type: 'Edm.Boolean' },
|
18
|
+
pdfExportExportBookmarks: { type: 'Edm.Boolean' },
|
19
|
+
pdfExportExportPlaceholders: { type: 'Edm.Boolean' },
|
20
|
+
pdfExportExportNotes: { type: 'Edm.Boolean' },
|
21
|
+
pdfExportExportNotesPages: { type: 'Edm.Boolean' },
|
22
|
+
pdfExportExportOnlyNotesPages: { type: 'Edm.Boolean' },
|
23
|
+
pdfExportExportNotesInMargin: { type: 'Edm.Boolean' },
|
24
|
+
pdfExportExportHiddenSlides: { type: 'Edm.Boolean' },
|
25
|
+
pdfExportIsSkipEmptyPages: { type: 'Edm.Boolean' },
|
26
|
+
pdfExportEmbedStandardFonts: { type: 'Edm.Boolean' },
|
27
|
+
pdfExportIsAddStream: { type: 'Edm.Boolean' },
|
28
|
+
pdfExportWatermark: { type: 'Edm.String' },
|
29
|
+
pdfExportWatermarkColor: { type: 'Edm.Decimal' },
|
30
|
+
pdfExportWatermarkFontHeight: { type: 'Edm.Decimal' },
|
31
|
+
pdfExportWatermarkRotateAngle: { type: 'Edm.Decimal' },
|
32
|
+
pdfExportWatermarkFontName: { type: 'Edm.String' },
|
33
|
+
pdfExportTiledWatermark: { type: 'Edm.String' },
|
34
|
+
pdfExportUseReferenceXObject: { type: 'Edm.Boolean' },
|
35
|
+
pdfExportIsRedactMode: { type: 'Edm.Boolean' },
|
36
|
+
pdfExportSinglePageSheets: { type: 'Edm.Boolean' },
|
37
|
+
/* initial view */
|
38
|
+
pdfExportResizeWindowToInitialPage: { type: 'Edm.Boolean' },
|
39
|
+
pdfExportCenterWindow: { type: 'Edm.Boolean' },
|
40
|
+
pdfExportOpenInFullScreenMode: { type: 'Edm.Boolean' },
|
41
|
+
pdfExportDisplayPDFDocumentTitle: { type: 'Edm.Boolean' },
|
42
|
+
pdfExportHideViewerMenubar: { type: 'Edm.Boolean' },
|
43
|
+
pdfExportHideViewerToolbar: { type: 'Edm.Boolean' },
|
44
|
+
pdfExportHideViewerWindowControls: { type: 'Edm.Boolean' },
|
45
|
+
pdfExportUseTransitionEffects: { type: 'Edm.Boolean' },
|
46
|
+
pdfExportOpenBookmarkLevels: { type: 'Edm.Decimal' },
|
47
|
+
/* links */
|
48
|
+
pdfExportExportBookmarksToPDFDestination: { type: 'Edm.Boolean' },
|
49
|
+
pdfExportConvertOOoTargetToPDFTarget: { type: 'Edm.Boolean' },
|
50
|
+
pdfExportExportLinksRelativeFsys: { type: 'Edm.Boolean' },
|
51
|
+
pdfExportPDFViewSelection: { type: 'Edm.Decimal' },
|
52
|
+
/* security */
|
53
|
+
pdfExportEncryptFile: { type: 'Edm.Boolean' },
|
54
|
+
pdfExportDocumentOpenPassword: { type: 'Edm.String' },
|
55
|
+
pdfExportRestrictPermissions: { type: 'Edm.Boolean' },
|
56
|
+
pdfExportPermissionPassword: { type: 'Edm.String' },
|
57
|
+
pdfExportPrinting: { type: 'Edm.Decimal' },
|
58
|
+
pdfExportChanges: { type: 'Edm.Decimal' },
|
59
|
+
pdfExportEnableCopyingOfContent: { type: 'Edm.Boolean' },
|
60
|
+
pdfExportEnableTextAccessForAccessibilityTools: { type: 'Edm.Boolean' },
|
61
|
+
/* digital signatures */
|
62
|
+
pdfExportSignPDF: { type: 'Edm.Boolean' },
|
63
|
+
pdfExportSignatureLocation: { type: 'Edm.String' },
|
64
|
+
pdfExportSignatureReason: { type: 'Edm.String' },
|
65
|
+
pdfExportSignatureContactInfo: { type: 'Edm.String' },
|
66
|
+
pdfExportSignaturePassword: { type: 'Edm.String' },
|
67
|
+
pdfExportSignCertificateSubjectName: { type: 'Edm.String' },
|
68
|
+
pdfExportSignatureTSA: { type: 'Edm.String' }
|
69
|
+
})
|
70
|
+
|
71
|
+
reporter.documentStore.model.entityTypes.TemplateType.libreOffice = { type: 'jsreport.LibreOfficeType' }
|
72
|
+
}
|
package/lib/worker.js
ADDED
@@ -0,0 +1,427 @@
|
|
1
|
+
const path = require('path')
|
2
|
+
const mime = require('mime')
|
3
|
+
const util = require('util')
|
4
|
+
const { spawn, exec } = require('child_process')
|
5
|
+
const execAsync = util.promisify(exec)
|
6
|
+
const url = require('url')
|
7
|
+
const fs = require('fs').promises
|
8
|
+
|
9
|
+
module.exports = function (reporter, definition) {
|
10
|
+
reporter.beforeRenderListeners.insert(0, 'libreoffice', (req, res) => {
|
11
|
+
// otherwise the output is html for office online
|
12
|
+
if (req.template.libreOffice && req.template.libreOffice.enabled !== false && req.template.libreOffice.format) {
|
13
|
+
req.options.preview = false
|
14
|
+
}
|
15
|
+
})
|
16
|
+
|
17
|
+
let sofficePath
|
18
|
+
let libreOfficeProfile
|
19
|
+
|
20
|
+
reporter.afterRenderListeners.insert({ before: 'scripts' }, 'libreoffice', async (req, res) => {
|
21
|
+
if (!req.template.libreOffice || req.template.libreOffice.enabled === false || (!req.template.libreOffice.format && !req.template.libreOffice.print) || req.context.isChildRequest) {
|
22
|
+
return
|
23
|
+
}
|
24
|
+
|
25
|
+
await sofficeCommand({
|
26
|
+
libreOfficeOptions: req.template.libreOffice,
|
27
|
+
source: { res }
|
28
|
+
}, req)
|
29
|
+
})
|
30
|
+
|
31
|
+
reporter.extendProxy((proxy, req, { sandboxRequire }) => {
|
32
|
+
proxy.libreOffice = {
|
33
|
+
async convert (content, format, options) {
|
34
|
+
if (!content) {
|
35
|
+
throw reporter.createError('jsreport.libreOffice.convert expect content buffer as the first parameter ', {
|
36
|
+
weak: true
|
37
|
+
})
|
38
|
+
}
|
39
|
+
|
40
|
+
if (!format) {
|
41
|
+
throw reporter.createError('jsreport.libreOffice.convert expect format as the second parameter ', {
|
42
|
+
weak: true
|
43
|
+
})
|
44
|
+
}
|
45
|
+
|
46
|
+
return sofficeCommand({
|
47
|
+
libreOfficeOptions: {
|
48
|
+
format,
|
49
|
+
...options
|
50
|
+
},
|
51
|
+
source: {
|
52
|
+
content
|
53
|
+
}
|
54
|
+
}, req)
|
55
|
+
},
|
56
|
+
async print (content, printer, options) {
|
57
|
+
if (!content) {
|
58
|
+
throw reporter.createError('jsreport.libreOffice.print expect content buffer as the first parameter ', {
|
59
|
+
weak: true
|
60
|
+
})
|
61
|
+
}
|
62
|
+
|
63
|
+
if (!printer) {
|
64
|
+
throw reporter.createError('jsreport.libreOffice.print expect printer name as the second parameter ', {
|
65
|
+
weak: true
|
66
|
+
})
|
67
|
+
}
|
68
|
+
|
69
|
+
return sofficeCommand({
|
70
|
+
libreOfficeOptions: {
|
71
|
+
printer,
|
72
|
+
...options
|
73
|
+
},
|
74
|
+
source: {
|
75
|
+
content
|
76
|
+
}
|
77
|
+
}, req)
|
78
|
+
}
|
79
|
+
}
|
80
|
+
})
|
81
|
+
|
82
|
+
async function sofficeCommand ({
|
83
|
+
libreOfficeOptions,
|
84
|
+
source
|
85
|
+
}, req) {
|
86
|
+
const profilerEvent = reporter.profiler.emit({
|
87
|
+
type: 'operationStart',
|
88
|
+
subtype: 'libreoffice',
|
89
|
+
name: 'libreoffice ' + (libreOfficeOptions.printer ? `print ${libreOfficeOptions.printer}` : `convert ${libreOfficeOptions.format}`),
|
90
|
+
doDiffs: false
|
91
|
+
}, req)
|
92
|
+
|
93
|
+
if (sofficePath == null) {
|
94
|
+
if (definition.options.sofficePath) {
|
95
|
+
sofficePath = definition.options.sofficePath
|
96
|
+
} else {
|
97
|
+
reporter.logger.debug('Searching for soffice path', req)
|
98
|
+
sofficePath = await getSofficePath()
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
if (libreOfficeProfile == null) {
|
103
|
+
libreOfficeProfile = path.join(reporter.options.tempDirectory, 'libreoffice', `profile-${reporter.workerId}`)
|
104
|
+
try {
|
105
|
+
reporter.logger.debug('Creating libreoffice profile at ' + libreOfficeProfile, req)
|
106
|
+
await execAsync(`"${sofficePath}" --convert-to pdf ${reporter.options.tempDirectory} --headless -env:UserInstallation=${url.pathToFileURL(libreOfficeProfile)} --outdir ${reporter.options.tempDirectory}`)
|
107
|
+
} catch (e) {
|
108
|
+
// the first render always fail because of missing profile for some reason
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
try {
|
113
|
+
let outputFilename
|
114
|
+
let pathToFile
|
115
|
+
if (source.res) {
|
116
|
+
pathToFile = (await source.res.output.writeToTempFile((uuid) => {
|
117
|
+
outputFilename = uuid + '.' + libreOfficeOptions.format
|
118
|
+
return `${uuid}.bin`
|
119
|
+
})).pathToFile
|
120
|
+
} else {
|
121
|
+
pathToFile = (await reporter.writeTempFile((uuid) => {
|
122
|
+
outputFilename = uuid + '.' + libreOfficeOptions.format
|
123
|
+
return `${uuid}.bin}`
|
124
|
+
}, source.content)).pathToFile
|
125
|
+
}
|
126
|
+
|
127
|
+
await new Promise((resolve, reject) => {
|
128
|
+
const stdout = []
|
129
|
+
const stderr = []
|
130
|
+
let failed = false
|
131
|
+
|
132
|
+
const args = []
|
133
|
+
|
134
|
+
if (libreOfficeOptions.printer) {
|
135
|
+
args.push('--pt', libreOfficeOptions.printer)
|
136
|
+
} else {
|
137
|
+
args.push('--convert-to', libreOfficeOptions.format !== 'pdf' ? libreOfficeOptions.format : pdfExportString(libreOfficeOptions))
|
138
|
+
}
|
139
|
+
|
140
|
+
args.push(`${pathToFile}`)
|
141
|
+
args.push('--headless')
|
142
|
+
args.push(`-env:UserInstallation=${url.pathToFileURL(libreOfficeProfile)}`)
|
143
|
+
|
144
|
+
if (!libreOfficeOptions.printer) {
|
145
|
+
args.push('--outdir', path.dirname(pathToFile))
|
146
|
+
}
|
147
|
+
|
148
|
+
reporter.logger.debug(`libreoffice command ${sofficePath} ${args.join(' ')}`, req)
|
149
|
+
const childProcess = spawn(sofficePath, args)
|
150
|
+
|
151
|
+
childProcess.stdout.on('data', (data) => {
|
152
|
+
stdout.push(data)
|
153
|
+
})
|
154
|
+
|
155
|
+
childProcess.stderr.on('data', (data) => {
|
156
|
+
stderr.push(data)
|
157
|
+
})
|
158
|
+
|
159
|
+
childProcess.on('close', async (code) => {
|
160
|
+
if (!failed) {
|
161
|
+
if (stderr.length) {
|
162
|
+
return reject(new Error(Buffer.concat(stderr).toString('utf8')))
|
163
|
+
}
|
164
|
+
resolve()
|
165
|
+
}
|
166
|
+
})
|
167
|
+
|
168
|
+
childProcess.on('error', (err) => {
|
169
|
+
failed = true
|
170
|
+
reject(err)
|
171
|
+
})
|
172
|
+
|
173
|
+
return childProcess
|
174
|
+
})
|
175
|
+
|
176
|
+
reporter.profiler.emit({
|
177
|
+
type: 'operationEnd',
|
178
|
+
operationId: profilerEvent.operationId,
|
179
|
+
doDiffs: false
|
180
|
+
}, req)
|
181
|
+
|
182
|
+
if (!libreOfficeOptions.printer) {
|
183
|
+
if (source.res) {
|
184
|
+
await source.res.output.update(path.join(path.dirname(pathToFile), outputFilename))
|
185
|
+
|
186
|
+
source.res.meta.fileExtension = libreOfficeOptions.format
|
187
|
+
source.res.meta.contentType = mime.getType(libreOfficeOptions.format)
|
188
|
+
} else {
|
189
|
+
return {
|
190
|
+
content: await fs.readFile(path.join(path.dirname(pathToFile), outputFilename)),
|
191
|
+
fileExtension: libreOfficeOptions.format
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
} catch (e) {
|
196
|
+
throw reporter.createError('Error while executing LibreOffice', {
|
197
|
+
original: e,
|
198
|
+
weak: true
|
199
|
+
})
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
const getSofficePath = async () => {
|
204
|
+
const getEnvVarKey = (key) => {
|
205
|
+
const upperKey = key.toUpperCase()
|
206
|
+
return Object.keys(process.env).find(k => k.toUpperCase() === upperKey)
|
207
|
+
}
|
208
|
+
|
209
|
+
const paths = (() => {
|
210
|
+
switch (process.platform) {
|
211
|
+
case 'darwin':
|
212
|
+
return ['/Applications/LibreOffice.app/Contents/MacOS/soffice']
|
213
|
+
case 'linux':
|
214
|
+
return [
|
215
|
+
'/usr/bin/libreoffice',
|
216
|
+
'/usr/bin/soffice',
|
217
|
+
'/snap/bin/libreoffice',
|
218
|
+
'/opt/libreoffice/program/soffice',
|
219
|
+
'/opt/libreoffice7.6/program/soffice'
|
220
|
+
]
|
221
|
+
case 'win32': {
|
222
|
+
const programFilesEnvKey = getEnvVarKey('ProgramFiles')
|
223
|
+
const programFilesX86EnvKey = getEnvVarKey('ProgramFiles(x86)')
|
224
|
+
return [
|
225
|
+
programFilesEnvKey ? path.join(process.env[programFilesEnvKey], 'LibreOffice/program/soffice.exe') : null,
|
226
|
+
programFilesX86EnvKey ? path.join(process.env[programFilesX86EnvKey], 'LIBREO~1/program/soffice.exe') : null,
|
227
|
+
programFilesX86EnvKey ? path.join(process.env[programFilesX86EnvKey], 'LibreOffice/program/soffice.exe') : null
|
228
|
+
]
|
229
|
+
}
|
230
|
+
}
|
231
|
+
}
|
232
|
+
)().filter(p => p)
|
233
|
+
|
234
|
+
for (const p of paths) {
|
235
|
+
try {
|
236
|
+
await fs.access(p)
|
237
|
+
return p
|
238
|
+
} catch (e) {
|
239
|
+
|
240
|
+
}
|
241
|
+
}
|
242
|
+
|
243
|
+
throw reporter.createError('Could not find soffice binary on paths ' + paths.join(', '), {
|
244
|
+
weak: true
|
245
|
+
})
|
246
|
+
}
|
247
|
+
|
248
|
+
const pdfExportString = (libreOfficeOptions) => {
|
249
|
+
const exportOptions = {}
|
250
|
+
if (libreOfficeOptions.pdfExportWatermark) {
|
251
|
+
exportOptions.Watermark = { type: 'string', value: libreOfficeOptions.pdfExportWatermark }
|
252
|
+
}
|
253
|
+
if (libreOfficeOptions.pdfExportPageRange) {
|
254
|
+
exportOptions.PageRange = { type: 'string', value: libreOfficeOptions.pdfExportPageRange }
|
255
|
+
}
|
256
|
+
if (libreOfficeOptions.pdfExportUseLosslessCompression != null) {
|
257
|
+
exportOptions.UseLosslessCompression = { type: 'boolean', value: libreOfficeOptions.pdfExportUseLosslessCompression }
|
258
|
+
}
|
259
|
+
if (libreOfficeOptions.pdfExportQuality) {
|
260
|
+
exportOptions.Quality = { type: 'long', value: libreOfficeOptions.pdfExportQuality }
|
261
|
+
}
|
262
|
+
if (libreOfficeOptions.pdfExportReduceImageResolution != null) {
|
263
|
+
exportOptions.ReduceImageResolution = { type: 'boolean', value: libreOfficeOptions.pdfExportReduceImageResolution }
|
264
|
+
}
|
265
|
+
if (libreOfficeOptions.pdfExportSelectPdfVersion) {
|
266
|
+
exportOptions.SelectPdfVersion = { type: 'long', value: libreOfficeOptions.pdfExportSelectPdfVersion }
|
267
|
+
}
|
268
|
+
if (libreOfficeOptions.pdfExportMaxImageResolution) {
|
269
|
+
exportOptions.MaxImageResolution = { type: 'long', value: libreOfficeOptions.pdfExportMaxImageResolution }
|
270
|
+
}
|
271
|
+
if (libreOfficeOptions.pdfExportPDFUACompliance != null) {
|
272
|
+
exportOptions.PDFUACompliance = { type: 'boolean', value: libreOfficeOptions.pdfExportPDFUACompliance }
|
273
|
+
}
|
274
|
+
if (libreOfficeOptions.pdfExportUseTaggedPDF != null) {
|
275
|
+
exportOptions.PDFUseTaggedPDF = { type: 'boolean', value: libreOfficeOptions.pdfExportUseTaggedPDF }
|
276
|
+
}
|
277
|
+
if (libreOfficeOptions.pdfExportExportFormFields != null) {
|
278
|
+
exportOptions.ExportFormFields = { type: 'boolean', value: libreOfficeOptions.pdfExportExportFormFields }
|
279
|
+
}
|
280
|
+
if (libreOfficeOptions.pdfExportFormsType) {
|
281
|
+
exportOptions.FormsType = { type: 'long', value: libreOfficeOptions.pdfExportFormsType }
|
282
|
+
}
|
283
|
+
if (libreOfficeOptions.pdfExportAllowDuplicateFieldNames != null) {
|
284
|
+
exportOptions.AllowDuplicateFieldNames = { type: 'boolean', value: libreOfficeOptions.pdfExportAllowDuplicateFieldNames }
|
285
|
+
}
|
286
|
+
if (libreOfficeOptions.pdfExportExportBookmarks != null) {
|
287
|
+
exportOptions.ExportBookmarks = { type: 'boolean', value: libreOfficeOptions.pdfExportExportBookmarks }
|
288
|
+
}
|
289
|
+
if (libreOfficeOptions.pdfExportExportPlaceholders != null) {
|
290
|
+
exportOptions.ExportPlaceholders = { type: 'boolean', value: libreOfficeOptions.pdfExportExportPlaceholders }
|
291
|
+
}
|
292
|
+
if (libreOfficeOptions.pdfExportExportNotes != null) {
|
293
|
+
exportOptions.ExportNotes = { type: 'boolean', value: libreOfficeOptions.pdfExportExportNotes }
|
294
|
+
}
|
295
|
+
if (libreOfficeOptions.pdfExportExportNotesPages != null) {
|
296
|
+
exportOptions.ExportNotesPages = { type: 'boolean', value: libreOfficeOptions.pdfExportExportNotesPages }
|
297
|
+
}
|
298
|
+
if (libreOfficeOptions.pdfExportExportOnlyNotesPages != null) {
|
299
|
+
exportOptions.ExportOnlyNotesPages = { type: 'boolean', value: libreOfficeOptions.pdfExportExportOnlyNotesPages }
|
300
|
+
}
|
301
|
+
if (libreOfficeOptions.pdfExportExportNotesInMargin != null) {
|
302
|
+
exportOptions.ExportNotesInMargin = { type: 'boolean', value: libreOfficeOptions.pdfExportExportNotesInMargin }
|
303
|
+
}
|
304
|
+
if (libreOfficeOptions.pdfExportExportHiddenSlides != null) {
|
305
|
+
exportOptions.ExportHiddenSlides = { type: 'boolean', value: libreOfficeOptions.pdfExportExportHiddenSlides }
|
306
|
+
}
|
307
|
+
if (libreOfficeOptions.pdfExportIsSkipEmptyPages != null) {
|
308
|
+
exportOptions.IsSkipEmptyPages = { type: 'boolean', value: libreOfficeOptions.pdfExportIsSkipEmpty }
|
309
|
+
}
|
310
|
+
if (libreOfficeOptions.pdfExportEmbedStandardFonts != null) {
|
311
|
+
exportOptions.EmbedStandardFonts = { type: 'boolean', value: libreOfficeOptions.pdfExportEmbedStandardFonts }
|
312
|
+
}
|
313
|
+
if (libreOfficeOptions.pdfExportIsAddStream != null) {
|
314
|
+
exportOptions.IsAddStream = { type: 'boolean', value: libreOfficeOptions.pdfExportIsAddStream }
|
315
|
+
}
|
316
|
+
if (libreOfficeOptions.pdfExportWatermarkColor) {
|
317
|
+
exportOptions.WatermarkColor = { type: 'long', value: libreOfficeOptions.pdfExportWatermarkColor }
|
318
|
+
}
|
319
|
+
if (libreOfficeOptions.pdfExportWatermarkFontHeight) {
|
320
|
+
exportOptions.WatermarkFontHeight = { type: 'long', value: libreOfficeOptions.pdfExportWatermarkFontHeight }
|
321
|
+
}
|
322
|
+
if (libreOfficeOptions.pdfExportWatermarkRotateAngle) {
|
323
|
+
exportOptions.WatermarkRotateAngle = { type: 'long', value: libreOfficeOptions.pdfExportWatermarkRotate }
|
324
|
+
}
|
325
|
+
if (libreOfficeOptions.pdfExportWatermarkFontName) {
|
326
|
+
exportOptions.WatermarkFontName = { type: 'string', value: libreOfficeOptions.pdfExportWatermarkFontName }
|
327
|
+
}
|
328
|
+
if (libreOfficeOptions.pdfExportTiledWatermark) {
|
329
|
+
exportOptions.TiledWatermark = { type: 'string', value: libreOfficeOptions.pdfExportTiledWatermark }
|
330
|
+
}
|
331
|
+
if (libreOfficeOptions.pdfExportUseReferenceXObject != null) {
|
332
|
+
exportOptions.UseReferenceXObject = { type: 'boolean', value: libreOfficeOptions.pdfExportUseReferenceXObject }
|
333
|
+
}
|
334
|
+
if (libreOfficeOptions.pdfExportIsRedactMode != null) {
|
335
|
+
exportOptions.IsRedactMode = { type: 'boolean', value: libreOfficeOptions.pdfExportIsRedactMode }
|
336
|
+
}
|
337
|
+
if (libreOfficeOptions.pdfExportSinglePageSheets != null) {
|
338
|
+
exportOptions.SinglePageSheets = { type: 'boolean', value: libreOfficeOptions.pdfExportSinglePageSheets }
|
339
|
+
}
|
340
|
+
if (libreOfficeOptions.pdfExportResizeWindowToInitialPage != null) {
|
341
|
+
exportOptions.ResizeWindowToInitialPage = { type: 'boolean', value: libreOfficeOptions.pdfExportResizeWindowToInitialPage }
|
342
|
+
}
|
343
|
+
if (libreOfficeOptions.pdfExportCenterWindow != null) {
|
344
|
+
exportOptions.CenterWindow = { type: 'boolean', value: libreOfficeOptions.pdfExportCenterWindow }
|
345
|
+
}
|
346
|
+
if (libreOfficeOptions.pdfExportOpenInFullScreenMode != null) {
|
347
|
+
exportOptions.OpenInFullScreenMode = { type: 'boolean', value: libreOfficeOptions.pdfExportOpenInFullScreenMode }
|
348
|
+
}
|
349
|
+
if (libreOfficeOptions.pdfExportDisplayPDFDocumentTitle != null) {
|
350
|
+
exportOptions.DisplayPDFDocumentTitle = { type: 'boolean', value: libreOfficeOptions.pdfExportDisplayPDFDocumentTitle }
|
351
|
+
}
|
352
|
+
if (libreOfficeOptions.pdfExportHideViewerMenubar != null) {
|
353
|
+
exportOptions.HideViewerMenubar = { type: 'boolean', value: libreOfficeOptions.pdfExportHideViewerMenubar }
|
354
|
+
}
|
355
|
+
if (libreOfficeOptions.pdfExportHideViewerToolbar != null) {
|
356
|
+
exportOptions.HideViewerToolbar = { type: 'boolean', value: libreOfficeOptions.pdfExportHideViewerToolbar }
|
357
|
+
}
|
358
|
+
if (libreOfficeOptions.pdfExportHideViewerWindowControls != null) {
|
359
|
+
exportOptions.HideViewerWindowControls = { type: 'boolean', value: libreOfficeOptions.pdfExportHideViewerWindowControls }
|
360
|
+
}
|
361
|
+
if (libreOfficeOptions.pdfExportUseTransitionEffects != null) {
|
362
|
+
exportOptions.UseTransitionEffects = { type: 'boolean', value: libreOfficeOptions.pdfExportUseTransitionEffects }
|
363
|
+
}
|
364
|
+
if (libreOfficeOptions.pdfExportOpenBookmarkLevels) {
|
365
|
+
exportOptions.OpenBookmarkLevels = { type: 'long', value: libreOfficeOptions.pdfExportOpenBookmarkLevels }
|
366
|
+
}
|
367
|
+
if (libreOfficeOptions.pdfExportExportBookmarksToPDFDestination != null) {
|
368
|
+
exportOptions.ExportBookmarksToPDFDestination = { type: 'boolean', value: libreOfficeOptions.pdfExportExportBookmarksToPDFDestination }
|
369
|
+
}
|
370
|
+
if (libreOfficeOptions.pdfExportConvertOOoTargetToPDFTarget != null) {
|
371
|
+
exportOptions.ConvertOOoTargetToPDFTarget = { type: 'boolean', value: libreOfficeOptions.pdfExportConvertOOoTargetToPDFTarget }
|
372
|
+
}
|
373
|
+
if (libreOfficeOptions.pdfExportExportLinksRelativeFsys != null) {
|
374
|
+
exportOptions.ExportLinksRelativeFsys = { type: 'boolean', value: libreOfficeOptions.pdfExportExportLinksRelativeFsys }
|
375
|
+
}
|
376
|
+
if (libreOfficeOptions.pdfExportPDFViewSelection) {
|
377
|
+
exportOptions.PDFViewSelection = { type: 'long', value: libreOfficeOptions.pdfExportPDFViewSelection }
|
378
|
+
}
|
379
|
+
if (libreOfficeOptions.pdfExportEncryptFile != null) {
|
380
|
+
exportOptions.EncryptFile = { type: 'boolean', value: libreOfficeOptions.pdfExportEncryptFile }
|
381
|
+
}
|
382
|
+
if (libreOfficeOptions.pdfExportDocumentOpenPassword) {
|
383
|
+
exportOptions.DocumentOpenPassword = { type: 'string', value: libreOfficeOptions.pdfExportDocumentOpenPassword }
|
384
|
+
}
|
385
|
+
if (libreOfficeOptions.pdfExportRestrictPermissions != null) {
|
386
|
+
exportOptions.RestrictPermissions = { type: 'boolean', value: libreOfficeOptions.pdfExportRestrictPermissions }
|
387
|
+
}
|
388
|
+
if (libreOfficeOptions.pdfExportPermissionPassword) {
|
389
|
+
exportOptions.PermissionPassword = { type: 'string', value: libreOfficeOptions.pdfExportPermissionPassword }
|
390
|
+
}
|
391
|
+
if (libreOfficeOptions.pdfExportPrinting) {
|
392
|
+
exportOptions.Printing = { type: 'long', value: libreOfficeOptions.pdfExportPrinting }
|
393
|
+
}
|
394
|
+
if (libreOfficeOptions.pdfExportChanges) {
|
395
|
+
exportOptions.Changes = { type: 'long', value: libreOfficeOptions.pdfExportChanges }
|
396
|
+
}
|
397
|
+
if (libreOfficeOptions.pdfExportEnableCopyingOfContent != null) {
|
398
|
+
exportOptions.EnableCopyingOfContent = { type: 'boolean', value: libreOfficeOptions.pdfExportEnableCopyingOfContent }
|
399
|
+
}
|
400
|
+
if (libreOfficeOptions.pdfExportEnableTextAccessForAccessibilityTools != null) {
|
401
|
+
exportOptions.EnableTextAccessForAccessibilityTools = { type: 'boolean', value: libreOfficeOptions.pdfExportEnableTextAccessForAccessibilityTools }
|
402
|
+
}
|
403
|
+
if (libreOfficeOptions.pdfExportSignPDF != null) {
|
404
|
+
exportOptions.SignPDF = { type: 'boolean', value: libreOfficeOptions.pdfExportSignPDF }
|
405
|
+
}
|
406
|
+
if (libreOfficeOptions.pdfExportSignatureLocation) {
|
407
|
+
exportOptions.SignatureLocation = { type: 'string', value: libreOfficeOptions.pdfExportSignatureLocation }
|
408
|
+
}
|
409
|
+
if (libreOfficeOptions.pdfExportSignatureReason) {
|
410
|
+
exportOptions.SignatureReason = { type: 'string', value: libreOfficeOptions.pdfExportSignatureReason }
|
411
|
+
}
|
412
|
+
if (libreOfficeOptions.pdfExportSignatureContactInfo) {
|
413
|
+
exportOptions.SignatureContactInfo = { type: 'string', value: libreOfficeOptions.pdfExportSignatureContactInfo }
|
414
|
+
}
|
415
|
+
if (libreOfficeOptions.pdfExportSignaturePassword) {
|
416
|
+
exportOptions.SignaturePassword = { type: 'string', value: libreOfficeOptions.pdfExportSignaturePassword }
|
417
|
+
}
|
418
|
+
if (libreOfficeOptions.pdfExportSignCertificateSubjectName) {
|
419
|
+
exportOptions.SignCertificateSubjectName = { type: 'string', value: libreOfficeOptions.pdfExportSignCertificateSubjectName }
|
420
|
+
}
|
421
|
+
if (libreOfficeOptions.pdfExportSignatureTSA) {
|
422
|
+
exportOptions.SignatureTSA = { type: 'string', value: libreOfficeOptions.pdfExportSignatureTSA }
|
423
|
+
}
|
424
|
+
|
425
|
+
return 'pdf:writer_pdf_Export:' + JSON.stringify(exportOptions)
|
426
|
+
}
|
427
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
{
|
2
|
+
"name": "@jsreport/jsreport-libreoffice",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "jsreport extension for converting office documents",
|
5
|
+
"keywords": [
|
6
|
+
"jsreport",
|
7
|
+
"office"
|
8
|
+
],
|
9
|
+
"homepage": "https://github.com/jsreport/jsreport/tree/master/packages//jsreport-libreoffice",
|
10
|
+
"repository": {
|
11
|
+
"type": "git",
|
12
|
+
"url": "git@github.com:jsreport/jsreport.git"
|
13
|
+
},
|
14
|
+
"license": "MIT",
|
15
|
+
"author": {
|
16
|
+
"name": "Jan Blaha",
|
17
|
+
"email": "jan.blaha@hotmail.com"
|
18
|
+
},
|
19
|
+
"contributors": [
|
20
|
+
"BJR Matos <bjrmatos@gmail.com> (https://github.com/bjrmatos)"
|
21
|
+
],
|
22
|
+
"files": [
|
23
|
+
"lib",
|
24
|
+
"studio",
|
25
|
+
"index.js",
|
26
|
+
"jsreport.config.js"
|
27
|
+
],
|
28
|
+
"scripts": {
|
29
|
+
"build": "jsreport-studio-build",
|
30
|
+
"prepublishOnly": "jsreport-studio-build",
|
31
|
+
"test": "mocha test --timeout 15000 && standard"
|
32
|
+
},
|
33
|
+
"dependencies": {
|
34
|
+
"mime": "2.4.4"
|
35
|
+
},
|
36
|
+
"devDependencies": {
|
37
|
+
"@jsreport/jsreport-core": "4.7.0",
|
38
|
+
"@jsreport/jsreport-html-to-xlsx": "4.2.1",
|
39
|
+
"@jsreport/jsreport-scripts": "4.2.0",
|
40
|
+
"@jsreport/studio-dev": "4.0.0",
|
41
|
+
"mocha": "10.1.0",
|
42
|
+
"should": "13.2.3",
|
43
|
+
"standard": "16.0.4"
|
44
|
+
},
|
45
|
+
"engines": {
|
46
|
+
"node": ">=18.15"
|
47
|
+
},
|
48
|
+
"standard": {
|
49
|
+
"ignore": [
|
50
|
+
"studio/main.js"
|
51
|
+
],
|
52
|
+
"env": {
|
53
|
+
"node": true,
|
54
|
+
"mocha": true,
|
55
|
+
"browser": true
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|