@zola_do/document-manipulator 0.1.9 → 0.1.13
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/README.md +93 -0
- package/package.json +6 -3
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @zola_do/document-manipulator
|
|
2
|
+
|
|
3
|
+
PDF and DOCX merge, conversion, and template population for NestJS.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install individually
|
|
9
|
+
npm install @zola_do/document-manipulator
|
|
10
|
+
|
|
11
|
+
# Or via meta package
|
|
12
|
+
npm install @zola_do/nestjs-shared
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Dependencies
|
|
16
|
+
|
|
17
|
+
This package depends on:
|
|
18
|
+
|
|
19
|
+
- `@zola_do/minio` — Object storage for documents
|
|
20
|
+
- `docx-templates` — DOCX template filling
|
|
21
|
+
- `pdf-lib` — PDF manipulation
|
|
22
|
+
- `libreoffice-convert` — Document format conversion (requires LibreOffice installed)
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Module Setup
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { Module } from '@nestjs/common';
|
|
30
|
+
import { DocumentManipulatorModule } from '@zola_do/document-manipulator';
|
|
31
|
+
import { MinIoModule } from '@zola_do/minio';
|
|
32
|
+
|
|
33
|
+
@Module({
|
|
34
|
+
imports: [MinIoModule, DocumentManipulatorModule],
|
|
35
|
+
})
|
|
36
|
+
export class AppModule {}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Merging PDFs
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { Injectable } from '@nestjs/common';
|
|
43
|
+
import { DocumentManipulatorService } from '@zola_do/document-manipulator';
|
|
44
|
+
|
|
45
|
+
@Injectable()
|
|
46
|
+
export class ReportService {
|
|
47
|
+
constructor(private readonly docService: DocumentManipulatorService) {}
|
|
48
|
+
|
|
49
|
+
async mergePdfs(pdfBuffers: Buffer[]) {
|
|
50
|
+
await this.docService.mergePdf(pdfBuffers);
|
|
51
|
+
// Merged PDF uploaded to MinIO
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Merging DOCX
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
await this.docService.mergeDocx(docxBuffers);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Populating Templates
|
|
63
|
+
|
|
64
|
+
Fill DOCX templates with data:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const populatedBuffer = await this.docService.populateTemplate(
|
|
68
|
+
templateBuffer,
|
|
69
|
+
{ public_body: 'Procurement of procedure' },
|
|
70
|
+
);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Converting Documents
|
|
74
|
+
|
|
75
|
+
Convert between formats (requires LibreOffice):
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
const htmlBuffer = await this.docService.convertDocument(
|
|
79
|
+
docxBuffer,
|
|
80
|
+
'.html',
|
|
81
|
+
);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Exports
|
|
85
|
+
|
|
86
|
+
- `DocumentManipulatorModule` — Register the module
|
|
87
|
+
- `DocumentManipulatorService` — Merge, convert, populate templates
|
|
88
|
+
- `FileHelperService` — File utilities
|
|
89
|
+
|
|
90
|
+
## Related Packages
|
|
91
|
+
|
|
92
|
+
- [@zola_do/docx](../docx) — DOCX template processing
|
|
93
|
+
- [@zola_do/minio](../minio) — Required for storage
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zola_do/document-manipulator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "PDF/DOCX merge, conversion, template population for NestJS",
|
|
5
5
|
"author": "zolaDO",
|
|
6
6
|
"license": "ISC",
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
"files": [
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
19
22
|
"scripts": {
|
|
20
23
|
"build": "rimraf dist && tsc",
|
|
21
24
|
"prepublishOnly": "npm run build"
|
|
@@ -26,7 +29,7 @@
|
|
|
26
29
|
"rxjs": "^7.0.0 || ^8.0.0"
|
|
27
30
|
},
|
|
28
31
|
"dependencies": {
|
|
29
|
-
"@zola_do/minio": "
|
|
32
|
+
"@zola_do/minio": "^0.1.9",
|
|
30
33
|
"@scholarcy/docx-merger": "^0.3.0",
|
|
31
34
|
"axios": "^1.13.2",
|
|
32
35
|
"docx-templates": "^4.14.1",
|