@imgly/plugin-print-ready-pdfs-web 1.1.2 → 1.68.0-rc.1
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/CHANGELOG.md +1 -77
- package/README.md +4 -541
- package/dist/core/ghostscript-loader.d.ts +14 -0
- package/dist/core/ghostscript-loader.d.ts.map +1 -0
- package/dist/core/virtual-filesystem.d.ts +22 -0
- package/dist/core/virtual-filesystem.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +4 -12
- package/dist/index.mjs.map +4 -4
- package/dist/pdfx.d.ts +18 -0
- package/dist/pdfx.d.ts.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/blob-utils.d.ts +5 -0
- package/dist/utils/blob-utils.d.ts.map +1 -0
- package/dist/utils/browser-detection.d.ts +4 -0
- package/dist/utils/browser-detection.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +24 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/wasm/ghostscript-module.d.ts +10 -0
- package/dist/wasm/ghostscript-module.d.ts.map +1 -0
- package/package.json +7 -40
- package/src/wasm/ghostscript-module.ts +52 -13
- package/dist/index.browser.mjs +0 -38
- package/dist/index.browser.mjs.map +0 -7
- package/dist/index.node.mjs +0 -38
- package/dist/index.node.mjs.map +0 -7
- package/dist/types/asset-loader.ts +0 -56
- package/dist/types/ghostscript.ts +0 -47
- package/dist/types/index.ts +0 -3
- package/dist/types/pdfx.ts +0 -46
package/CHANGELOG.md
CHANGED
|
@@ -1,79 +1,3 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [1.1.2] - 2025-12-23
|
|
9
|
-
|
|
10
|
-
### Fixed
|
|
11
|
-
|
|
12
|
-
- Fixed Webpack 5 **runtime** compatibility issue where `import.meta.url` was transformed to `file://` URLs at build time, causing "Cannot find module" errors in Angular 17+ and other Webpack 5 bundled environments
|
|
13
|
-
|
|
14
|
-
### Added
|
|
15
|
-
|
|
16
|
-
- New `AssetLoader` interface for customizing how plugin assets (gs.js, gs.wasm, ICC profiles) are loaded
|
|
17
|
-
- `BrowserAssetLoader` for browser environments with configurable `assetPath` option
|
|
18
|
-
- `NodeAssetLoader` for Node.js environments (used automatically)
|
|
19
|
-
- New `assetPath` option for `convertToPDFX3()` to specify where assets are served from
|
|
20
|
-
- Separate browser/node entry points via conditional exports in package.json
|
|
21
|
-
- New Playwright test suite for Angular + Webpack 5 runtime verification (`pnpm test:webpack5:angular`)
|
|
22
|
-
|
|
23
|
-
### Changed
|
|
24
|
-
|
|
25
|
-
- Refactored asset loading to use dependency injection pattern for better bundler compatibility
|
|
26
|
-
- Vite and native ESM continue to work without configuration (auto-detects via `import.meta.url`)
|
|
27
|
-
|
|
28
|
-
## [1.1.1] - 2025-12-18
|
|
29
|
-
|
|
30
|
-
### Fixed
|
|
31
|
-
|
|
32
|
-
- Fixed Webpack 5 compatibility issue where Node.js module imports (`module`, `path`, `fs`, `url`) caused build failures in Angular 17+ and other Webpack 5 environments ([#11471](https://github.com/imgly/ubq/issues/11471))
|
|
33
|
-
|
|
34
|
-
## [1.1.0] - 2025-12-03
|
|
35
|
-
|
|
36
|
-
### Added
|
|
37
|
-
|
|
38
|
-
- Export `Logger` class for controlling log verbosity
|
|
39
|
-
- Export `LogLevel` type for TypeScript users
|
|
40
|
-
|
|
41
|
-
### Changed
|
|
42
|
-
|
|
43
|
-
- Library is now silent by default (log level set to `warn` instead of `info`)
|
|
44
|
-
- Ghostscript WASM module suppresses stdout/stderr output by default
|
|
45
|
-
|
|
46
|
-
### Fixed
|
|
47
|
-
|
|
48
|
-
- Eliminated Ghostscript warnings about PDF 1.5 features ("Can't use Object streams", "Can't use an XRef stream") by disabling `-dWriteObjStms` and `-dWriteXRefStm` when targeting PDF 1.4 compatibility
|
|
49
|
-
|
|
50
|
-
## [1.0.0] - 2025-10-21
|
|
51
|
-
|
|
52
|
-
### Changed
|
|
53
|
-
|
|
54
|
-
- Promoted to stable release
|
|
55
|
-
|
|
56
|
-
## [0.1.0-rc.1] - 2025-10-16
|
|
57
|
-
|
|
58
|
-
### Added
|
|
59
|
-
|
|
60
|
-
- Initial release candidate for Print-Ready PDFs plugin
|
|
61
|
-
- Full PDF/X-3:2003 compliance with RGB to CMYK conversion
|
|
62
|
-
- Three bundled ICC profiles:
|
|
63
|
-
- FOGRA39 (ISO Coated v2) - European printing standard
|
|
64
|
-
- GRACoL 2013 - US commercial printing standard
|
|
65
|
-
- sRGB IEC61966-2.1 - Digital/web distribution
|
|
66
|
-
- Custom ICC profile support for specialized printing requirements
|
|
67
|
-
- Function overloading for batch PDF processing
|
|
68
|
-
- Configurable OutputIntent metadata (identifier and description)
|
|
69
|
-
- Transparency flattening control (enabled by default for PDF/X-3 compliance)
|
|
70
|
-
- Browser-based PDF processing (100% client-side, no server required)
|
|
71
|
-
- Node.js compatibility
|
|
72
|
-
|
|
73
|
-
### Notes
|
|
74
|
-
|
|
75
|
-
- This is a release candidate for testing and feedback
|
|
76
|
-
- Source code available at: https://github.com/imgly/plugins
|
|
77
|
-
- Ghostscript WASM components are AGPL-3.0 licensed
|
|
78
|
-
- Client-side execution model minimizes AGPL compliance concerns
|
|
79
|
-
- For commercial licensing guidance, consult legal counsel or contact IMG.LY support
|
|
3
|
+
See the main [CE.SDK CHANGELOG](https://img.ly/docs/cesdk/changelog/) for all plugin changes.
|
package/README.md
CHANGED
|
@@ -1,546 +1,9 @@
|
|
|
1
1
|
# @imgly/plugin-print-ready-pdfs-web
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Print-Ready PDFs plugin for CE.SDK editor - PDF/X conversion and export functionality. Contains AGPL-3.0 licensed Ghostscript WASM.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
For documentation, visit: https://img.ly/docs/cesdk
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## License
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- CMYK color space instead of RGB
|
|
12
|
-
- PDF/X-3 or PDF/X-4 compliance
|
|
13
|
-
- Embedded ICC color profiles for accurate color reproduction
|
|
14
|
-
|
|
15
|
-
## The Solution
|
|
16
|
-
|
|
17
|
-
This plugin automatically converts CE.SDK's RGB PDFs into print-ready files that meet professional printing requirements:
|
|
18
|
-
|
|
19
|
-
- ✅ **CMYK Color Space**: Converts RGB to CMYK using professional ICC profiles
|
|
20
|
-
- ✅ **PDF/X Standards**: Generates PDF/X-3 compliant files for commercial printing
|
|
21
|
-
- ✅ **Color Profile Support**: Embeds industry-standard or custom ICC profiles
|
|
22
|
-
- ✅ **100% Client-Side**: Everything runs in the browser—zero backend infrastructure
|
|
23
|
-
- ✅ **Drop-in Integration**: One function call transforms any PDF
|
|
24
|
-
|
|
25
|
-
## Key Features
|
|
26
|
-
|
|
27
|
-
- **Drop-in Replacement**: Works seamlessly with CE.SDK's existing export functionality
|
|
28
|
-
- **100% Client-Side**: All processing happens in the browser—no server infrastructure required
|
|
29
|
-
- **Industry Profiles Included**: Ships with FOGRA39 (Europe), GRACoL 2013 (US), and sRGB profiles
|
|
30
|
-
- **Custom Profile Support**: Bring your own ICC profile to match sophisticated print pipelines
|
|
31
|
-
- **PDF/X-3 Compliant**: Generates files that meet commercial printing standards
|
|
32
|
-
|
|
33
|
-
## Installation
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
npm install @imgly/plugin-print-ready-pdfs-web
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Bundler Setup (Webpack 5 / Angular)
|
|
40
|
-
|
|
41
|
-
When using bundlers like Webpack 5 or Angular CLI, the plugin's WASM assets need to be copied to your public folder and the `assetPath` option must be provided.
|
|
42
|
-
|
|
43
|
-
**Why is this needed?** Webpack 5 transforms `import.meta.url` to `file://` URLs at build time, which don't work in browsers. The `assetPath` option tells the plugin where to find its assets at runtime.
|
|
44
|
-
|
|
45
|
-
### Angular CLI
|
|
46
|
-
|
|
47
|
-
Add to your `angular.json` in the `assets` array:
|
|
48
|
-
|
|
49
|
-
```json
|
|
50
|
-
{
|
|
51
|
-
"glob": "{gs.js,gs.wasm,*.icc}",
|
|
52
|
-
"input": "node_modules/@imgly/plugin-print-ready-pdfs-web/dist",
|
|
53
|
-
"output": "/assets/print-ready-pdfs"
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Then provide the `assetPath` option:
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
const printReadyPDF = await convertToPDFX3(pdfBlob, {
|
|
61
|
-
outputProfile: 'fogra39',
|
|
62
|
-
assetPath: '/assets/print-ready-pdfs/'
|
|
63
|
-
});
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Webpack 5
|
|
67
|
-
|
|
68
|
-
Use `copy-webpack-plugin` to copy the assets:
|
|
69
|
-
|
|
70
|
-
```javascript
|
|
71
|
-
const CopyPlugin = require('copy-webpack-plugin');
|
|
72
|
-
|
|
73
|
-
module.exports = {
|
|
74
|
-
plugins: [
|
|
75
|
-
new CopyPlugin({
|
|
76
|
-
patterns: [{
|
|
77
|
-
from: 'node_modules/@imgly/plugin-print-ready-pdfs-web/dist/*.{js,wasm,icc}',
|
|
78
|
-
to: 'assets/[name][ext]'
|
|
79
|
-
}]
|
|
80
|
-
})
|
|
81
|
-
]
|
|
82
|
-
};
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Then provide the `assetPath` option:
|
|
86
|
-
|
|
87
|
-
```javascript
|
|
88
|
-
const printReadyPDF = await convertToPDFX3(pdfBlob, {
|
|
89
|
-
outputProfile: 'fogra39',
|
|
90
|
-
assetPath: '/assets/'
|
|
91
|
-
});
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Vite / Native ESM
|
|
95
|
-
|
|
96
|
-
No additional configuration needed. The plugin automatically resolves assets using `import.meta.url`.
|
|
97
|
-
|
|
98
|
-
### Custom Asset Loading
|
|
99
|
-
|
|
100
|
-
For advanced use cases (CDN hosting, custom loading logic), implement the `AssetLoader` interface:
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
103
|
-
import { convertToPDFX3, type AssetLoader } from '@imgly/plugin-print-ready-pdfs-web';
|
|
104
|
-
|
|
105
|
-
class CDNAssetLoader implements AssetLoader {
|
|
106
|
-
private cdnBase = 'https://cdn.example.com/pdf-plugin/v1.1.2/';
|
|
107
|
-
|
|
108
|
-
async loadGhostscriptModule() {
|
|
109
|
-
const module = await import(/* webpackIgnore: true */ this.cdnBase + 'gs.js');
|
|
110
|
-
return module.default;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
getWasmPath() {
|
|
114
|
-
return this.cdnBase + 'gs.wasm';
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async loadICCProfile(name: string) {
|
|
118
|
-
const response = await fetch(this.cdnBase + name);
|
|
119
|
-
return response.blob();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const printReadyPDF = await convertToPDFX3(pdfBlob, {
|
|
124
|
-
outputProfile: 'fogra39',
|
|
125
|
-
assetLoader: new CDNAssetLoader()
|
|
126
|
-
});
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Quick Start
|
|
130
|
-
|
|
131
|
-
Just one function call transforms any PDF into a print-ready file:
|
|
132
|
-
|
|
133
|
-
```javascript
|
|
134
|
-
import { convertToPDFX3 } from '@imgly/plugin-print-ready-pdfs-web';
|
|
135
|
-
|
|
136
|
-
// Convert CE.SDK's RGB PDF to print-ready CMYK
|
|
137
|
-
const printReadyPDF = await convertToPDFX3(pdfBlob, {
|
|
138
|
-
outputProfile: 'fogra39', // European printing standard
|
|
139
|
-
title: 'My Print Document',
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// That's it! The PDF is now ready for professional printing
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
## Drop-in CE.SDK Integration
|
|
146
|
-
|
|
147
|
-
Add print-ready export to your existing CE.SDK implementation with minimal code changes:
|
|
148
|
-
|
|
149
|
-
```javascript
|
|
150
|
-
import CreativeEditorSDK from '@cesdk/cesdk-js';
|
|
151
|
-
import { convertToPDFX3 } from '@imgly/plugin-print-ready-pdfs-web';
|
|
152
|
-
|
|
153
|
-
const config = {
|
|
154
|
-
license: 'your-cesdk-license',
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const cesdk = await CreativeEditorSDK.create('#editor', config);
|
|
158
|
-
await cesdk.createDesignScene();
|
|
159
|
-
|
|
160
|
-
// Add custom export button to the navigation bar
|
|
161
|
-
cesdk.ui.insertNavigationBarOrderComponent('last', {
|
|
162
|
-
id: 'ly.img.actions.navigationBar',
|
|
163
|
-
children: [
|
|
164
|
-
{
|
|
165
|
-
key: 'export-print-ready-pdf',
|
|
166
|
-
id: 'ly.img.action.navigationBar',
|
|
167
|
-
label: 'Export Print-Ready PDF',
|
|
168
|
-
iconName: '@imgly/Download',
|
|
169
|
-
onClick: async () => {
|
|
170
|
-
const sceneId = cesdk.engine.scene.get();
|
|
171
|
-
const pdfBlob = await cesdk.engine.block.export(
|
|
172
|
-
sceneId,
|
|
173
|
-
'application/pdf'
|
|
174
|
-
);
|
|
175
|
-
const printReadyBlob = await convertToPDFX3(pdfBlob, {
|
|
176
|
-
outputProfile: 'fogra39',
|
|
177
|
-
title: 'Print-Ready Export',
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// Download
|
|
181
|
-
const url = URL.createObjectURL(printReadyBlob);
|
|
182
|
-
const link = document.createElement('a');
|
|
183
|
-
link.href = url;
|
|
184
|
-
link.download = 'design-print-ready.pdf';
|
|
185
|
-
link.click();
|
|
186
|
-
URL.revokeObjectURL(url);
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
],
|
|
190
|
-
});
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## API Reference
|
|
194
|
-
|
|
195
|
-
### `convertToPDFX3(pdf, options)` / `convertToPDFX3(pdfs, options)`
|
|
196
|
-
|
|
197
|
-
Converts RGB PDF(s) to print-ready format. This function supports both single PDF conversion and batch processing through function overloading.
|
|
198
|
-
|
|
199
|
-
**Single PDF Conversion:**
|
|
200
|
-
|
|
201
|
-
```typescript
|
|
202
|
-
convertToPDFX3(pdf: Blob, options: PDFX3Options): Promise<Blob>
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
**Parameters:**
|
|
206
|
-
- `pdf` (Blob): Input PDF file as a Blob object
|
|
207
|
-
- `options` (PDFX3Options): Conversion configuration
|
|
208
|
-
|
|
209
|
-
**Returns:** Promise<Blob> - The print-ready PDF file
|
|
210
|
-
|
|
211
|
-
**Batch Processing:**
|
|
212
|
-
|
|
213
|
-
```typescript
|
|
214
|
-
convertToPDFX3(pdfs: Blob[], options: PDFX3Options): Promise<Blob[]>
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
**Parameters:**
|
|
218
|
-
- `pdfs` (Blob[]): Array of input PDF files as Blob objects
|
|
219
|
-
- `options` (PDFX3Options): Conversion configuration (applied to all PDFs)
|
|
220
|
-
|
|
221
|
-
**Returns:** Promise<Blob[]> - Array of print-ready PDF files
|
|
222
|
-
|
|
223
|
-
**Options Interface:**
|
|
224
|
-
|
|
225
|
-
```typescript
|
|
226
|
-
interface PDFX3Options {
|
|
227
|
-
// Required
|
|
228
|
-
outputProfile: 'gracol' | 'fogra39' | 'srgb' | 'custom';
|
|
229
|
-
|
|
230
|
-
// Optional
|
|
231
|
-
customProfile?: Blob; // Required only if outputProfile is 'custom'
|
|
232
|
-
title?: string; // Document title
|
|
233
|
-
outputConditionIdentifier?: string; // ICC profile identifier for OutputIntent
|
|
234
|
-
outputCondition?: string; // Human-readable output condition description
|
|
235
|
-
flattenTransparency?: boolean; // Flatten transparency (default: true for PDF/X-3)
|
|
236
|
-
|
|
237
|
-
// Asset loading (for bundler compatibility)
|
|
238
|
-
assetPath?: string; // URL path where plugin assets are served
|
|
239
|
-
assetLoader?: AssetLoader; // Custom asset loader (advanced)
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
**Asset Loading Options:**
|
|
244
|
-
|
|
245
|
-
| Option | When to Use |
|
|
246
|
-
|--------|-------------|
|
|
247
|
-
| Neither | Vite, native ESM - auto-detected via `import.meta.url` |
|
|
248
|
-
| `assetPath` | Webpack 5, Angular - specify where assets are served |
|
|
249
|
-
| `assetLoader` | CDN hosting, custom loading logic - full control |
|
|
250
|
-
|
|
251
|
-
See [Bundler Setup](#bundler-setup-webpack-5--angular) for configuration examples.
|
|
252
|
-
|
|
253
|
-
**Note:** Batch processing handles each PDF sequentially to avoid overwhelming the WASM module.
|
|
254
|
-
|
|
255
|
-
**OutputIntent Metadata:**
|
|
256
|
-
|
|
257
|
-
The `outputConditionIdentifier` and `outputCondition` fields control the PDF/X-3 OutputIntent metadata:
|
|
258
|
-
|
|
259
|
-
- **Built-in profiles** (fogra39, gracol, srgb): Use preset values automatically (e.g., "FOGRA39", "ISO Coated v2 (ECI)")
|
|
260
|
-
- **Custom profiles**: Specify your own identifiers and descriptions
|
|
261
|
-
- Both fields are optional and have sensible defaults
|
|
262
|
-
|
|
263
|
-
### Included Color Profiles
|
|
264
|
-
|
|
265
|
-
The plugin ships with industry-standard ICC profiles for immediate use:
|
|
266
|
-
|
|
267
|
-
| Profile | Purpose | Standard |
|
|
268
|
-
| ----------- | ------------------------------- | ------------------------------------------------- |
|
|
269
|
-
| `'fogra39'` | European CMYK printing standard | FOGRA39 (ISO Coated v2) - Offset printing profile |
|
|
270
|
-
| `'gracol'` | US CMYK printing standard | GRACoL 2013 - Commercial printing profile |
|
|
271
|
-
| `'srgb'` | Digital/web distribution | sRGB - When CMYK conversion isn't required |
|
|
272
|
-
| `'custom'` | Specific color requirements | Load any ICC profile for exact color matching |
|
|
273
|
-
|
|
274
|
-
## Real-World Usage
|
|
275
|
-
|
|
276
|
-
### High-Level CE.SDK Export API
|
|
277
|
-
|
|
278
|
-
The simplest way to integrate with CE.SDK's high-level export function:
|
|
279
|
-
|
|
280
|
-
```javascript
|
|
281
|
-
import CreativeEditorSDK from '@cesdk/cesdk-js';
|
|
282
|
-
import { convertToPDFX3 } from '@imgly/plugin-print-ready-pdfs-web';
|
|
283
|
-
|
|
284
|
-
const cesdk = await CreativeEditorSDK.create('#editor', config);
|
|
285
|
-
|
|
286
|
-
// Export and convert to print-ready in one flow
|
|
287
|
-
const { blobs } = await cesdk.export({
|
|
288
|
-
mimeType: 'application/pdf'
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
// Function overloading automatically handles array input
|
|
292
|
-
const printReadyBlobs = await convertToPDFX3(blobs, {
|
|
293
|
-
outputProfile: 'fogra39',
|
|
294
|
-
title: 'Print-Ready Export',
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
// Download the first print-ready PDF
|
|
298
|
-
const url = URL.createObjectURL(printReadyBlobs[0]);
|
|
299
|
-
const link = document.createElement('a');
|
|
300
|
-
link.href = url;
|
|
301
|
-
link.download = 'design-print-ready.pdf';
|
|
302
|
-
link.click();
|
|
303
|
-
URL.revokeObjectURL(url);
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
### Professional Printing Requirements
|
|
307
|
-
|
|
308
|
-
```javascript
|
|
309
|
-
import { convertToPDFX3 } from '@imgly/plugin-print-ready-pdfs-web';
|
|
310
|
-
|
|
311
|
-
// Your user designed materials in CE.SDK
|
|
312
|
-
const designPDF = await cesdk.engine.block.export(sceneId, 'application/pdf');
|
|
313
|
-
|
|
314
|
-
// Convert to print-ready format with CMYK and PDF/X-3 compliance
|
|
315
|
-
const printReadyPDF = await convertToPDFX3(designPDF, {
|
|
316
|
-
outputProfile: 'fogra39', // Industry-standard CMYK profile
|
|
317
|
-
title: 'Marketing Materials - Q4 2024',
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
// PDF now meets professional printing requirements
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
### Regional Color Standards
|
|
324
|
-
|
|
325
|
-
```javascript
|
|
326
|
-
// US Commercial Printing Standard
|
|
327
|
-
const usPrintReady = await convertToPDFX3(pdfBlob, {
|
|
328
|
-
outputProfile: 'gracol', // GRACoL 2013 CMYK profile
|
|
329
|
-
title: 'US Print Production',
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
// European Printing Standard
|
|
333
|
-
const euPrintReady = await convertToPDFX3(pdfBlob, {
|
|
334
|
-
outputProfile: 'fogra39', // FOGRA39 CMYK profile
|
|
335
|
-
title: 'EU Print Production',
|
|
336
|
-
});
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
### Custom Color Profiles
|
|
340
|
-
|
|
341
|
-
Bring your own ICC profile for specialized printing requirements:
|
|
342
|
-
|
|
343
|
-
```javascript
|
|
344
|
-
// Load a specific ICC profile for exact color requirements
|
|
345
|
-
const customProfile = await fetch('/profiles/custom-cmyk-profile.icc').then(
|
|
346
|
-
(r) => r.blob()
|
|
347
|
-
);
|
|
348
|
-
|
|
349
|
-
const printReadyPDF = await convertToPDFX3(pdfBlob, {
|
|
350
|
-
outputProfile: 'custom',
|
|
351
|
-
customProfile: customProfile,
|
|
352
|
-
title: 'Specialized Print Output',
|
|
353
|
-
outputConditionIdentifier: 'Custom_Newsprint_CMYK',
|
|
354
|
-
outputCondition: 'Custom newsprint profile for high-speed web press'
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
// PDF now uses your exact CMYK color profile with custom metadata
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
**Override Built-in Profile Metadata:**
|
|
361
|
-
|
|
362
|
-
You can also override the metadata for built-in profiles:
|
|
363
|
-
|
|
364
|
-
```javascript
|
|
365
|
-
const printReadyPDF = await convertToPDFX3(pdfBlob, {
|
|
366
|
-
outputProfile: 'fogra39',
|
|
367
|
-
title: 'Custom FOGRA39 Variant',
|
|
368
|
-
outputConditionIdentifier: 'FOGRA39_Modified',
|
|
369
|
-
outputCondition: 'Modified ISO Coated v2 for specific press'
|
|
370
|
-
});
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
### Batch Processing
|
|
374
|
-
|
|
375
|
-
Process multiple PDFs using the overloaded function:
|
|
376
|
-
|
|
377
|
-
```javascript
|
|
378
|
-
import { convertToPDFX3 } from '@imgly/plugin-print-ready-pdfs-web';
|
|
379
|
-
|
|
380
|
-
// Array input automatically triggers batch processing (sequential)
|
|
381
|
-
const printReadyPDFs = await convertToPDFX3(pdfBlobs, {
|
|
382
|
-
outputProfile: 'gracol',
|
|
383
|
-
title: 'Batch Export',
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
// Or process in parallel for maximum speed (use with caution for large files)
|
|
387
|
-
const printReadyPDFs = await Promise.all(
|
|
388
|
-
pdfBlobs.map((pdf) =>
|
|
389
|
-
convertToPDFX3(pdf, {
|
|
390
|
-
outputProfile: 'gracol',
|
|
391
|
-
title: 'Batch Export',
|
|
392
|
-
})
|
|
393
|
-
)
|
|
394
|
-
);
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
**Note:** When passing an array, PDFs are processed sequentially to avoid overwhelming the WASM module. For parallel processing, use `Promise.all` with individual calls. Sequential processing is recommended for reliability.
|
|
398
|
-
|
|
399
|
-
## Testing
|
|
400
|
-
|
|
401
|
-
Test the integration with a complete CE.SDK example:
|
|
402
|
-
|
|
403
|
-
```bash
|
|
404
|
-
# Start the test server
|
|
405
|
-
npm run test:cesdk
|
|
406
|
-
|
|
407
|
-
# Open http://localhost:3001 in your browser
|
|
408
|
-
# Create designs and export with different print profiles
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
The test interface includes:
|
|
412
|
-
|
|
413
|
-
- Live CE.SDK editor
|
|
414
|
-
- Navigation bar with print-ready export options
|
|
415
|
-
- Real-time conversion and download
|
|
416
|
-
|
|
417
|
-
## PDF/X-3 Compliance Details
|
|
418
|
-
|
|
419
|
-
The plugin ensures full PDF/X-3:2003 compliance by:
|
|
420
|
-
|
|
421
|
-
### OutputIntent
|
|
422
|
-
|
|
423
|
-
Every converted PDF includes a properly configured OutputIntent entry with:
|
|
424
|
-
- **DestOutputProfile**: The embedded ICC profile data
|
|
425
|
-
- **OutputConditionIdentifier**: Standard identifier (e.g., "FOGRA39", "GRACoL 2013")
|
|
426
|
-
- **OutputCondition**: Human-readable description of the printing condition
|
|
427
|
-
- **S**: Set to `/GTS_PDFX` for PDF/X-3 standard
|
|
428
|
-
|
|
429
|
-
### Trapped Entry
|
|
430
|
-
|
|
431
|
-
The `/Trapped` field is automatically set to `/False` in the PDF document info dictionary, indicating that trapping operations have not been performed. This is the correct value since the plugin performs color conversion but does not apply trapping.
|
|
432
|
-
|
|
433
|
-
Per the PDF/X-3 specification, this field must be set to either `/True` or `/False` (not `/Unknown`).
|
|
434
|
-
|
|
435
|
-
### Text and Vector Preservation
|
|
436
|
-
|
|
437
|
-
Text and vector graphics are preserved in their original vector format during conversion. Only the color space is converted from RGB to CMYK—no rasterization occurs for non-transparent content.
|
|
438
|
-
|
|
439
|
-
### Transparency Handling
|
|
440
|
-
|
|
441
|
-
**Important:** PDF/X-3:2003 is based on PDF 1.3 which does not support transparency. By default, the plugin flattens all transparency to ensure compliance:
|
|
442
|
-
|
|
443
|
-
```javascript
|
|
444
|
-
// Default behavior - flattens transparency (PDF/X-3 compliant)
|
|
445
|
-
const printReadyPDF = await convertToPDFX3(pdfBlob, {
|
|
446
|
-
outputProfile: 'fogra39',
|
|
447
|
-
title: 'Print Ready',
|
|
448
|
-
// flattenTransparency: true (default)
|
|
449
|
-
});
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
**Transparency Flattening Behavior:**
|
|
453
|
-
- **Pages with transparency** → Rasterized to bitmap at high resolution
|
|
454
|
-
- **Pages without transparency** → Preserved as vectors (text, shapes remain editable)
|
|
455
|
-
- **Mixed content** → Only transparent elements are rasterized
|
|
456
|
-
|
|
457
|
-
**Why Flattening is Required:**
|
|
458
|
-
|
|
459
|
-
PDF/X-3 is based on PDF 1.3, which predates PDF transparency features (introduced in PDF 1.4). Therefore, **transparency flattening is mandatory** for PDF/X-3 compliance—this is a requirement of the standard itself, not a limitation of the tooling. Any PDF with transparency must have those elements composited into opaque equivalents before it can be a valid PDF/X-3 file.
|
|
460
|
-
|
|
461
|
-
**⚠️ Known Issue: Black Backgrounds During Flattening**
|
|
462
|
-
|
|
463
|
-
During the flattening process, certain elements with transparency may render with black backgrounds instead of their intended appearance. Affected elements include:
|
|
464
|
-
|
|
465
|
-
- Gradients that fade to transparent
|
|
466
|
-
- PNG images with alpha channels (e.g., stickers, icons)
|
|
467
|
-
- Text with emoji characters
|
|
468
|
-
- Overlapping semi-transparent elements
|
|
469
|
-
|
|
470
|
-
**Workaround - Preserve Transparency:**
|
|
471
|
-
|
|
472
|
-
If visual fidelity is more important than strict PDF/X-3 compliance, you can disable transparency flattening:
|
|
473
|
-
|
|
474
|
-
```javascript
|
|
475
|
-
// Preserve transparency for better visual fidelity
|
|
476
|
-
const printReadyPDF = await convertToPDFX3(pdfBlob, {
|
|
477
|
-
outputProfile: 'fogra39',
|
|
478
|
-
title: 'Visual Fidelity Preserved',
|
|
479
|
-
flattenTransparency: false, // Preserves appearance but may not be strictly PDF/X-3 compliant
|
|
480
|
-
});
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
**Trade-offs:**
|
|
484
|
-
| Setting | Visual Fidelity | PDF/X-3 Compliance |
|
|
485
|
-
|---------|----------------|-------------------|
|
|
486
|
-
| `flattenTransparency: true` (default) | May have artifacts | Strictly compliant |
|
|
487
|
-
| `flattenTransparency: false` | Preserved | May not validate if transparency exists |
|
|
488
|
-
|
|
489
|
-
**Avoiding Transparency Issues in CE.SDK:**
|
|
490
|
-
|
|
491
|
-
To ensure best results with PDF/X-3, design without transparency:
|
|
492
|
-
- Use 100% opacity for all elements
|
|
493
|
-
- Avoid PNG images with alpha channels
|
|
494
|
-
- Use solid fills instead of gradient opacity
|
|
495
|
-
- Avoid gradients that fade to transparent
|
|
496
|
-
- Export without blend modes
|
|
497
|
-
|
|
498
|
-
## Known Limitations
|
|
499
|
-
|
|
500
|
-
- **Transparency Flattening Required**: PDF/X-3 is based on PDF 1.3 which does not support transparency. Transparency flattening is mandatory for compliance. During flattening, elements with transparency may render with black backgrounds (affects gradients with alpha, PNGs with transparency, emojis). Use `flattenTransparency: false` as a workaround if visual fidelity is more important than strict compliance. See [Transparency Handling](#transparency-handling) for details.
|
|
501
|
-
- **Spot Colors**: Currently, spot colors (Pantone, custom inks) are converted to CMYK during the PDF/X-3 conversion process. This is a limitation of the current Ghostscript WASM implementation. If preserving spot colors is critical for your workflow, consider server-side PDF processing solutions.
|
|
502
|
-
- **PDF/X Versions**: Only supports PDF/X-3:2003 (not X-1a or X-4 yet)
|
|
503
|
-
|
|
504
|
-
## License Considerations
|
|
505
|
-
|
|
506
|
-
This plugin uses Ghostscript WebAssembly (AGPL-3.0 licensed) with **client-side browser execution**:
|
|
507
|
-
|
|
508
|
-
### How It Works
|
|
509
|
-
|
|
510
|
-
- Ghostscript WASM loads dynamically in the user's browser
|
|
511
|
-
- All PDF processing happens client-side on the user's device
|
|
512
|
-
- No AGPL code runs on your servers
|
|
513
|
-
- Similar to users installing a browser extension
|
|
514
|
-
|
|
515
|
-
### Usage Guidelines
|
|
516
|
-
|
|
517
|
-
✅ **Generally Safe For:**
|
|
518
|
-
|
|
519
|
-
- Open source projects
|
|
520
|
-
- Internal/private applications
|
|
521
|
-
- Commercial websites (processing happens in user's browser)
|
|
522
|
-
- SaaS applications (no server-side AGPL code execution)
|
|
523
|
-
|
|
524
|
-
⚠️ **Considerations:**
|
|
525
|
-
|
|
526
|
-
- If you bundle/modify the WASM module directly
|
|
527
|
-
- If you prevent users from accessing the source
|
|
528
|
-
- If you process PDFs server-side
|
|
529
|
-
|
|
530
|
-
### Why Browser Execution Matters
|
|
531
|
-
|
|
532
|
-
Since the AGPL-licensed Ghostscript runs entirely in the end user's browser rather than as a network service:
|
|
533
|
-
|
|
534
|
-
1. Your servers never execute AGPL code
|
|
535
|
-
2. You're not providing a "network service" under AGPL terms
|
|
536
|
-
3. The architecture is similar to CDN-delivered JavaScript libraries
|
|
537
|
-
|
|
538
|
-
For specific legal guidance, consult with legal counsel. For technical questions, contact IMG.LY support.
|
|
539
|
-
|
|
540
|
-
## Support
|
|
541
|
-
|
|
542
|
-
For questions about CE.SDK integration or print workflows:
|
|
543
|
-
|
|
544
|
-
- [CE.SDK Documentation](https://img.ly/docs)
|
|
545
|
-
- [GitHub Issues](https://github.com/imgly/plugins/issues)
|
|
546
|
-
- [IMG.LY Support](https://img.ly/support)
|
|
9
|
+
This plugin is part of the IMG.LY plugin ecosystem for CreativeEditor SDK.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EmscriptenModule } from '../types/ghostscript';
|
|
2
|
+
export interface LoaderOptions {
|
|
3
|
+
timeout?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class GhostscriptLoader {
|
|
6
|
+
private static instance;
|
|
7
|
+
private static readonly TIMEOUT_MS;
|
|
8
|
+
static load(options?: LoaderOptions): Promise<EmscriptenModule>;
|
|
9
|
+
private static loadInternal;
|
|
10
|
+
private static loadFromBundle;
|
|
11
|
+
private static loadWithTimeout;
|
|
12
|
+
static reset(): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=ghostscript-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ghostscript-loader.d.ts","sourceRoot":"","sources":["../../src/core/ghostscript-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAK7D,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0C;IAEjE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAS;WAE9B,IAAI,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC;mBASpD,YAAY;mBA2BZ,cAAc;mBAwBd,eAAe;IAepC,MAAM,CAAC,KAAK,IAAI,IAAI;CAGrB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EmscriptenModule } from '../types/ghostscript';
|
|
2
|
+
export interface FileEntry {
|
|
3
|
+
path: string;
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
cleanup: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class VirtualFileSystem {
|
|
8
|
+
private readonly module;
|
|
9
|
+
private readonly fs;
|
|
10
|
+
private readonly logger;
|
|
11
|
+
private readonly managedFiles;
|
|
12
|
+
private readonly workingDir;
|
|
13
|
+
constructor(module: EmscriptenModule, workingDir?: string);
|
|
14
|
+
private initialize;
|
|
15
|
+
private createDirIfNotExists;
|
|
16
|
+
writeBlob(path: string, blob: Blob, managed?: boolean): Promise<void>;
|
|
17
|
+
writeText(path: string, content: string, managed?: boolean): void;
|
|
18
|
+
readFile(path: string): Uint8Array;
|
|
19
|
+
exists(path: string): boolean;
|
|
20
|
+
cleanup(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=virtual-filesystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-filesystem.d.ts","sourceRoot":"","sources":["../../src/core/virtual-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAgB,MAAM,sBAAsB,CAAC;AAI3E,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,iBAAiB;IAU1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IATzB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAe;IAElC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0B;IAEvD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAGjB,MAAM,EAAE,gBAAgB,EACzC,UAAU,SAAc;IAQ1B,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,oBAAoB;IAWtB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBxE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,UAAO,GAAG,IAAI;IAe9D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAWlC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAS7B,OAAO,IAAI,IAAI;CAehB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @imgly/plugin-pdfx-web - Print-Ready PDF conversion for CE.SDK
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: This package includes Ghostscript WASM binaries licensed under AGPL-3.0.
|
|
5
|
+
* Commercial users must ensure license compliance. See README.md for details.
|
|
6
|
+
*/
|
|
7
|
+
export { convertToPDFX3 } from './pdfx';
|
|
8
|
+
export { Logger } from './utils/logger';
|
|
9
|
+
export type { PDFX3Options } from './types/pdfx';
|
|
10
|
+
export type { LogLevel } from './utils/logger';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGxC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|