@univer-cli/unit-pdf-printer 1.0.0-rc.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 +13 -0
- package/README.zh-CN.md +14 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.mjs +1 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @univer-cli/unit-pdf-printer
|
|
2
|
+
|
|
3
|
+
English | [简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Prints a materialized Sheet, Doc, Slide, or Board Unit to PDF through the current browser Render Page. Base printing is not supported.
|
|
6
|
+
|
|
7
|
+
The capability returns PDF bytes and metadata; the host application owns Unit materialization, local paths, and file writes. Print layout and rendering come from the browser Render Page's native print operation rather than a separate PDF renderer.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const printer = createUnitPdfPrinter({ runtime });
|
|
11
|
+
const result = await printer.print({ unitType: "doc", unitData });
|
|
12
|
+
await writeFile("output.pdf", result.bytes);
|
|
13
|
+
```
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @univer-cli/unit-pdf-printer
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | 简体中文
|
|
4
|
+
|
|
5
|
+
通过当前 browser Render Page,把已经物化的 Sheet、Doc、Slide 或 Board Unit 打印为 PDF。暂不支持 Base 打印。
|
|
6
|
+
|
|
7
|
+
Capability 只返回 PDF bytes 与 metadata;Unit 物化、本地路径和文件写入由 host application 负责。打印布局与渲染
|
|
8
|
+
来自 browser Render Page 的原生 print operation,不使用另一套 PDF renderer。
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
const printer = createUnitPdfPrinter({ runtime });
|
|
12
|
+
const result = await printer.print({ unitType: "doc", unitData });
|
|
13
|
+
await writeFile("output.pdf", result.bytes);
|
|
14
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';module['exports']=require('./index.mjs');
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { UniverPrintPdfInput, UniverPrintPdfRuntime, UniverRenderUnit } from "@univer-cli/univer-render-runtime";
|
|
2
|
+
//#region src/errors.d.ts
|
|
3
|
+
type UnitPdfPrinterErrorCode = "INVALID_INPUT" | "UNSUPPORTED_UNIT_TYPE";
|
|
4
|
+
declare class UnitPdfPrinterError extends Error {
|
|
5
|
+
readonly code: UnitPdfPrinterErrorCode;
|
|
6
|
+
constructor(code: UnitPdfPrinterErrorCode, message: string);
|
|
7
|
+
}
|
|
8
|
+
declare function isUnitPdfPrinterError(error: unknown): error is UnitPdfPrinterError;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/types.d.ts
|
|
11
|
+
type UnitPdfPrintInput = UniverPrintPdfInput;
|
|
12
|
+
interface UnitPdfPrintResult {
|
|
13
|
+
readonly bytes: Uint8Array;
|
|
14
|
+
readonly mediaType: "application/pdf";
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly pageCount: number;
|
|
17
|
+
readonly unitId: string;
|
|
18
|
+
readonly unitType: Exclude<UniverRenderUnit["unitType"], "base">;
|
|
19
|
+
}
|
|
20
|
+
interface UnitPdfPrinterOptions {
|
|
21
|
+
readonly maxPages?: number;
|
|
22
|
+
readonly runtime: UniverPrintPdfRuntime;
|
|
23
|
+
}
|
|
24
|
+
interface UnitPdfPrinter {
|
|
25
|
+
print(input: UnitPdfPrintInput): Promise<UnitPdfPrintResult>;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/unit-pdf-printer.d.ts
|
|
29
|
+
declare function createUnitPdfPrinter(options: UnitPdfPrinterOptions): UnitPdfPrinter;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { type UnitPdfPrintInput, type UnitPdfPrintResult, type UnitPdfPrinter, UnitPdfPrinterError, type UnitPdfPrinterErrorCode, type UnitPdfPrinterOptions, createUnitPdfPrinter, isUnitPdfPrinterError };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(_0x4cfd4f,_0x53abf8){const _0x156099=_0x5abb,_0x483786=_0x4cfd4f();while(!![]){try{const _0x293098=parseInt(_0x156099(0x89))/0x1*(parseInt(_0x156099(0x9d))/0x2)+-parseInt(_0x156099(0x92))/0x3*(-parseInt(_0x156099(0xa2))/0x4)+parseInt(_0x156099(0x9a))/0x5*(parseInt(_0x156099(0x99))/0x6)+-parseInt(_0x156099(0x83))/0x7+-parseInt(_0x156099(0x9e))/0x8+parseInt(_0x156099(0x94))/0x9+parseInt(_0x156099(0x80))/0xa;if(_0x293098===_0x53abf8)break;else _0x483786['push'](_0x483786['shift']());}catch(_0x4265c){_0x483786['push'](_0x483786['shift']());}}}(_0x29f8,0xafc7f));var e=class extends Error{['code'];constructor(_0xfb0e99,_0x1619c5){const _0x399b51=_0x5abb;super(_0x1619c5),this[_0x399b51(0x81)]=_0x399b51(0x8a),this[_0x399b51(0xa1)]=_0xfb0e99;}};function t(_0x533c79){return _0x533c79 instanceof e;}function _0x29f8(){const _0x3a5b3d=['trim','pageCount','unitData.id\x20is\x20required','1ENCPLa','UnitPdfPrinterError','render\x20runtime\x20returned\x20invalid\x20PDF\x20bytes','operation\x20aborted','reason','bytes','signal','\x20page\x20limit','unitData','18SLuLmM','runtime','5130720QQmlhd','subarray','application/pdf','.pdf','length','12Fhoduz','2934065NonTGc','\x20pages,\x20over\x20the\x20','printPdf','1298706OZBvph','10387512XbBBMp','string','unit','code','199164OQAksy','INVALID_INPUT','6439900qtpbJt','name','replaceAll','9221499rKtmGS','print\x20produced\x20','fromCharCode'];_0x29f8=function(){return _0x3a5b3d;};return _0x29f8();}var n=0x3e8;function r(_0x5e1df0){let _0x1d8ec6=_0x5e1df0['maxPages']??n;if(!Number['isSafeInteger'](_0x1d8ec6)||_0x1d8ec6<0x1)throw new e('INVALID_INPUT','maxPages\x20must\x20be\x20a\x20positive\x20integer');return{async 'print'(_0x3bd2a1){const _0x2838ab=_0x5abb;c(_0x3bd2a1[_0x2838ab(0x8f)]);let _0x163049=i(_0x3bd2a1[_0x2838ab(0x91)]),_0x1017c8=await _0x5e1df0[_0x2838ab(0x93)][_0x2838ab(0x9c)](_0x3bd2a1);if(c(_0x3bd2a1[_0x2838ab(0x8f)]),_0x1017c8['pageCount']>_0x1d8ec6)throw new e('INVALID_INPUT',_0x2838ab(0x84)+_0x1017c8[_0x2838ab(0x87)]+_0x2838ab(0x9b)+_0x1d8ec6+_0x2838ab(0x90));if(!s(_0x1017c8[_0x2838ab(0x8e)]))throw new e('INVALID_INPUT',_0x2838ab(0x8b));return{'bytes':_0x1017c8[_0x2838ab(0x8e)],'mediaType':_0x2838ab(0x96),'name':o(a(_0x3bd2a1['unitData'])??_0x163049)+_0x2838ab(0x97),'pageCount':_0x1017c8[_0x2838ab(0x87)],'unitId':_0x163049,'unitType':_0x3bd2a1['unitType']};}};}function _0x5abb(_0xd218b1,_0x5a2a27){_0xd218b1=_0xd218b1-0x80;const _0x29f840=_0x29f8();let _0x5abba3=_0x29f840[_0xd218b1];return _0x5abba3;}function i(_0x437beb){const _0x24ef89=_0x5abb;if(typeof _0x437beb['id']!=_0x24ef89(0x9f)||_0x437beb['id'][_0x24ef89(0x98)]===0x0)throw new e(_0x24ef89(0xa3),_0x24ef89(0x88));return _0x437beb['id'];}function a(_0x2b57f4){const _0x59a6dd=_0x5abb;let _0x50dbd9=_0x2b57f4[_0x59a6dd(0x81)];return typeof _0x50dbd9==_0x59a6dd(0x9f)&&_0x50dbd9[_0x59a6dd(0x86)]()[_0x59a6dd(0x98)]>0x0?_0x50dbd9[_0x59a6dd(0x86)]():void 0x0;}function o(_0x291d71){const _0x16db53=_0x5abb;let _0x1a6e1e=_0x291d71[_0x16db53(0x82)](/[\\/:*?"<>|]/gu,'-')['trim']();return _0x1a6e1e[_0x16db53(0x98)]>0x0?_0x1a6e1e:_0x16db53(0xa0);}function s(_0x1d69d1){const _0x4a96e4=_0x5abb;return _0x1d69d1[_0x4a96e4(0x98)]>=0x5&&String[_0x4a96e4(0x85)](..._0x1d69d1[_0x4a96e4(0x95)](0x0,0x5))==='%PDF-';}function c(_0xd5afb5){const _0x488cdb=_0x5abb;if(_0xd5afb5?.['aborted']===!0x0)throw _0xd5afb5[_0x488cdb(0x8d)]instanceof Error?_0xd5afb5[_0x488cdb(0x8d)]:Error(_0x488cdb(0x8c));}export{e as UnitPdfPrinterError,r as createUnitPdfPrinter,t as isUnitPdfPrinterError};
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@univer-cli/unit-pdf-printer",
|
|
3
|
+
"description": "Print materialized Univer Units to PDF through the browser render runtime.",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "1.0.0-rc.0",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"README.zh-CN.md"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@univer-cli/univer-render-runtime": "1.0.0-rc.0"
|
|
23
|
+
}
|
|
24
|
+
}
|