@cecee/document-flip-book 1.0.16 → 1.0.18
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/LICENSE +15 -0
- package/README.md +83 -0
- package/dist/cjs/AccountingBook/index.d.ts +3 -0
- package/dist/cjs/AccountingBook/index.js +19 -0
- package/dist/cjs/{ArchiveCover.js → DocumentFlipBook/ArchiveCover.js} +23 -3
- package/dist/cjs/{ExportModal.js → DocumentFlipBook/ExportModal.js} +1 -1
- package/dist/cjs/{ProjectCover.js → DocumentFlipBook/ProjectCover.js} +24 -4
- package/dist/cjs/{exportHtml.d.ts → DocumentFlipBook/exportHtml.d.ts} +3 -3
- package/dist/cjs/{exportHtml.js → DocumentFlipBook/exportHtml.js} +104 -48
- package/dist/cjs/{exportPdf.d.ts → DocumentFlipBook/exportPdf.d.ts} +2 -0
- package/dist/cjs/{exportPdf.js → DocumentFlipBook/exportPdf.js} +17 -6
- package/dist/cjs/{globalCache.d.ts → DocumentFlipBook/globalCache.d.ts} +2 -1
- package/dist/cjs/DocumentFlipBook/images/Clip_1.svg +97 -0
- package/dist/cjs/DocumentFlipBook/images/Clip_2.svg +1114 -0
- package/dist/cjs/DocumentFlipBook/images/Inside.svg +10 -0
- package/dist/cjs/DocumentFlipBook/images/book.svg +1 -0
- package/dist/cjs/DocumentFlipBook/images/coverSpine.svg +4 -0
- package/dist/{esm/DocumentFlipBook.d.ts → cjs/DocumentFlipBook/index.d.ts} +2 -0
- package/dist/cjs/{DocumentFlipBook.js → DocumentFlipBook/index.js} +116 -22
- package/dist/cjs/DocumentFlipBook/index.less +797 -0
- package/dist/cjs/{printPdf.d.ts → DocumentFlipBook/printPdf.d.ts} +1 -0
- package/dist/cjs/{utils.d.ts → DocumentFlipBook/utils.d.ts} +2 -1
- package/dist/cjs/{utils.js → DocumentFlipBook/utils.js} +4 -1
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +10 -3
- package/dist/esm/AccountingBook/index.d.ts +3 -0
- package/dist/esm/AccountingBook/index.js +13 -0
- package/dist/esm/{ArchiveCover.js → DocumentFlipBook/ArchiveCover.js} +23 -3
- package/dist/esm/{ExportModal.js → DocumentFlipBook/ExportModal.js} +1 -1
- package/dist/esm/{ProjectCover.js → DocumentFlipBook/ProjectCover.js} +24 -4
- package/dist/esm/{exportHtml.d.ts → DocumentFlipBook/exportHtml.d.ts} +3 -3
- package/dist/esm/{exportHtml.js → DocumentFlipBook/exportHtml.js} +103 -47
- package/dist/esm/{exportPdf.d.ts → DocumentFlipBook/exportPdf.d.ts} +2 -0
- package/dist/esm/{exportPdf.js → DocumentFlipBook/exportPdf.js} +17 -6
- package/dist/esm/{globalCache.d.ts → DocumentFlipBook/globalCache.d.ts} +2 -1
- package/dist/esm/DocumentFlipBook/images/Clip_1.svg +97 -0
- package/dist/esm/DocumentFlipBook/images/Clip_2.svg +1114 -0
- package/dist/esm/DocumentFlipBook/images/Inside.svg +10 -0
- package/dist/esm/DocumentFlipBook/images/book.svg +1 -0
- package/dist/esm/DocumentFlipBook/images/coverSpine.svg +4 -0
- package/dist/{cjs/DocumentFlipBook.d.ts → esm/DocumentFlipBook/index.d.ts} +2 -0
- package/dist/esm/{DocumentFlipBook.js → DocumentFlipBook/index.js} +116 -22
- package/dist/esm/DocumentFlipBook/index.less +797 -0
- package/dist/esm/{printPdf.d.ts → DocumentFlipBook/printPdf.d.ts} +1 -0
- package/dist/esm/{utils.d.ts → DocumentFlipBook/utils.d.ts} +2 -1
- package/dist/esm/{utils.js → DocumentFlipBook/utils.js} +4 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +5 -3
- package/package.json +6 -1
- package/dist/cjs/index.less +0 -674
- package/dist/esm/index.less +0 -674
- /package/dist/cjs/{ArchiveCover.d.ts → DocumentFlipBook/ArchiveCover.d.ts} +0 -0
- /package/dist/cjs/{ExportModal.d.ts → DocumentFlipBook/ExportModal.d.ts} +0 -0
- /package/dist/cjs/{HeaderBar.d.ts → DocumentFlipBook/HeaderBar.d.ts} +0 -0
- /package/dist/cjs/{HeaderBar.js → DocumentFlipBook/HeaderBar.js} +0 -0
- /package/dist/cjs/{PdfPage.d.ts → DocumentFlipBook/PdfPage.d.ts} +0 -0
- /package/dist/cjs/{PdfPage.js → DocumentFlipBook/PdfPage.js} +0 -0
- /package/dist/cjs/{ProjectCover.d.ts → DocumentFlipBook/ProjectCover.d.ts} +0 -0
- /package/dist/cjs/{SideTabs.d.ts → DocumentFlipBook/SideTabs.d.ts} +0 -0
- /package/dist/cjs/{SideTabs.js → DocumentFlipBook/SideTabs.js} +0 -0
- /package/dist/cjs/{globalCache.js → DocumentFlipBook/globalCache.js} +0 -0
- /package/dist/cjs/{printPdf.js → DocumentFlipBook/printPdf.js} +0 -0
- /package/dist/cjs/{types.d.ts → DocumentFlipBook/types.d.ts} +0 -0
- /package/dist/cjs/{types.js → DocumentFlipBook/types.js} +0 -0
- /package/dist/esm/{ArchiveCover.d.ts → DocumentFlipBook/ArchiveCover.d.ts} +0 -0
- /package/dist/esm/{ExportModal.d.ts → DocumentFlipBook/ExportModal.d.ts} +0 -0
- /package/dist/esm/{HeaderBar.d.ts → DocumentFlipBook/HeaderBar.d.ts} +0 -0
- /package/dist/esm/{HeaderBar.js → DocumentFlipBook/HeaderBar.js} +0 -0
- /package/dist/esm/{PdfPage.d.ts → DocumentFlipBook/PdfPage.d.ts} +0 -0
- /package/dist/esm/{PdfPage.js → DocumentFlipBook/PdfPage.js} +0 -0
- /package/dist/esm/{ProjectCover.d.ts → DocumentFlipBook/ProjectCover.d.ts} +0 -0
- /package/dist/esm/{SideTabs.d.ts → DocumentFlipBook/SideTabs.d.ts} +0 -0
- /package/dist/esm/{SideTabs.js → DocumentFlipBook/SideTabs.js} +0 -0
- /package/dist/esm/{globalCache.js → DocumentFlipBook/globalCache.js} +0 -0
- /package/dist/esm/{printPdf.js → DocumentFlipBook/printPdf.js} +0 -0
- /package/dist/esm/{types.d.ts → DocumentFlipBook/types.d.ts} +0 -0
- /package/dist/esm/{types.js → DocumentFlipBook/types.js} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, @cecee
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @cecee/document-flip-book
|
|
2
|
+
|
|
3
|
+
A high-performance document flipbook component based on React and Ant Design.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 📖 **Smooth Flip Animation**: Realistic book flipping effect using `react-pageflip`.
|
|
8
|
+
- 📄 **PDF Support**: Integrated PDF rendering with `react-pdf`.
|
|
9
|
+
- 🖼️ **Image Support**: Support for image-based pages.
|
|
10
|
+
- 🖨️ **Print & Export**: Support for printing and exporting to PDF/EPUB.
|
|
11
|
+
- 🎨 **Customizable**: Adjustable themes and covers.
|
|
12
|
+
- 📦 **Dual Output**: Supports both ESM and CJS formats.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @cecee/document-flip-book
|
|
18
|
+
# or
|
|
19
|
+
pnpm add @cecee/document-flip-book
|
|
20
|
+
# or
|
|
21
|
+
yarn add @cecee/document-flip-book
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Peer Dependencies
|
|
25
|
+
|
|
26
|
+
Make sure you have the following peer dependencies installed in your project:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install antd dayjs html2canvas jspdf lodash react react-dom react-pageflip react-pdf
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### DocumentFlipBook
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import React from 'react';
|
|
38
|
+
import { DocumentFlipBook } from '@cecee/document-flip-book';
|
|
39
|
+
|
|
40
|
+
const App = () => {
|
|
41
|
+
const documentInfo = {
|
|
42
|
+
fd: 'doc-id',
|
|
43
|
+
attachments: [
|
|
44
|
+
{ path: 'https://example.com/page1.pdf', acc17c_fd: '1' },
|
|
45
|
+
{ path: 'https://example.com/image1.jpg', acc17c_fd: '2' },
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div style={{ height: '800px' }}>
|
|
51
|
+
<DocumentFlipBook
|
|
52
|
+
documentInfo={documentInfo}
|
|
53
|
+
title="Sample Document"
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default App;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### PDF Worker Configuration
|
|
63
|
+
|
|
64
|
+
By default, the component looks for `pdf.worker.min.js` at the root of your application (`/pdf.worker.min.js`).
|
|
65
|
+
|
|
66
|
+
You can configure a custom worker source using the `pdfWorkerSrc` prop or by calling `setupPdfWorker`:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { setupPdfWorker } from '@cecee/document-flip-book';
|
|
70
|
+
|
|
71
|
+
// Using a CDN
|
|
72
|
+
setupPdfWorker('https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.4.168/pdf.worker.min.mjs');
|
|
73
|
+
|
|
74
|
+
// Or via prop
|
|
75
|
+
<DocumentFlipBook
|
|
76
|
+
pdfWorkerSrc="path/to/your/worker.js"
|
|
77
|
+
...
|
|
78
|
+
/>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
ISC
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var AccountingBook = function AccountingBook() {
|
|
11
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
12
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h1", {
|
|
13
|
+
children: "Accounting Book Component"
|
|
14
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
15
|
+
children: "This is a placeholder for the Accounting Book component."
|
|
16
|
+
})]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
var _default = exports.default = AccountingBook;
|
|
@@ -34,12 +34,32 @@ var ArchiveCover = function ArchiveCover(_ref) {
|
|
|
34
34
|
attachmentsCount: (archiveInfo === null || archiveInfo === void 0 || (_archiveInfo$com00cs = archiveInfo.com00cs) === null || _archiveInfo$com00cs === void 0 ? void 0 : _archiveInfo$com00cs.length) || 0,
|
|
35
35
|
nsp24cFd: (archiveInfo === null || archiveInfo === void 0 || (_archiveInfo$nsp24c = archiveInfo.nsp24c) === null || _archiveInfo$nsp24c === void 0 ? void 0 : _archiveInfo$nsp24c.fd) || '-'
|
|
36
36
|
};
|
|
37
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
37
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
38
38
|
className: "archive-cover",
|
|
39
39
|
style: {
|
|
40
40
|
backgroundColor: themeColor
|
|
41
41
|
},
|
|
42
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
42
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
43
|
+
className: "archive-spine",
|
|
44
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
|
|
45
|
+
width: "100%",
|
|
46
|
+
height: "100%",
|
|
47
|
+
viewBox: "0 0 17 825",
|
|
48
|
+
preserveAspectRatio: "none",
|
|
49
|
+
fill: "none",
|
|
50
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
51
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
52
|
+
d: "M0 30L17 0V825L0 789V30Z",
|
|
53
|
+
fill: themeColor,
|
|
54
|
+
style: {
|
|
55
|
+
filter: 'brightness(0.9)'
|
|
56
|
+
}
|
|
57
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
58
|
+
d: "M4 43.8636L13 29.5V802L4 782.364L4 43.8636Z",
|
|
59
|
+
fill: "rgba(255,255,255,0.3)"
|
|
60
|
+
})]
|
|
61
|
+
})
|
|
62
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
43
63
|
className: "archive-cover__outer-border",
|
|
44
64
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
45
65
|
className: "archive-cover__inner",
|
|
@@ -136,7 +156,7 @@ var ArchiveCover = function ArchiveCover(_ref) {
|
|
|
136
156
|
})
|
|
137
157
|
})]
|
|
138
158
|
})
|
|
139
|
-
})
|
|
159
|
+
})]
|
|
140
160
|
});
|
|
141
161
|
};
|
|
142
162
|
var _default = exports.default = /*#__PURE__*/_react.default.memo(ArchiveCover);
|
|
@@ -91,19 +91,39 @@ var ProjectCover = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
91
91
|
})
|
|
92
92
|
});
|
|
93
93
|
};
|
|
94
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
94
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
95
95
|
className: "project-cover-container",
|
|
96
96
|
style: {
|
|
97
97
|
backgroundColor: themeColor
|
|
98
98
|
},
|
|
99
99
|
ref: ref,
|
|
100
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
100
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
101
|
+
className: "archive-spine",
|
|
102
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
|
|
103
|
+
width: "100%",
|
|
104
|
+
height: "100%",
|
|
105
|
+
viewBox: "0 0 17 825",
|
|
106
|
+
preserveAspectRatio: "none",
|
|
107
|
+
fill: "none",
|
|
108
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
109
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
110
|
+
d: "M0 30L17 0V825L0 789V30Z",
|
|
111
|
+
fill: themeColor,
|
|
112
|
+
style: {
|
|
113
|
+
filter: 'brightness(0.9)'
|
|
114
|
+
}
|
|
115
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
116
|
+
d: "M4 43.8636L13 29.5V802L4 782.364L4 43.8636Z",
|
|
117
|
+
fill: "rgba(255,255,255,0.3)"
|
|
118
|
+
})]
|
|
119
|
+
})
|
|
120
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
101
121
|
className: "project-cover-border-outer",
|
|
102
122
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
103
123
|
className: "project-cover-border-inner",
|
|
104
124
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
105
125
|
className: "project-cover-header",
|
|
106
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("
|
|
126
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
107
127
|
className: "project-cover-title",
|
|
108
128
|
children: title
|
|
109
129
|
})
|
|
@@ -202,7 +222,7 @@ var ProjectCover = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
202
222
|
})]
|
|
203
223
|
})]
|
|
204
224
|
})
|
|
205
|
-
})
|
|
225
|
+
})]
|
|
206
226
|
});
|
|
207
227
|
});
|
|
208
228
|
var _default = exports.default = /*#__PURE__*/_react.default.memo(ProjectCover);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuiltPage, PdfDocumentLike } from './types';
|
|
2
|
-
interface
|
|
2
|
+
interface ExportEpubOptions {
|
|
3
3
|
pages: BuiltPage[];
|
|
4
4
|
filename: string;
|
|
5
5
|
title?: string;
|
|
@@ -13,7 +13,7 @@ interface ExportHtmlOptions {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* 导出
|
|
16
|
+
* 导出 EPUB 电子书功能
|
|
17
17
|
*/
|
|
18
|
-
export declare const
|
|
18
|
+
export declare const exportArchivePagesToEpub: (options: ExportEpubOptions) => Promise<void>;
|
|
19
19
|
export {};
|
|
@@ -4,9 +4,10 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.exportArchivePagesToEpub = void 0;
|
|
8
8
|
var _antd = require("antd");
|
|
9
9
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
10
|
+
var _jszip = _interopRequireDefault(require("jszip"));
|
|
10
11
|
var _exportPdf = require("./exportPdf");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
@@ -14,6 +15,19 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
14
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
16
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
16
17
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
18
|
+
/**
|
|
19
|
+
* 将 Data URL 转换为 ArrayBuffer
|
|
20
|
+
*/
|
|
21
|
+
var dataUrlToArrayBuffer = function dataUrlToArrayBuffer(dataUrl) {
|
|
22
|
+
var base64 = dataUrl.split(',')[1];
|
|
23
|
+
var binary = window.atob(base64);
|
|
24
|
+
var bytes = new Uint8Array(binary.length);
|
|
25
|
+
for (var i = 0; i < binary.length; i++) {
|
|
26
|
+
bytes[i] = binary.charCodeAt(i);
|
|
27
|
+
}
|
|
28
|
+
return bytes.buffer;
|
|
29
|
+
};
|
|
30
|
+
|
|
17
31
|
/**
|
|
18
32
|
* 渲染封面为图片
|
|
19
33
|
*/
|
|
@@ -131,99 +145,141 @@ var renderCoverToImage = /*#__PURE__*/function () {
|
|
|
131
145
|
}();
|
|
132
146
|
|
|
133
147
|
/**
|
|
134
|
-
* 导出
|
|
148
|
+
* 导出 EPUB 电子书功能
|
|
135
149
|
*/
|
|
136
|
-
var
|
|
150
|
+
var exportArchivePagesToEpub = exports.exportArchivePagesToEpub = /*#__PURE__*/function () {
|
|
137
151
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
138
|
-
var pages, filename, _options$title, title, getDocument, coverInfo, hide,
|
|
152
|
+
var pages, filename, _options$title, title, getDocument, coverInfo, hide, _zip$folder, _zip$folder2, _zip$folder3, _zip$folder4, _zip$folder7, _zip$folder8, zip, coverDataUrl, manifestItems, spineItems, navPoints, i, page, pageNum, imgDataUrl, img, _img, _zip$folder5, _zip$folder6, imgFileName, xhtmlFileName, pageId, content, url, link, finalFilename;
|
|
139
153
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
140
154
|
while (1) switch (_context2.prev = _context2.next) {
|
|
141
155
|
case 0:
|
|
142
|
-
pages = options.pages, filename = options.filename, _options$title = options.title, title = _options$title === void 0 ? '
|
|
143
|
-
hide = _antd.message.loading('正在导出
|
|
156
|
+
pages = options.pages, filename = options.filename, _options$title = options.title, title = _options$title === void 0 ? '电子档案书' : _options$title, getDocument = options.getDocument, coverInfo = options.coverInfo;
|
|
157
|
+
hide = _antd.message.loading('正在导出 EPUB 电子书,请稍候…', 0);
|
|
144
158
|
_context2.prev = 2;
|
|
145
|
-
|
|
159
|
+
zip = new _jszip.default(); // 1. mimetype (必须是第一个文件且不压缩)
|
|
160
|
+
zip.file('mimetype', 'application/epub+zip', {
|
|
161
|
+
compression: 'STORE'
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// 2. META-INF/container.xml
|
|
165
|
+
(_zip$folder = zip.folder('META-INF')) === null || _zip$folder === void 0 || _zip$folder.file('container.xml', "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<container version=\"1.0\" xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\">\n <rootfiles>\n <rootfile full-path=\"OEBPS/content.opf\" media-type=\"application/oebps-package+xml\"/>\n </rootfiles>\n</container>");
|
|
166
|
+
|
|
167
|
+
// 3. 准备资源
|
|
168
|
+
_context2.next = 8;
|
|
146
169
|
return renderCoverToImage(coverInfo);
|
|
147
|
-
case 5:
|
|
148
|
-
coverImg = _context2.sent;
|
|
149
|
-
pagesData = [coverImg];
|
|
150
|
-
i = 0;
|
|
151
170
|
case 8:
|
|
171
|
+
coverDataUrl = _context2.sent;
|
|
172
|
+
(_zip$folder2 = zip.folder('OEBPS')) === null || _zip$folder2 === void 0 || (_zip$folder2 = _zip$folder2.folder('Images')) === null || _zip$folder2 === void 0 || _zip$folder2.file('cover.jpg', dataUrlToArrayBuffer(coverDataUrl));
|
|
173
|
+
manifestItems = ['<item id="cover" href="Text/cover.xhtml" media-type="application/xhtml+xml"/>', '<item id="cover-image" href="Images/cover.jpg" media-type="image/jpeg" properties="cover-image"/>', '<item id="style" href="Styles/style.css" media-type="text/css"/>', '<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>'];
|
|
174
|
+
spineItems = ['<itemref idref="cover"/>'];
|
|
175
|
+
navPoints = ["<navPoint id=\"navPoint-1\" playOrder=\"1\"><navLabel><text>\u5C01\u9762</text></navLabel><content src=\"Text/cover.xhtml\"/></navPoint>"]; // 封面 XHTML
|
|
176
|
+
(_zip$folder3 = zip.folder('OEBPS')) === null || _zip$folder3 === void 0 || (_zip$folder3 = _zip$folder3.folder('Text')) === null || _zip$folder3 === void 0 || _zip$folder3.file('cover.xhtml', "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <title>Cover</title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"../Styles/style.css\"/>\n</head>\n<body style=\"margin:0;padding:0;text-align:center;\">\n <div style=\"width:100%;height:100%;\"><img src=\"../Images/cover.jpg\" style=\"max-width:100%;max-height:100%;\"/></div>\n</body>\n</html>");
|
|
177
|
+
|
|
178
|
+
// 样式表
|
|
179
|
+
(_zip$folder4 = zip.folder('OEBPS')) === null || _zip$folder4 === void 0 || (_zip$folder4 = _zip$folder4.folder('Styles')) === null || _zip$folder4 === void 0 || _zip$folder4.file('style.css', "\nbody { margin: 0; padding: 0; background: #fff; }\nimg { max-width: 100%; height: auto; }\n.page-container { text-align: center; page-break-after: always; }\n");
|
|
180
|
+
|
|
181
|
+
// 处理每一页
|
|
182
|
+
i = 0;
|
|
183
|
+
case 16:
|
|
152
184
|
if (!(i < pages.length)) {
|
|
153
|
-
_context2.next =
|
|
185
|
+
_context2.next = 42;
|
|
154
186
|
break;
|
|
155
187
|
}
|
|
156
188
|
page = pages[i];
|
|
157
|
-
|
|
189
|
+
pageNum = i + 1;
|
|
190
|
+
_context2.prev = 19;
|
|
191
|
+
imgDataUrl = '';
|
|
158
192
|
if (!(page.type === 'image')) {
|
|
159
|
-
_context2.next =
|
|
193
|
+
_context2.next = 28;
|
|
160
194
|
break;
|
|
161
195
|
}
|
|
162
|
-
_context2.next =
|
|
196
|
+
_context2.next = 24;
|
|
163
197
|
return (0, _exportPdf.renderImageToDataUrl)(page.file);
|
|
164
|
-
case
|
|
198
|
+
case 24:
|
|
165
199
|
img = _context2.sent;
|
|
166
|
-
|
|
167
|
-
_context2.next =
|
|
200
|
+
imgDataUrl = img.dataUrl;
|
|
201
|
+
_context2.next = 33;
|
|
168
202
|
break;
|
|
169
|
-
case
|
|
203
|
+
case 28:
|
|
170
204
|
if (!(page.type === 'pdf')) {
|
|
171
|
-
_context2.next =
|
|
205
|
+
_context2.next = 33;
|
|
172
206
|
break;
|
|
173
207
|
}
|
|
174
|
-
_context2.next =
|
|
208
|
+
_context2.next = 31;
|
|
175
209
|
return (0, _exportPdf.renderPdfPageToDataUrl)({
|
|
176
210
|
getDocument: getDocument,
|
|
177
211
|
file: page.file,
|
|
178
212
|
pageNum: page.pageNum,
|
|
179
213
|
scale: 2
|
|
180
214
|
});
|
|
181
|
-
case
|
|
215
|
+
case 31:
|
|
182
216
|
_img = _context2.sent;
|
|
183
|
-
|
|
184
|
-
case
|
|
185
|
-
|
|
217
|
+
imgDataUrl = _img.dataUrl;
|
|
218
|
+
case 33:
|
|
219
|
+
if (imgDataUrl) {
|
|
220
|
+
imgFileName = "page".concat(pageNum, ".jpg");
|
|
221
|
+
xhtmlFileName = "page".concat(pageNum, ".xhtml");
|
|
222
|
+
pageId = "page".concat(pageNum);
|
|
223
|
+
(_zip$folder5 = zip.folder('OEBPS')) === null || _zip$folder5 === void 0 || (_zip$folder5 = _zip$folder5.folder('Images')) === null || _zip$folder5 === void 0 || _zip$folder5.file(imgFileName, dataUrlToArrayBuffer(imgDataUrl));
|
|
224
|
+
(_zip$folder6 = zip.folder('OEBPS')) === null || _zip$folder6 === void 0 || (_zip$folder6 = _zip$folder6.folder('Text')) === null || _zip$folder6 === void 0 || _zip$folder6.file(xhtmlFileName, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <title>Page ".concat(pageNum, "</title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"../Styles/style.css\"/>\n</head>\n<body style=\"margin:0;padding:0;text-align:center;\">\n <div class=\"page-container\"><img src=\"../Images/").concat(imgFileName, "\"/></div>\n</body>\n</html>"));
|
|
225
|
+
manifestItems.push("<item id=\"".concat(pageId, "\" href=\"Text/").concat(xhtmlFileName, "\" media-type=\"application/xhtml+xml\"/>"));
|
|
226
|
+
manifestItems.push("<item id=\"".concat(pageId, "-img\" href=\"Images/").concat(imgFileName, "\" media-type=\"image/jpeg\"/>"));
|
|
227
|
+
spineItems.push("<itemref idref=\"".concat(pageId, "\"/>"));
|
|
228
|
+
navPoints.push("<navPoint id=\"navPoint-".concat(pageNum + 1, "\" playOrder=\"").concat(pageNum + 1, "\"><navLabel><text>\u7B2C ").concat(pageNum, " \u9875</text></navLabel><content src=\"Text/").concat(xhtmlFileName, "\"/></navPoint>"));
|
|
229
|
+
}
|
|
230
|
+
_context2.next = 39;
|
|
186
231
|
break;
|
|
187
|
-
case
|
|
188
|
-
_context2.prev =
|
|
189
|
-
_context2.t0 = _context2["catch"](
|
|
232
|
+
case 36:
|
|
233
|
+
_context2.prev = 36;
|
|
234
|
+
_context2.t0 = _context2["catch"](19);
|
|
190
235
|
console.error("\u6E32\u67D3\u7B2C ".concat(i + 1, " \u9875\u5931\u8D25:"), _context2.t0);
|
|
191
|
-
case
|
|
236
|
+
case 39:
|
|
192
237
|
i++;
|
|
193
|
-
_context2.next =
|
|
238
|
+
_context2.next = 16;
|
|
194
239
|
break;
|
|
195
|
-
case
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
240
|
+
case 42:
|
|
241
|
+
// 4. content.opf
|
|
242
|
+
(_zip$folder7 = zip.folder('OEBPS')) === null || _zip$folder7 === void 0 || _zip$folder7.file('content.opf', "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<package xmlns=\"http://www.idpf.org/2007/opf\" unique-identifier=\"pub-id\" version=\"3.0\">\n <metadata xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n <dc:identifier id=\"pub-id\">urn:uuid:".concat(crypto.randomUUID(), "</dc:identifier>\n <dc:title>").concat(title, "</dc:title>\n <dc:language>zh-CN</dc:language>\n <dc:creator>Archive System</dc:creator>\n <dc:date>").concat(new Date().toISOString(), "</dc:date>\n <meta property=\"dcterms:modified\">").concat(new Date().toISOString().split('.')[0], "Z</meta>\n </metadata>\n <manifest>\n ").concat(manifestItems.join('\n '), "\n </manifest>\n <spine toc=\"ncx\">\n ").concat(spineItems.join('\n '), "\n </spine>\n</package>"));
|
|
243
|
+
|
|
244
|
+
// 5. toc.ncx
|
|
245
|
+
(_zip$folder8 = zip.folder('OEBPS')) === null || _zip$folder8 === void 0 || _zip$folder8.file('toc.ncx', "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ncx xmlns=\"http://www.daisy.org/z3986/2005/ncx/\" version=\"2005-1\">\n <head>\n <meta name=\"dtb:uid\" content=\"urn:uuid:12345\"/>\n <meta name=\"dtb:depth\" content=\"1\"/>\n <meta name=\"dtb:totalPageCount\" content=\"0\"/>\n <meta name=\"dtb:maxPageNumber\" content=\"0\"/>\n </head>\n <docTitle><text>".concat(title, "</text></docTitle>\n <navMap>\n ").concat(navPoints.join('\n '), "\n </navMap>\n</ncx>"));
|
|
246
|
+
|
|
247
|
+
// 生成并下载
|
|
248
|
+
_context2.next = 46;
|
|
249
|
+
return zip.generateAsync({
|
|
250
|
+
type: 'blob',
|
|
251
|
+
mimeType: 'application/epub+zip'
|
|
199
252
|
});
|
|
200
|
-
|
|
253
|
+
case 46:
|
|
254
|
+
content = _context2.sent;
|
|
255
|
+
url = URL.createObjectURL(content);
|
|
201
256
|
link = document.createElement('a');
|
|
202
257
|
link.href = url;
|
|
203
|
-
|
|
258
|
+
finalFilename = "".concat(title, ".epub");
|
|
259
|
+
link.download = finalFilename;
|
|
204
260
|
document.body.appendChild(link);
|
|
205
261
|
link.click();
|
|
206
262
|
document.body.removeChild(link);
|
|
207
263
|
URL.revokeObjectURL(url);
|
|
208
|
-
_antd.message.success('
|
|
209
|
-
_context2.next =
|
|
264
|
+
_antd.message.success('EPUB 电子书导出成功');
|
|
265
|
+
_context2.next = 63;
|
|
210
266
|
break;
|
|
211
|
-
case
|
|
212
|
-
_context2.prev =
|
|
267
|
+
case 59:
|
|
268
|
+
_context2.prev = 59;
|
|
213
269
|
_context2.t1 = _context2["catch"](2);
|
|
214
|
-
console.error('
|
|
215
|
-
_antd.message.error('
|
|
216
|
-
case
|
|
217
|
-
_context2.prev =
|
|
270
|
+
console.error('EPUB 导出失败:', _context2.t1);
|
|
271
|
+
_antd.message.error('EPUB 导出失败');
|
|
272
|
+
case 63:
|
|
273
|
+
_context2.prev = 63;
|
|
218
274
|
hide();
|
|
219
|
-
return _context2.finish(
|
|
220
|
-
case
|
|
275
|
+
return _context2.finish(63);
|
|
276
|
+
case 66:
|
|
221
277
|
case "end":
|
|
222
278
|
return _context2.stop();
|
|
223
279
|
}
|
|
224
|
-
}, _callee2, null, [[2,
|
|
280
|
+
}, _callee2, null, [[2, 59, 63, 66], [19, 36]]);
|
|
225
281
|
}));
|
|
226
|
-
return function
|
|
282
|
+
return function exportArchivePagesToEpub(_x2) {
|
|
227
283
|
return _ref2.apply(this, arguments);
|
|
228
284
|
};
|
|
229
285
|
}();
|
|
@@ -18,10 +18,12 @@ export declare function buildArchivePdfBlob(params: {
|
|
|
18
18
|
pages: BuiltPage[];
|
|
19
19
|
getDocument: (path: string) => Promise<PdfDocumentLike>;
|
|
20
20
|
scale?: number;
|
|
21
|
+
printType?: 'A4' | 'A5';
|
|
21
22
|
}): Promise<Blob>;
|
|
22
23
|
export declare function exportArchivePagesToPdf(params: {
|
|
23
24
|
pages: BuiltPage[];
|
|
24
25
|
getDocument: (path: string) => Promise<PdfDocumentLike>;
|
|
25
26
|
filename: string;
|
|
26
27
|
scale?: number;
|
|
28
|
+
printType?: 'A4' | 'A5';
|
|
27
29
|
}): Promise<void>;
|
|
@@ -121,15 +121,26 @@ function buildArchivePdfBlob(_x3) {
|
|
|
121
121
|
}
|
|
122
122
|
function _buildArchivePdfBlob() {
|
|
123
123
|
_buildArchivePdfBlob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
124
|
-
var pages, getDocument, _params$scale, scale, pdf, first, _iterator, _step, p, img, pageW, pageH, _img, _pageW, _pageH;
|
|
124
|
+
var pages, getDocument, _params$scale, scale, _params$printType, printType, pdf, first, _iterator, _step, p, img, pageW, pageH, _img, _pageW, _pageH;
|
|
125
125
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
126
126
|
while (1) switch (_context3.prev = _context3.next) {
|
|
127
127
|
case 0:
|
|
128
|
-
pages = params.pages, getDocument = params.getDocument, _params$scale = params.scale, scale = _params$scale === void 0 ? 2 : _params$scale;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
pages = params.pages, getDocument = params.getDocument, _params$scale = params.scale, scale = _params$scale === void 0 ? 2 : _params$scale, _params$printType = params.printType, printType = _params$printType === void 0 ? 'A4' : _params$printType;
|
|
129
|
+
if (printType === 'A5') {
|
|
130
|
+
pdf = new _jspdf.jsPDF({
|
|
131
|
+
orientation: 'landscape',
|
|
132
|
+
unit: 'mm',
|
|
133
|
+
format: [210, 148],
|
|
134
|
+
// A5横向
|
|
135
|
+
compress: true
|
|
136
|
+
});
|
|
137
|
+
} else {
|
|
138
|
+
// 默认 A4
|
|
139
|
+
pdf = new _jspdf.jsPDF({
|
|
140
|
+
unit: 'pt',
|
|
141
|
+
compress: true
|
|
142
|
+
});
|
|
143
|
+
}
|
|
133
144
|
first = true;
|
|
134
145
|
_iterator = _createForOfIteratorHelper(pages);
|
|
135
146
|
_context3.prev = 4;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const globalPdfCache: {
|
|
2
|
-
getDocument(path: string): Promise<import("
|
|
2
|
+
getDocument(path: string): Promise<import("../index").PdfDocumentLike>;
|
|
3
3
|
getPageCount(path: string): Promise<number>;
|
|
4
4
|
clear(path: string): void;
|
|
5
|
+
clearAll(): void;
|
|
5
6
|
};
|