@opendataloader/pdf 0.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.
@@ -0,0 +1,28 @@
1
+ This software module was originally developed by Raphaël Grosbois and
2
+ Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
3
+ Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
4
+ Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
5
+ Centre France S.A) in the course of development of the JPEG2000
6
+ standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
7
+ software module is an implementation of a part of the JPEG 2000
8
+ Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
9
+ Systems AB and Canon Research Centre France S.A (collectively JJ2000
10
+ Partners) agree not to assert against ISO/IEC and users of the JPEG
11
+ 2000 Standard (Users) any of their rights under the copyright, not
12
+ including other intellectual property rights, for this software module
13
+ with respect to the usage by ISO/IEC and Users of this software module
14
+ or modifications thereof for use in hardware or software products
15
+ claiming conformance to the JPEG 2000 Standard. Those intending to use
16
+ this software module in hardware or software products are advised that
17
+ their use may infringe existing patents. The original developers of
18
+ this software module, JJ2000 Partners and ISO/IEC assume no liability
19
+ for use of this software module or modifications thereof. No license
20
+ or right to this software module is granted for non JPEG 2000 Standard
21
+ conforming products. JJ2000 Partners have full right to use this
22
+ software module for his/her own purpose, assign or donate this
23
+ software module to any third party and to inhibit third parties from
24
+ using this software module for non JPEG 2000 Standard conforming
25
+ products. This copyright notice must be included in all copies or
26
+ derivative works of this software module.
27
+
28
+ Copyright (c) 1999/2000 JJ2000 Partners.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) <year> <copyright holders>
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.
@@ -0,0 +1,408 @@
1
+ Mozilla Public License
2
+ Version 2.0
3
+ ======================
4
+
5
+
6
+ 1. Definitions
7
+ --------------
8
+
9
+ 1.1. "Contributor"
10
+
11
+ means each individual or legal entity that creates, contributes to the creation
12
+ of, or owns Covered Software.
13
+
14
+ 1.2. "Contributor Version"
15
+
16
+ means the combination of the Contributions of others (if any) used by a
17
+ Contributor and that particular Contributor's Contribution.
18
+
19
+ 1.3. "Contribution"
20
+
21
+ means Covered Software of a particular Contributor.
22
+
23
+ 1.4. "Covered Software"
24
+
25
+ means Source Code Form to which the initial Contributor has attached the notice
26
+ in Exhibit A, the Executable Form of such Source Code Form, and Modifications
27
+ of such Source Code Form, in each case including portions thereof.
28
+
29
+ 1.5. "Incompatible With Secondary Licenses"
30
+
31
+ means
32
+
33
+ a.
34
+
35
+ that the initial Contributor has attached the notice described in Exhibit B
36
+ to the Covered Software; or
37
+
38
+ b.
39
+
40
+ that the Covered Software was made available under the terms of version 1.1
41
+ or earlier of the License, but not also under the terms of a Secondary
42
+ License.
43
+
44
+ 1.6. "Executable Form"
45
+
46
+ means any form of the work other than Source Code Form.
47
+
48
+ 1.7. "Larger Work"
49
+
50
+ means a work that combines Covered Software with other material, in a separate
51
+ file or files, that is not Covered Software.
52
+
53
+ 1.8. "License"
54
+
55
+ means this document.
56
+
57
+ 1.9. "Licensable"
58
+
59
+ means having the right to grant, to the maximum extent possible, whether at the
60
+ time of the initial grant or subsequently, any and all of the rights conveyed
61
+ by this License.
62
+
63
+ 1.10. "Modifications"
64
+
65
+ means any of the following:
66
+
67
+ a.
68
+
69
+ any file in Source Code Form that results from an addition to, deletion
70
+ from, or modification of the contents of Covered Software; or
71
+
72
+ b.
73
+
74
+ any new file in Source Code Form that contains any Covered Software.
75
+
76
+ 1.11. "Patent Claims" of a Contributor
77
+
78
+ means any patent claim(s), including without limitation, method, process, and
79
+ apparatus claims, in any patent Licensable by such Contributor that would be
80
+ infringed, but for the grant of the License, by the making, using, selling,
81
+ offering for sale, having made, import, or transfer of either its Contributions
82
+ or its Contributor Version.
83
+
84
+ 1.12. "Secondary License"
85
+
86
+ means either the GNU General Public License, Version 2.0, the GNU Lesser
87
+ General Public License, Version 2.1, the GNU Affero General Public License,
88
+ Version 3.0, or any later versions of those licenses.
89
+
90
+ 1.13. "Source Code Form"
91
+
92
+ means the form of the work preferred for making modifications.
93
+
94
+ 1.14. "You" (or "Your")
95
+
96
+ means an individual or a legal entity exercising rights under this License. For
97
+ legal entities, "You" includes any entity that controls, is controlled by, or
98
+ is under common control with You. For purposes of this definition, "control"
99
+ means (a) the power, direct or indirect, to cause the direction or management
100
+ of such entity, whether by contract or otherwise, or (b) ownership of more than
101
+ fifty percent (50%) of the outstanding shares or beneficial ownership of such
102
+ entity.
103
+
104
+
105
+ 2. License Grants and Conditions
106
+ --------------------------------
107
+
108
+
109
+ 2.1. Grants
110
+
111
+ Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive
112
+ license:
113
+
114
+ a.
115
+
116
+ under intellectual property rights (other than patent or trademark)
117
+ Licensable by such Contributor to use, reproduce, make available, modify,
118
+ display, perform, distribute, and otherwise exploit its Contributions,
119
+ either on an unmodified basis, with Modifications, or as part of a Larger
120
+ Work; and
121
+
122
+ b.
123
+
124
+ under Patent Claims of such Contributor to make, use, sell, offer for sale,
125
+ have made, import, and otherwise transfer either its Contributions or its
126
+ Contributor Version.
127
+
128
+
129
+ 2.2. Effective Date
130
+
131
+ The licenses granted in Section 2.1 with respect to any Contribution become
132
+ effective for each Contribution on the date the Contributor first distributes
133
+ such Contribution.
134
+
135
+
136
+ 2.3. Limitations on Grant Scope
137
+
138
+ The licenses granted in this Section 2 are the only rights granted under this
139
+ License. No additional rights or licenses will be implied from the distribution
140
+ or licensing of Covered Software under this License. Notwithstanding
141
+ Section 2.1(b) above, no patent license is granted by a Contributor:
142
+
143
+ a.
144
+
145
+ for any code that a Contributor has removed from Covered Software; or
146
+
147
+ b.
148
+
149
+ for infringements caused by: (i) Your and any other third party's
150
+ modifications of Covered Software, or (ii) the combination of its
151
+ Contributions with other software (except as part of its Contributor
152
+ Version); or
153
+
154
+ c.
155
+
156
+ under Patent Claims infringed by Covered Software in the absence of its
157
+ Contributions.
158
+
159
+ This License does not grant any rights in the trademarks, service marks, or
160
+ logos of any Contributor (except as may be necessary to comply with the notice
161
+ requirements in Section 3.4).
162
+
163
+
164
+ 2.4. Subsequent Licenses
165
+
166
+ No Contributor makes additional grants as a result of Your choice to distribute
167
+ the Covered Software under a subsequent version of this License (see
168
+ Section 10.2) or under the terms of a Secondary License (if permitted under the
169
+ terms of Section 3.3).
170
+
171
+
172
+ 2.5. Representation
173
+
174
+ Each Contributor represents that the Contributor believes its Contributions are
175
+ its original creation(s) or it has sufficient rights to grant the rights to its
176
+ Contributions conveyed by this License.
177
+
178
+
179
+ 2.6. Fair Use
180
+
181
+ This License is not intended to limit any rights You have under applicable
182
+ copyright doctrines of fair use, fair dealing, or other equivalents.
183
+
184
+
185
+ 2.7. Conditions
186
+
187
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
188
+ Section 2.1.
189
+
190
+
191
+ 3. Responsibilities
192
+ -------------------
193
+
194
+
195
+ 3.1. Distribution of Source Form
196
+
197
+ All distribution of Covered Software in Source Code Form, including any
198
+ Modifications that You create or to which You contribute, must be under the
199
+ terms of this License. You must inform recipients that the Source Code Form of
200
+ the Covered Software is governed by the terms of this License, and how they can
201
+ obtain a copy of this License. You may not attempt to alter or restrict the
202
+ recipients' rights in the Source Code Form.
203
+
204
+
205
+ 3.2. Distribution of Executable Form
206
+
207
+ If You distribute Covered Software in Executable Form then:
208
+
209
+ a.
210
+
211
+ such Covered Software must also be made available in Source Code Form, as
212
+ described in Section 3.1, and You must inform recipients of the Executable
213
+ Form how they can obtain a copy of such Source Code Form by reasonable
214
+ means in a timely manner, at a charge no more than the cost of distribution
215
+ to the recipient; and
216
+
217
+ b.
218
+
219
+ You may distribute such Executable Form under the terms of this License, or
220
+ sublicense it under different terms, provided that the license for the
221
+ Executable Form does not attempt to limit or alter the recipients' rights
222
+ in the Source Code Form under this License.
223
+
224
+
225
+ 3.3. Distribution of a Larger Work
226
+
227
+ You may create and distribute a Larger Work under terms of Your choice,
228
+ provided that You also comply with the requirements of this License for the
229
+ Covered Software. If the Larger Work is a combination of Covered Software with
230
+ a work governed by one or more Secondary Licenses, and the Covered Software is
231
+ not Incompatible With Secondary Licenses, this License permits You to
232
+ additionally distribute such Covered Software under the terms of such Secondary
233
+ License(s), so that the recipient of the Larger Work may, at their option,
234
+ further distribute the Covered Software under the terms of either this License
235
+ or such Secondary License(s).
236
+
237
+
238
+ 3.4. Notices
239
+
240
+ You may not remove or alter the substance of any license notices (including
241
+ copyright notices, patent notices, disclaimers of warranty, or limitations of
242
+ liability) contained within the Source Code Form of the Covered Software,
243
+ except that You may alter any license notices to the extent required to remedy
244
+ known factual inaccuracies.
245
+
246
+
247
+ 3.5. Application of Additional Terms
248
+
249
+ You may choose to offer, and to charge a fee for, warranty, support, indemnity
250
+ or liability obligations to one or more recipients of Covered Software.
251
+ However, You may do so only on Your own behalf, and not on behalf of any
252
+ Contributor. You must make it absolutely clear that any such warranty, support,
253
+ indemnity, or liability obligation is offered by You alone, and You hereby
254
+ agree to indemnify every Contributor for any liability incurred by such
255
+ Contributor as a result of warranty, support, indemnity or liability terms You
256
+ offer. You may include additional disclaimers of warranty and limitations of
257
+ liability specific to any jurisdiction.
258
+
259
+
260
+ 4. Inability to Comply Due to Statute or Regulation
261
+ ---------------------------------------------------
262
+
263
+ If it is impossible for You to comply with any of the terms of this License with
264
+ respect to some or all of the Covered Software due to statute, judicial order, or
265
+ regulation then You must: (a) comply with the terms of this License to the
266
+ maximum extent possible; and (b) describe the limitations and the code they
267
+ affect. Such description must be placed in a text file included with all
268
+ distributions of the Covered Software under this License. Except to the extent
269
+ prohibited by statute or regulation, such description must be sufficiently
270
+ detailed for a recipient of ordinary skill to be able to understand it.
271
+
272
+
273
+ 5. Termination
274
+ --------------
275
+
276
+ 5.1. The rights granted under this License will terminate automatically if You
277
+ fail to comply with any of its terms. However, if You become compliant, then
278
+ the rights granted under this License from a particular Contributor are
279
+ reinstated (a) provisionally, unless and until such Contributor explicitly and
280
+ finally terminates Your grants, and (b) on an ongoing basis, if such
281
+ Contributor fails to notify You of the non-compliance by some reasonable means
282
+ prior to 60 days after You have come back into compliance. Moreover, Your
283
+ grants from a particular Contributor are reinstated on an ongoing basis if such
284
+ Contributor notifies You of the non-compliance by some reasonable means, this
285
+ is the first time You have received notice of non-compliance with this License
286
+ from such Contributor, and You become compliant prior to 30 days after Your
287
+ receipt of the notice.
288
+
289
+ 5.2. If You initiate litigation against any entity by asserting a patent
290
+ infringement claim (excluding declaratory judgment actions, counter-claims, and
291
+ cross-claims) alleging that a Contributor Version directly or indirectly
292
+ infringes any patent, then the rights granted to You by any and all
293
+ Contributors for the Covered Software under Section 2.1 of this License shall
294
+ terminate.
295
+
296
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
297
+ license agreements (excluding distributors and resellers) which have been
298
+ validly granted by You or Your distributors under this License prior to
299
+ termination shall survive termination.
300
+
301
+
302
+ 6. Disclaimer of Warranty
303
+ -------------------------
304
+
305
+ Covered Software is provided under this License on an "as is" basis, without
306
+ warranty of any kind, either expressed, implied, or statutory, including, without
307
+ limitation, warranties that the Covered Software is free of defects,
308
+ merchantable, fit for a particular purpose or non-infringing. The entire risk as
309
+ to the quality and performance of the Covered Software is with You. Should any
310
+ Covered Software prove defective in any respect, You (not any Contributor) assume
311
+ the cost of any necessary servicing, repair, or correction. This disclaimer of
312
+ warranty constitutes an essential part of this License. No use of any Covered
313
+ Software is authorized under this License except under this disclaimer.
314
+
315
+
316
+ 7. Limitation of Liability
317
+ --------------------------
318
+
319
+ Under no circumstances and under no legal theory, whether tort (including
320
+ negligence), contract, or otherwise, shall any Contributor, or anyone who
321
+ distributes Covered Software as permitted above, be liable to You for any direct,
322
+ indirect, special, incidental, or consequential damages of any character
323
+ including, without limitation, damages for lost profits, loss of goodwill, work
324
+ stoppage, computer failure or malfunction, or any and all other commercial
325
+ damages or losses, even if such party shall have been informed of the possibility
326
+ of such damages. This limitation of liability shall not apply to liability for
327
+ death or personal injury resulting from such party's negligence to the extent
328
+ applicable law prohibits such limitation. Some jurisdictions do not allow the
329
+ exclusion or limitation of incidental or consequential damages, so this exclusion
330
+ and limitation may not apply to You.
331
+
332
+
333
+ 8. Litigation
334
+ -------------
335
+
336
+ Any litigation relating to this License may be brought only in the courts of a
337
+ jurisdiction where the defendant maintains its principal place of business and
338
+ such litigation shall be governed by laws of that jurisdiction, without reference
339
+ to its conflict-of-law provisions. Nothing in this Section shall prevent a
340
+ party's ability to bring cross-claims or counter-claims.
341
+
342
+
343
+ 9. Miscellaneous
344
+ ----------------
345
+
346
+ This License represents the complete agreement concerning the subject matter
347
+ hereof. If any provision of this License is held to be unenforceable, such
348
+ provision shall be reformed only to the extent necessary to make it enforceable.
349
+ Any law or regulation which provides that the language of a contract shall be
350
+ construed against the drafter shall not be used to construe this License against
351
+ a Contributor.
352
+
353
+
354
+ 10. Versions of the License
355
+ ---------------------------
356
+
357
+
358
+ 10.1. New Versions
359
+
360
+ Mozilla Foundation is the license steward. Except as provided in Section 10.3,
361
+ no one other than the license steward has the right to modify or publish new
362
+ versions of this License. Each version will be given a distinguishing version
363
+ number.
364
+
365
+
366
+ 10.2. Effect of New Versions
367
+
368
+ You may distribute the Covered Software under the terms of the version of the
369
+ License under which You originally received the Covered Software, or under the
370
+ terms of any subsequent version published by the license steward.
371
+
372
+
373
+ 10.3. Modified Versions
374
+
375
+ If you create software not governed by this License, and you want to create a
376
+ new license for such software, you may create and use a modified version of
377
+ this License if you rename the license and remove any references to the name of
378
+ the license steward (except to note that such modified license differs from
379
+ this License).
380
+
381
+
382
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
383
+ Licenses
384
+
385
+ If You choose to distribute Source Code Form that is Incompatible With
386
+ Secondary Licenses under the terms of this version of the License, the notice
387
+ described in Exhibit B of this License must be attached.
388
+
389
+
390
+ Exhibit A - Source Code Form License Notice
391
+ -------------------------------------------
392
+
393
+ This Source Code Form is subject to the terms of the Mozilla Public License,
394
+ v. 2.0. If a copy of the MPL was not distributed with this file, You can
395
+ obtain one at http://mozilla.org/MPL/2.0/.
396
+
397
+ If it is not possible or desirable to put the notice in a particular file, then
398
+ You may include the notice in a location (such as a LICENSE file in a relevant
399
+ directory) where a recipient would be likely to look for such a notice.
400
+
401
+ You may add additional accurate notices of copyright ownership.
402
+
403
+
404
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
405
+ ---------------------------------------------------------
406
+
407
+ This Source Code Form is "Incompatible With Secondary Licenses", as defined
408
+ by the Mozilla Public License, v. 2.0.
@@ -0,0 +1,37 @@
1
+ Plexus Classworlds License
2
+ ==========================
3
+
4
+ Copyright 2002 (C) The Codehaus. All Rights Reserved.
5
+
6
+ Redistribution and use of this software and associated documentation
7
+ ("Software"), with or without modification, are permitted provided that the
8
+ following conditions are met:
9
+
10
+ 1. Redistributions of source code must retain copyright statements and notices.
11
+ Redistributions must also contain a copy of this document.
12
+
13
+ 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ this list of conditions and the following disclaimer in the documentation
15
+ and/or other materials provided with the distribution.
16
+
17
+ 3. The name "classworlds" must not be used to endorse or promote products
18
+ derived from this Software without prior written permission of The Codehaus.
19
+ For written permission, please contact bob@codehaus.org.
20
+
21
+ 4. Products derived from this Software may not be called "classworlds" nor may
22
+ "classworlds" appear in their names without prior written permission of The
23
+ Codehaus. "classworlds" is a registered trademark of The Codehaus.
24
+
25
+ 5. Due credit should be given to The Codehaus.
26
+ (http://classworlds.codehaus.org/).
27
+
28
+ THIS SOFTWARE IS PROVIDED BY THE CODEHAUS AND CONTRIBUTORS "AS IS" AND ANY
29
+ EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31
+ DISCLAIMED. IN NO EVENT SHALL THE CODEHAUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
32
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
37
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/dist/index.cjs ADDED
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ run: () => run
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+ var import_child_process = require("child_process");
37
+ var path = __toESM(require("path"), 1);
38
+ var fs = __toESM(require("fs"), 1);
39
+ var import_url = require("url");
40
+ var import_meta = {};
41
+ var __filename = (0, import_url.fileURLToPath)(import_meta.url);
42
+ var __dirname = path.dirname(__filename);
43
+ var JAR_NAME = "opendataloader-pdf-cli.jar";
44
+ function run(inputPath, options = {}) {
45
+ return new Promise((resolve, reject) => {
46
+ if (!fs.existsSync(inputPath)) {
47
+ return reject(new Error(`Input file or folder not found: ${inputPath}`));
48
+ }
49
+ const args = [];
50
+ if (options.outputFolder) {
51
+ args.push("--output-dir", options.outputFolder);
52
+ }
53
+ if (options.password) {
54
+ args.push("--password", options.password);
55
+ }
56
+ if (options.replaceInvalidChars) {
57
+ args.push("--replace-invalid-chars", options.replaceInvalidChars);
58
+ }
59
+ if (options.generateMarkdown) {
60
+ args.push("--markdown");
61
+ }
62
+ if (options.generateHtml) {
63
+ args.push("--html");
64
+ }
65
+ if (options.generateAnnotatedPdf) {
66
+ args.push("--pdf");
67
+ }
68
+ if (options.keepLineBreaks) {
69
+ args.push("--keep-line-breaks");
70
+ }
71
+ if (options.findHiddenText) {
72
+ args.push("--findhiddentext");
73
+ }
74
+ if (options.htmlInMarkdown) {
75
+ args.push("--markdown-with-html");
76
+ }
77
+ if (options.addImageToMarkdown) {
78
+ args.push("--markdown-with-images");
79
+ }
80
+ args.push(inputPath);
81
+ const jarPath = path.join(__dirname, "..", "lib", JAR_NAME);
82
+ if (!fs.existsSync(jarPath)) {
83
+ return reject(
84
+ new Error(`JAR file not found at ${jarPath}. Please run the build script first.`)
85
+ );
86
+ }
87
+ const command = "java";
88
+ const commandArgs = ["-jar", jarPath, ...args];
89
+ if (options.debug) {
90
+ console.error(`Running command: ${command} ${commandArgs.join(" ")}`);
91
+ }
92
+ const javaProcess = (0, import_child_process.spawn)(command, commandArgs);
93
+ let stdout = "";
94
+ let stderr = "";
95
+ javaProcess.stdout.on("data", (data) => {
96
+ const chunk = data.toString();
97
+ if (options.debug) {
98
+ process.stdout.write(chunk);
99
+ }
100
+ stdout += chunk;
101
+ });
102
+ javaProcess.stderr.on("data", (data) => {
103
+ const chunk = data.toString();
104
+ if (options.debug) {
105
+ process.stderr.write(chunk);
106
+ }
107
+ stderr += chunk;
108
+ });
109
+ javaProcess.on("close", (code) => {
110
+ if (code === 0) {
111
+ resolve(stdout);
112
+ } else {
113
+ const error = new Error(
114
+ `The opendataloader-pdf CLI exited with code ${code}.
115
+
116
+ ${stderr}`
117
+ );
118
+ reject(error);
119
+ }
120
+ });
121
+ javaProcess.on("error", (err) => {
122
+ if (err.message.includes("ENOENT")) {
123
+ reject(
124
+ new Error(
125
+ "'java' command not found. Please ensure Java is installed and in your system's PATH."
126
+ )
127
+ );
128
+ } else {
129
+ reject(err);
130
+ }
131
+ });
132
+ });
133
+ }
134
+ // Annotate the CommonJS export names for ESM import in node:
135
+ 0 && (module.exports = {
136
+ run
137
+ });
138
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { spawn } from 'child_process';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst JAR_NAME = 'opendataloader-pdf-cli.jar';\n\nexport interface RunOptions {\n outputFolder?: string;\n password?: string;\n replaceInvalidChars?: string;\n generateMarkdown?: boolean;\n generateHtml?: boolean;\n generateAnnotatedPdf?: boolean;\n keepLineBreaks?: boolean;\n findHiddenText?: boolean;\n htmlInMarkdown?: boolean;\n addImageToMarkdown?: boolean;\n debug?: boolean;\n}\n\nexport function run(inputPath: string, options: RunOptions = {}): Promise<string> {\n return new Promise((resolve, reject) => {\n if (!fs.existsSync(inputPath)) {\n return reject(new Error(`Input file or folder not found: ${inputPath}`));\n }\n\n const args: string[] = [];\n if (options.outputFolder) {\n args.push('--output-dir', options.outputFolder);\n }\n if (options.password) {\n args.push('--password', options.password);\n }\n if (options.replaceInvalidChars) {\n args.push('--replace-invalid-chars', options.replaceInvalidChars);\n }\n if (options.generateMarkdown) {\n args.push('--markdown');\n }\n if (options.generateHtml) {\n args.push('--html');\n }\n if (options.generateAnnotatedPdf) {\n args.push('--pdf');\n }\n if (options.keepLineBreaks) {\n args.push('--keep-line-breaks');\n }\n if (options.findHiddenText) {\n args.push('--findhiddentext');\n }\n if (options.htmlInMarkdown) {\n args.push('--markdown-with-html');\n }\n if (options.addImageToMarkdown) {\n args.push('--markdown-with-images');\n }\n\n args.push(inputPath);\n\n const jarPath = path.join(__dirname, '..', 'lib', JAR_NAME);\n\n if (!fs.existsSync(jarPath)) {\n return reject(\n new Error(`JAR file not found at ${jarPath}. Please run the build script first.`),\n );\n }\n\n const command = 'java';\n const commandArgs = ['-jar', jarPath, ...args];\n\n if (options.debug) {\n console.error(`Running command: ${command} ${commandArgs.join(' ')}`);\n }\n\n const javaProcess = spawn(command, commandArgs);\n\n let stdout = '';\n let stderr = '';\n\n javaProcess.stdout.on('data', (data) => {\n const chunk = data.toString();\n if (options.debug) {\n process.stdout.write(chunk);\n }\n stdout += chunk;\n });\n\n javaProcess.stderr.on('data', (data) => {\n const chunk = data.toString();\n if (options.debug) {\n process.stderr.write(chunk);\n }\n stderr += chunk;\n });\n\n javaProcess.on('close', (code) => {\n if (code === 0) {\n resolve(stdout);\n } else {\n const error = new Error(\n `The opendataloader-pdf CLI exited with code ${code}.\\n\\n${stderr}`,\n );\n reject(error);\n }\n });\n\n javaProcess.on('error', (err) => {\n if (err.message.includes('ENOENT')) {\n reject(\n new Error(\n \"'java' command not found. Please ensure Java is installed and in your system's PATH.\",\n ),\n );\n } else {\n reject(err);\n }\n });\n });\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,16 @@
1
+ interface RunOptions {
2
+ outputFolder?: string;
3
+ password?: string;
4
+ replaceInvalidChars?: string;
5
+ generateMarkdown?: boolean;
6
+ generateHtml?: boolean;
7
+ generateAnnotatedPdf?: boolean;
8
+ keepLineBreaks?: boolean;
9
+ findHiddenText?: boolean;
10
+ htmlInMarkdown?: boolean;
11
+ addImageToMarkdown?: boolean;
12
+ debug?: boolean;
13
+ }
14
+ declare function run(inputPath: string, options?: RunOptions): Promise<string>;
15
+
16
+ export { type RunOptions, run };
@@ -0,0 +1,16 @@
1
+ interface RunOptions {
2
+ outputFolder?: string;
3
+ password?: string;
4
+ replaceInvalidChars?: string;
5
+ generateMarkdown?: boolean;
6
+ generateHtml?: boolean;
7
+ generateAnnotatedPdf?: boolean;
8
+ keepLineBreaks?: boolean;
9
+ findHiddenText?: boolean;
10
+ htmlInMarkdown?: boolean;
11
+ addImageToMarkdown?: boolean;
12
+ debug?: boolean;
13
+ }
14
+ declare function run(inputPath: string, options?: RunOptions): Promise<string>;
15
+
16
+ export { type RunOptions, run };