emf-converter 4.18.2 → 4.20.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/README.md +42 -10
- package/dist/browser.js +849 -24
- package/dist/browser.mjs +849 -25
- package/dist/index.d.mts +57 -6
- package/dist/index.d.ts +57 -6
- package/dist/index.js +849 -24
- package/dist/index.mjs +849 -25
- package/package.json +4 -2
package/dist/index.d.mts
CHANGED
|
@@ -114,11 +114,24 @@ interface EmfConvertOptions {
|
|
|
114
114
|
y: number;
|
|
115
115
|
};
|
|
116
116
|
/**
|
|
117
|
-
* ANSI code page of the
|
|
118
|
-
* charset text and
|
|
119
|
-
*
|
|
120
|
-
* 874, 932, 936, 949, 950, 1250..1258, 54936 and
|
|
121
|
-
* fall back to 1252. Explicit text charsets
|
|
117
|
+
* ANSI code page of the playback device (Windows `GetACP()`), used for
|
|
118
|
+
* ANSI/DEFAULT charset text in EMF and WMF ANSI text records and for WMF
|
|
119
|
+
* LOGFONT face names, as Windows decodes them. Defaults to 1252.
|
|
120
|
+
* Supported values: 874, 932, 936, 949, 950, 1250..1258, 54936 and
|
|
121
|
+
* 65001. Other values fall back to 1252. Explicit text charsets keep
|
|
122
|
+
* their own code page.
|
|
123
|
+
*/
|
|
124
|
+
ansiCodePage?: number;
|
|
125
|
+
/**
|
|
126
|
+
* OEM code page of the playback device (Windows `GetOEMCP()`), used for
|
|
127
|
+
* OEM_CHARSET text in EMF and WMF ANSI text records. Defaults to 437.
|
|
128
|
+
* Supported values: 437, 737, 775, 850, 852, 855, 858, 860, 861, 862,
|
|
129
|
+
* 863, 865, 866, 874, 932, 936, 949 and 950. Other values fall back to 437.
|
|
130
|
+
*/
|
|
131
|
+
oemCodePage?: number;
|
|
132
|
+
/**
|
|
133
|
+
* ANSI code page of the WMF playback device only; overrides
|
|
134
|
+
* {@link ansiCodePage} for WMF input. Same values as `ansiCodePage`.
|
|
122
135
|
*/
|
|
123
136
|
wmfAnsiCodePage?: number;
|
|
124
137
|
/** Maximum output width in pixels. */
|
|
@@ -197,6 +210,29 @@ interface EmfConvertOptions {
|
|
|
197
210
|
*/
|
|
198
211
|
fontSmoothing?: 'cleartype' | 'gray' | 'mono';
|
|
199
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Options for {@link convertMetafileToJpegDataUrl}: every
|
|
215
|
+
* {@link EmfConvertOptions} field plus the JPEG encoding settings.
|
|
216
|
+
*/
|
|
217
|
+
interface JpegConvertOptions extends EmfConvertOptions {
|
|
218
|
+
/**
|
|
219
|
+
* JPEG quality from 0 to 1, as for `canvas.toDataURL('image/jpeg', quality)`.
|
|
220
|
+
* Default 0.92.
|
|
221
|
+
*/
|
|
222
|
+
quality?: number;
|
|
223
|
+
/**
|
|
224
|
+
* Colour the transparent background and translucent pixels are
|
|
225
|
+
* composited over, as `#rgb` or `#rrggbb` (JPEG has no alpha channel).
|
|
226
|
+
* Default `'#ffffff'`.
|
|
227
|
+
*/
|
|
228
|
+
background?: string;
|
|
229
|
+
/**
|
|
230
|
+
* `true` averages colour over 2 x 2 pixels (4:2:0) for a smaller file.
|
|
231
|
+
* Default `false`: full-resolution colour (4:4:4), which keeps coloured
|
|
232
|
+
* lines and text free of colour fringes.
|
|
233
|
+
*/
|
|
234
|
+
chromaSubsampling?: boolean;
|
|
235
|
+
}
|
|
200
236
|
/**
|
|
201
237
|
* Options for the SVG outputs ({@link convertMetafileToSvg} and friends).
|
|
202
238
|
* `maxWidth`/`maxHeight`/`dpiScale`/`maxCanvasDimension` set the SVG's
|
|
@@ -278,6 +314,21 @@ interface SvgConvertOptions extends EmfConvertOptions {
|
|
|
278
314
|
* @returns A `data:image/png;base64,...` string, or `null` on failure.
|
|
279
315
|
*/
|
|
280
316
|
declare function convertMetafileToDataUrl(buffer: ArrayBuffer, options?: EmfConvertOptions, recursionDepth?: number): Promise<string | null>;
|
|
317
|
+
/**
|
|
318
|
+
* Converts an EMF or WMF buffer (format auto-detected) to a JPEG data URL.
|
|
319
|
+
*
|
|
320
|
+
* The drawing is rendered exactly as for {@link convertMetafileToDataUrl}
|
|
321
|
+
* (same options, same backends, same `null` cases) and encoded by the
|
|
322
|
+
* bundled baseline JPEG encoder, so the bytes do not depend on the canvas
|
|
323
|
+
* backend. JPEG has no transparency: the metafile's transparent background
|
|
324
|
+
* and any translucent pixels are composited over
|
|
325
|
+
* {@link JpegConvertOptions.background} (white by default).
|
|
326
|
+
*
|
|
327
|
+
* @param buffer - The raw EMF or WMF file bytes.
|
|
328
|
+
* @param options - Optional {@link JpegConvertOptions}.
|
|
329
|
+
* @returns A `data:image/jpeg;base64,...` string, or `null` on failure.
|
|
330
|
+
*/
|
|
331
|
+
declare function convertMetafileToJpegDataUrl(buffer: ArrayBuffer, options?: JpegConvertOptions): Promise<string | null>;
|
|
281
332
|
|
|
282
333
|
/**
|
|
283
334
|
* Converts an EMF or WMF buffer (format auto-detected) into an SVG document
|
|
@@ -368,4 +419,4 @@ interface LoadSystemFontsOptions {
|
|
|
368
419
|
*/
|
|
369
420
|
declare function loadSystemFonts(options?: LoadSystemFontsOptions): Promise<Uint8Array[]>;
|
|
370
421
|
|
|
371
|
-
export { type CreateElement, DEFAULT_DPI_SCALE, type EmfConvertOptions, type LoadSystemFontsOptions, type SvgConvertOptions, type SvgJsxOptions, type SvgNode, convertMetafileToDataUrl, convertMetafileToSvg, convertMetafileToSvgDataUrl, convertMetafileToSvgTree, loadSystemFonts, svgTreeToDataUrl, svgTreeToJsx, svgTreeToReact, svgTreeToString };
|
|
422
|
+
export { type CreateElement, DEFAULT_DPI_SCALE, type EmfConvertOptions, type JpegConvertOptions, type LoadSystemFontsOptions, type SvgConvertOptions, type SvgJsxOptions, type SvgNode, convertMetafileToDataUrl, convertMetafileToJpegDataUrl, convertMetafileToSvg, convertMetafileToSvgDataUrl, convertMetafileToSvgTree, loadSystemFonts, svgTreeToDataUrl, svgTreeToJsx, svgTreeToReact, svgTreeToString };
|
package/dist/index.d.ts
CHANGED
|
@@ -114,11 +114,24 @@ interface EmfConvertOptions {
|
|
|
114
114
|
y: number;
|
|
115
115
|
};
|
|
116
116
|
/**
|
|
117
|
-
* ANSI code page of the
|
|
118
|
-
* charset text and
|
|
119
|
-
*
|
|
120
|
-
* 874, 932, 936, 949, 950, 1250..1258, 54936 and
|
|
121
|
-
* fall back to 1252. Explicit text charsets
|
|
117
|
+
* ANSI code page of the playback device (Windows `GetACP()`), used for
|
|
118
|
+
* ANSI/DEFAULT charset text in EMF and WMF ANSI text records and for WMF
|
|
119
|
+
* LOGFONT face names, as Windows decodes them. Defaults to 1252.
|
|
120
|
+
* Supported values: 874, 932, 936, 949, 950, 1250..1258, 54936 and
|
|
121
|
+
* 65001. Other values fall back to 1252. Explicit text charsets keep
|
|
122
|
+
* their own code page.
|
|
123
|
+
*/
|
|
124
|
+
ansiCodePage?: number;
|
|
125
|
+
/**
|
|
126
|
+
* OEM code page of the playback device (Windows `GetOEMCP()`), used for
|
|
127
|
+
* OEM_CHARSET text in EMF and WMF ANSI text records. Defaults to 437.
|
|
128
|
+
* Supported values: 437, 737, 775, 850, 852, 855, 858, 860, 861, 862,
|
|
129
|
+
* 863, 865, 866, 874, 932, 936, 949 and 950. Other values fall back to 437.
|
|
130
|
+
*/
|
|
131
|
+
oemCodePage?: number;
|
|
132
|
+
/**
|
|
133
|
+
* ANSI code page of the WMF playback device only; overrides
|
|
134
|
+
* {@link ansiCodePage} for WMF input. Same values as `ansiCodePage`.
|
|
122
135
|
*/
|
|
123
136
|
wmfAnsiCodePage?: number;
|
|
124
137
|
/** Maximum output width in pixels. */
|
|
@@ -197,6 +210,29 @@ interface EmfConvertOptions {
|
|
|
197
210
|
*/
|
|
198
211
|
fontSmoothing?: 'cleartype' | 'gray' | 'mono';
|
|
199
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Options for {@link convertMetafileToJpegDataUrl}: every
|
|
215
|
+
* {@link EmfConvertOptions} field plus the JPEG encoding settings.
|
|
216
|
+
*/
|
|
217
|
+
interface JpegConvertOptions extends EmfConvertOptions {
|
|
218
|
+
/**
|
|
219
|
+
* JPEG quality from 0 to 1, as for `canvas.toDataURL('image/jpeg', quality)`.
|
|
220
|
+
* Default 0.92.
|
|
221
|
+
*/
|
|
222
|
+
quality?: number;
|
|
223
|
+
/**
|
|
224
|
+
* Colour the transparent background and translucent pixels are
|
|
225
|
+
* composited over, as `#rgb` or `#rrggbb` (JPEG has no alpha channel).
|
|
226
|
+
* Default `'#ffffff'`.
|
|
227
|
+
*/
|
|
228
|
+
background?: string;
|
|
229
|
+
/**
|
|
230
|
+
* `true` averages colour over 2 x 2 pixels (4:2:0) for a smaller file.
|
|
231
|
+
* Default `false`: full-resolution colour (4:4:4), which keeps coloured
|
|
232
|
+
* lines and text free of colour fringes.
|
|
233
|
+
*/
|
|
234
|
+
chromaSubsampling?: boolean;
|
|
235
|
+
}
|
|
200
236
|
/**
|
|
201
237
|
* Options for the SVG outputs ({@link convertMetafileToSvg} and friends).
|
|
202
238
|
* `maxWidth`/`maxHeight`/`dpiScale`/`maxCanvasDimension` set the SVG's
|
|
@@ -278,6 +314,21 @@ interface SvgConvertOptions extends EmfConvertOptions {
|
|
|
278
314
|
* @returns A `data:image/png;base64,...` string, or `null` on failure.
|
|
279
315
|
*/
|
|
280
316
|
declare function convertMetafileToDataUrl(buffer: ArrayBuffer, options?: EmfConvertOptions, recursionDepth?: number): Promise<string | null>;
|
|
317
|
+
/**
|
|
318
|
+
* Converts an EMF or WMF buffer (format auto-detected) to a JPEG data URL.
|
|
319
|
+
*
|
|
320
|
+
* The drawing is rendered exactly as for {@link convertMetafileToDataUrl}
|
|
321
|
+
* (same options, same backends, same `null` cases) and encoded by the
|
|
322
|
+
* bundled baseline JPEG encoder, so the bytes do not depend on the canvas
|
|
323
|
+
* backend. JPEG has no transparency: the metafile's transparent background
|
|
324
|
+
* and any translucent pixels are composited over
|
|
325
|
+
* {@link JpegConvertOptions.background} (white by default).
|
|
326
|
+
*
|
|
327
|
+
* @param buffer - The raw EMF or WMF file bytes.
|
|
328
|
+
* @param options - Optional {@link JpegConvertOptions}.
|
|
329
|
+
* @returns A `data:image/jpeg;base64,...` string, or `null` on failure.
|
|
330
|
+
*/
|
|
331
|
+
declare function convertMetafileToJpegDataUrl(buffer: ArrayBuffer, options?: JpegConvertOptions): Promise<string | null>;
|
|
281
332
|
|
|
282
333
|
/**
|
|
283
334
|
* Converts an EMF or WMF buffer (format auto-detected) into an SVG document
|
|
@@ -368,4 +419,4 @@ interface LoadSystemFontsOptions {
|
|
|
368
419
|
*/
|
|
369
420
|
declare function loadSystemFonts(options?: LoadSystemFontsOptions): Promise<Uint8Array[]>;
|
|
370
421
|
|
|
371
|
-
export { type CreateElement, DEFAULT_DPI_SCALE, type EmfConvertOptions, type LoadSystemFontsOptions, type SvgConvertOptions, type SvgJsxOptions, type SvgNode, convertMetafileToDataUrl, convertMetafileToSvg, convertMetafileToSvgDataUrl, convertMetafileToSvgTree, loadSystemFonts, svgTreeToDataUrl, svgTreeToJsx, svgTreeToReact, svgTreeToString };
|
|
422
|
+
export { type CreateElement, DEFAULT_DPI_SCALE, type EmfConvertOptions, type JpegConvertOptions, type LoadSystemFontsOptions, type SvgConvertOptions, type SvgJsxOptions, type SvgNode, convertMetafileToDataUrl, convertMetafileToJpegDataUrl, convertMetafileToSvg, convertMetafileToSvgDataUrl, convertMetafileToSvgTree, loadSystemFonts, svgTreeToDataUrl, svgTreeToJsx, svgTreeToReact, svgTreeToString };
|