@cecee/document-flip-book 1.0.17 → 1.0.19
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} +23 -3
- 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} +119 -25
- package/dist/cjs/{index.less → DocumentFlipBook/index.less} +194 -78
- 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} +23 -3
- 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} +119 -25
- package/dist/esm/{index.less → DocumentFlipBook/index.less} +194 -78
- 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/{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
|
@@ -4,7 +4,21 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
4
4
|
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); }); }; }
|
|
5
5
|
import { message } from 'antd';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
|
+
import JSZip from 'jszip';
|
|
7
8
|
import { renderPdfPageToDataUrl, renderImageToDataUrl } from "./exportPdf";
|
|
9
|
+
/**
|
|
10
|
+
* 将 Data URL 转换为 ArrayBuffer
|
|
11
|
+
*/
|
|
12
|
+
var dataUrlToArrayBuffer = function dataUrlToArrayBuffer(dataUrl) {
|
|
13
|
+
var base64 = dataUrl.split(',')[1];
|
|
14
|
+
var binary = window.atob(base64);
|
|
15
|
+
var bytes = new Uint8Array(binary.length);
|
|
16
|
+
for (var i = 0; i < binary.length; i++) {
|
|
17
|
+
bytes[i] = binary.charCodeAt(i);
|
|
18
|
+
}
|
|
19
|
+
return bytes.buffer;
|
|
20
|
+
};
|
|
21
|
+
|
|
8
22
|
/**
|
|
9
23
|
* 渲染封面为图片
|
|
10
24
|
*/
|
|
@@ -120,99 +134,141 @@ var renderCoverToImage = /*#__PURE__*/function () {
|
|
|
120
134
|
}();
|
|
121
135
|
|
|
122
136
|
/**
|
|
123
|
-
* 导出
|
|
137
|
+
* 导出 EPUB 电子书功能
|
|
124
138
|
*/
|
|
125
|
-
export var
|
|
139
|
+
export var exportArchivePagesToEpub = /*#__PURE__*/function () {
|
|
126
140
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
127
|
-
var pages, filename, _options$title, title, getDocument, coverInfo, hide,
|
|
141
|
+
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;
|
|
128
142
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
129
143
|
while (1) switch (_context2.prev = _context2.next) {
|
|
130
144
|
case 0:
|
|
131
|
-
pages = options.pages, filename = options.filename, _options$title = options.title, title = _options$title === void 0 ? '
|
|
132
|
-
hide = message.loading('正在导出
|
|
145
|
+
pages = options.pages, filename = options.filename, _options$title = options.title, title = _options$title === void 0 ? '电子档案书' : _options$title, getDocument = options.getDocument, coverInfo = options.coverInfo;
|
|
146
|
+
hide = message.loading('正在导出 EPUB 电子书,请稍候…', 0);
|
|
133
147
|
_context2.prev = 2;
|
|
134
|
-
|
|
148
|
+
zip = new JSZip(); // 1. mimetype (必须是第一个文件且不压缩)
|
|
149
|
+
zip.file('mimetype', 'application/epub+zip', {
|
|
150
|
+
compression: 'STORE'
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// 2. META-INF/container.xml
|
|
154
|
+
(_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>");
|
|
155
|
+
|
|
156
|
+
// 3. 准备资源
|
|
157
|
+
_context2.next = 8;
|
|
135
158
|
return renderCoverToImage(coverInfo);
|
|
136
|
-
case 5:
|
|
137
|
-
coverImg = _context2.sent;
|
|
138
|
-
pagesData = [coverImg];
|
|
139
|
-
i = 0;
|
|
140
159
|
case 8:
|
|
160
|
+
coverDataUrl = _context2.sent;
|
|
161
|
+
(_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));
|
|
162
|
+
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"/>'];
|
|
163
|
+
spineItems = ['<itemref idref="cover"/>'];
|
|
164
|
+
navPoints = ["<navPoint id=\"navPoint-1\" playOrder=\"1\"><navLabel><text>\u5C01\u9762</text></navLabel><content src=\"Text/cover.xhtml\"/></navPoint>"]; // 封面 XHTML
|
|
165
|
+
(_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>");
|
|
166
|
+
|
|
167
|
+
// 样式表
|
|
168
|
+
(_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");
|
|
169
|
+
|
|
170
|
+
// 处理每一页
|
|
171
|
+
i = 0;
|
|
172
|
+
case 16:
|
|
141
173
|
if (!(i < pages.length)) {
|
|
142
|
-
_context2.next =
|
|
174
|
+
_context2.next = 42;
|
|
143
175
|
break;
|
|
144
176
|
}
|
|
145
177
|
page = pages[i];
|
|
146
|
-
|
|
178
|
+
pageNum = i + 1;
|
|
179
|
+
_context2.prev = 19;
|
|
180
|
+
imgDataUrl = '';
|
|
147
181
|
if (!(page.type === 'image')) {
|
|
148
|
-
_context2.next =
|
|
182
|
+
_context2.next = 28;
|
|
149
183
|
break;
|
|
150
184
|
}
|
|
151
|
-
_context2.next =
|
|
185
|
+
_context2.next = 24;
|
|
152
186
|
return renderImageToDataUrl(page.file);
|
|
153
|
-
case
|
|
187
|
+
case 24:
|
|
154
188
|
img = _context2.sent;
|
|
155
|
-
|
|
156
|
-
_context2.next =
|
|
189
|
+
imgDataUrl = img.dataUrl;
|
|
190
|
+
_context2.next = 33;
|
|
157
191
|
break;
|
|
158
|
-
case
|
|
192
|
+
case 28:
|
|
159
193
|
if (!(page.type === 'pdf')) {
|
|
160
|
-
_context2.next =
|
|
194
|
+
_context2.next = 33;
|
|
161
195
|
break;
|
|
162
196
|
}
|
|
163
|
-
_context2.next =
|
|
197
|
+
_context2.next = 31;
|
|
164
198
|
return renderPdfPageToDataUrl({
|
|
165
199
|
getDocument: getDocument,
|
|
166
200
|
file: page.file,
|
|
167
201
|
pageNum: page.pageNum,
|
|
168
202
|
scale: 2
|
|
169
203
|
});
|
|
170
|
-
case
|
|
204
|
+
case 31:
|
|
171
205
|
_img = _context2.sent;
|
|
172
|
-
|
|
173
|
-
case
|
|
174
|
-
|
|
206
|
+
imgDataUrl = _img.dataUrl;
|
|
207
|
+
case 33:
|
|
208
|
+
if (imgDataUrl) {
|
|
209
|
+
imgFileName = "page".concat(pageNum, ".jpg");
|
|
210
|
+
xhtmlFileName = "page".concat(pageNum, ".xhtml");
|
|
211
|
+
pageId = "page".concat(pageNum);
|
|
212
|
+
(_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));
|
|
213
|
+
(_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>"));
|
|
214
|
+
manifestItems.push("<item id=\"".concat(pageId, "\" href=\"Text/").concat(xhtmlFileName, "\" media-type=\"application/xhtml+xml\"/>"));
|
|
215
|
+
manifestItems.push("<item id=\"".concat(pageId, "-img\" href=\"Images/").concat(imgFileName, "\" media-type=\"image/jpeg\"/>"));
|
|
216
|
+
spineItems.push("<itemref idref=\"".concat(pageId, "\"/>"));
|
|
217
|
+
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>"));
|
|
218
|
+
}
|
|
219
|
+
_context2.next = 39;
|
|
175
220
|
break;
|
|
176
|
-
case
|
|
177
|
-
_context2.prev =
|
|
178
|
-
_context2.t0 = _context2["catch"](
|
|
221
|
+
case 36:
|
|
222
|
+
_context2.prev = 36;
|
|
223
|
+
_context2.t0 = _context2["catch"](19);
|
|
179
224
|
console.error("\u6E32\u67D3\u7B2C ".concat(i + 1, " \u9875\u5931\u8D25:"), _context2.t0);
|
|
180
|
-
case
|
|
225
|
+
case 39:
|
|
181
226
|
i++;
|
|
182
|
-
_context2.next =
|
|
227
|
+
_context2.next = 16;
|
|
183
228
|
break;
|
|
184
|
-
case
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
229
|
+
case 42:
|
|
230
|
+
// 4. content.opf
|
|
231
|
+
(_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>"));
|
|
232
|
+
|
|
233
|
+
// 5. toc.ncx
|
|
234
|
+
(_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>"));
|
|
235
|
+
|
|
236
|
+
// 生成并下载
|
|
237
|
+
_context2.next = 46;
|
|
238
|
+
return zip.generateAsync({
|
|
239
|
+
type: 'blob',
|
|
240
|
+
mimeType: 'application/epub+zip'
|
|
188
241
|
});
|
|
189
|
-
|
|
242
|
+
case 46:
|
|
243
|
+
content = _context2.sent;
|
|
244
|
+
url = URL.createObjectURL(content);
|
|
190
245
|
link = document.createElement('a');
|
|
191
246
|
link.href = url;
|
|
192
|
-
|
|
247
|
+
finalFilename = "".concat(title, ".epub");
|
|
248
|
+
link.download = finalFilename;
|
|
193
249
|
document.body.appendChild(link);
|
|
194
250
|
link.click();
|
|
195
251
|
document.body.removeChild(link);
|
|
196
252
|
URL.revokeObjectURL(url);
|
|
197
|
-
message.success('
|
|
198
|
-
_context2.next =
|
|
253
|
+
message.success('EPUB 电子书导出成功');
|
|
254
|
+
_context2.next = 63;
|
|
199
255
|
break;
|
|
200
|
-
case
|
|
201
|
-
_context2.prev =
|
|
256
|
+
case 59:
|
|
257
|
+
_context2.prev = 59;
|
|
202
258
|
_context2.t1 = _context2["catch"](2);
|
|
203
|
-
console.error('
|
|
204
|
-
message.error('
|
|
205
|
-
case
|
|
206
|
-
_context2.prev =
|
|
259
|
+
console.error('EPUB 导出失败:', _context2.t1);
|
|
260
|
+
message.error('EPUB 导出失败');
|
|
261
|
+
case 63:
|
|
262
|
+
_context2.prev = 63;
|
|
207
263
|
hide();
|
|
208
|
-
return _context2.finish(
|
|
209
|
-
case
|
|
264
|
+
return _context2.finish(63);
|
|
265
|
+
case 66:
|
|
210
266
|
case "end":
|
|
211
267
|
return _context2.stop();
|
|
212
268
|
}
|
|
213
|
-
}, _callee2, null, [[2,
|
|
269
|
+
}, _callee2, null, [[2, 59, 63, 66], [19, 36]]);
|
|
214
270
|
}));
|
|
215
|
-
return function
|
|
271
|
+
return function exportArchivePagesToEpub(_x2) {
|
|
216
272
|
return _ref2.apply(this, arguments);
|
|
217
273
|
};
|
|
218
274
|
}();
|
|
@@ -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>;
|
|
@@ -112,15 +112,26 @@ export function buildArchivePdfBlob(_x3) {
|
|
|
112
112
|
}
|
|
113
113
|
function _buildArchivePdfBlob() {
|
|
114
114
|
_buildArchivePdfBlob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
115
|
-
var pages, getDocument, _params$scale, scale, pdf, first, _iterator, _step, p, img, pageW, pageH, _img, _pageW, _pageH;
|
|
115
|
+
var pages, getDocument, _params$scale, scale, _params$printType, printType, pdf, first, _iterator, _step, p, img, pageW, pageH, _img, _pageW, _pageH;
|
|
116
116
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
117
117
|
while (1) switch (_context3.prev = _context3.next) {
|
|
118
118
|
case 0:
|
|
119
|
-
pages = params.pages, getDocument = params.getDocument, _params$scale = params.scale, scale = _params$scale === void 0 ? 2 : _params$scale;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
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;
|
|
120
|
+
if (printType === 'A5') {
|
|
121
|
+
pdf = new jsPDF({
|
|
122
|
+
orientation: 'landscape',
|
|
123
|
+
unit: 'mm',
|
|
124
|
+
format: [210, 148],
|
|
125
|
+
// A5横向
|
|
126
|
+
compress: true
|
|
127
|
+
});
|
|
128
|
+
} else {
|
|
129
|
+
// 默认 A4
|
|
130
|
+
pdf = new jsPDF({
|
|
131
|
+
unit: 'pt',
|
|
132
|
+
compress: true
|
|
133
|
+
});
|
|
134
|
+
}
|
|
124
135
|
first = true;
|
|
125
136
|
_iterator = _createForOfIteratorHelper(pages);
|
|
126
137
|
_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
|
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<svg width="28" height="768" viewBox="0 0 28 768" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M4 0L28 4.43758V762.562L4 767V0Z" fill="url(#paint0_linear_28911_9466)"/>
|
|
3
|
+
<path d="M4 0L1.34311 3.93006C1.1195 4.26082 1 4.65094 1 5.05019V764.264C1 765.021 1.428 765.714 2.10557 766.053L4 767V0Z" fill="url(#paint1_linear_28911_9466)"/>
|
|
4
|
+
<g opacity="0.79" filter="url(#filter0_f_28911_9466)">
|
|
5
|
+
<rect x="11" y="6" width="4" height="755" rx="2" fill="black"/>
|
|
6
|
+
</g>
|
|
7
|
+
<g opacity="0.82" filter="url(#filter1_f_28911_9466)">
|
|
8
|
+
<rect x="12" y="7" width="2" height="753" rx="1" fill="white"/>
|
|
9
|
+
</g>
|
|
10
|
+
<g opacity="0.12" filter="url(#filter2_f_28911_9466)">
|
|
11
|
+
<rect x="15" y="7" width="8" height="753" rx="4" fill="white"/>
|
|
12
|
+
</g>
|
|
13
|
+
<g opacity="0.48" filter="url(#filter3_f_28911_9466)">
|
|
14
|
+
<rect x="19" y="8" width="1" height="752" rx="0.5" fill="white"/>
|
|
15
|
+
</g>
|
|
16
|
+
<g opacity="0.81" filter="url(#filter4_f_28911_9466)">
|
|
17
|
+
<rect x="6" y="4" width="4" height="760" rx="2" fill="white"/>
|
|
18
|
+
</g>
|
|
19
|
+
<g filter="url(#filter5_f_28911_9466)">
|
|
20
|
+
<rect x="5" y="5" width="2" height="757" rx="1" fill="white"/>
|
|
21
|
+
</g>
|
|
22
|
+
<g opacity="0.45" filter="url(#filter6_f_28911_9466)">
|
|
23
|
+
<rect x="4" y="552" width="6" height="210" rx="3" fill="white"/>
|
|
24
|
+
</g>
|
|
25
|
+
<g opacity="0.5" filter="url(#filter7_f_28911_9466)">
|
|
26
|
+
<rect x="11" y="56" width="7" height="21" rx="3.5" fill="black"/>
|
|
27
|
+
</g>
|
|
28
|
+
<g opacity="0.45" filter="url(#filter8_f_28911_9466)">
|
|
29
|
+
<rect x="4" y="375" width="6" height="130" rx="3" fill="white"/>
|
|
30
|
+
</g>
|
|
31
|
+
<g opacity="0.34" filter="url(#filter9_f_28911_9466)">
|
|
32
|
+
<rect x="11" y="552" width="6" height="141" rx="3" fill="black"/>
|
|
33
|
+
</g>
|
|
34
|
+
<defs>
|
|
35
|
+
<filter id="filter0_f_28911_9466" x="7" y="2" width="12" height="763" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
36
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
37
|
+
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
|
38
|
+
<feGaussianBlur stdDeviation="2" result="effect1_foregroundBlur_28911_9466"/>
|
|
39
|
+
</filter>
|
|
40
|
+
<filter id="filter1_f_28911_9466" x="10" y="5" width="6" height="757" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
41
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
42
|
+
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
|
43
|
+
<feGaussianBlur stdDeviation="1" result="effect1_foregroundBlur_28911_9466"/>
|
|
44
|
+
</filter>
|
|
45
|
+
<filter id="filter2_f_28911_9466" x="13" y="5" width="12" height="757" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
46
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
47
|
+
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
|
48
|
+
<feGaussianBlur stdDeviation="1" result="effect1_foregroundBlur_28911_9466"/>
|
|
49
|
+
</filter>
|
|
50
|
+
<filter id="filter3_f_28911_9466" x="17" y="6" width="5" height="756" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
51
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
52
|
+
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
|
53
|
+
<feGaussianBlur stdDeviation="1" result="effect1_foregroundBlur_28911_9466"/>
|
|
54
|
+
</filter>
|
|
55
|
+
<filter id="filter4_f_28911_9466" x="2" y="0" width="12" height="768" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
56
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
57
|
+
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
|
58
|
+
<feGaussianBlur stdDeviation="2" result="effect1_foregroundBlur_28911_9466"/>
|
|
59
|
+
</filter>
|
|
60
|
+
<filter id="filter5_f_28911_9466" x="4" y="4" width="4" height="759" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
61
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
62
|
+
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
|
63
|
+
<feGaussianBlur stdDeviation="0.5" result="effect1_foregroundBlur_28911_9466"/>
|
|
64
|
+
</filter>
|
|
65
|
+
<filter id="filter6_f_28911_9466" x="0" y="548" width="14" height="218" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
66
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
67
|
+
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
|
68
|
+
<feGaussianBlur stdDeviation="2" result="effect1_foregroundBlur_28911_9466"/>
|
|
69
|
+
</filter>
|
|
70
|
+
<filter id="filter7_f_28911_9466" x="7" y="52" width="15" height="29" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
71
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
72
|
+
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
|
73
|
+
<feGaussianBlur stdDeviation="2" result="effect1_foregroundBlur_28911_9466"/>
|
|
74
|
+
</filter>
|
|
75
|
+
<filter id="filter8_f_28911_9466" x="0" y="371" width="14" height="138" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
76
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
77
|
+
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
|
78
|
+
<feGaussianBlur stdDeviation="2" result="effect1_foregroundBlur_28911_9466"/>
|
|
79
|
+
</filter>
|
|
80
|
+
<filter id="filter9_f_28911_9466" x="5" y="546" width="18" height="153" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
81
|
+
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
|
82
|
+
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
|
83
|
+
<feGaussianBlur stdDeviation="3" result="effect1_foregroundBlur_28911_9466"/>
|
|
84
|
+
</filter>
|
|
85
|
+
<linearGradient id="paint0_linear_28911_9466" x1="4" y1="383.5" x2="28" y2="383.5" gradientUnits="userSpaceOnUse">
|
|
86
|
+
<stop stop-color="#C8C8C8"/>
|
|
87
|
+
<stop offset="0.68" stop-color="#7B7B7B"/>
|
|
88
|
+
<stop offset="0.94" stop-color="#8C8C8C"/>
|
|
89
|
+
</linearGradient>
|
|
90
|
+
<linearGradient id="paint1_linear_28911_9466" x1="4" y1="383.5" x2="1" y2="383.5" gradientUnits="userSpaceOnUse">
|
|
91
|
+
<stop offset="0.23" stop-color="white"/>
|
|
92
|
+
<stop offset="0.27" stop-color="#4A4A4A"/>
|
|
93
|
+
<stop offset="0.525" stop-color="#7C7C7C"/>
|
|
94
|
+
<stop offset="1" stop-color="#8F8F8F"/>
|
|
95
|
+
</linearGradient>
|
|
96
|
+
</defs>
|
|
97
|
+
</svg>
|