@oiij/js-pdf 0.0.4 → 0.0.6
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 +5 -17
- package/dist/index.cjs +2 -4
- package/dist/index.js +2 -4
- package/package.json +5 -5
package/LICENSE
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
MIT License
|
|
1
|
+
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright
|
|
3
|
+
Copyright © 2025 [OIIJ](https://github.com/oiij)
|
|
4
4
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
11
6
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
14
8
|
|
|
15
|
-
THE SOFTWARE IS PROVIDED
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -76,11 +76,10 @@ async function pdf2Canvases(pdf) {
|
|
|
76
76
|
try {
|
|
77
77
|
const pages = await Promise.all(Array.from({ length: pdf.numPages }).map((_, i) => pdf.getPage(i + 1)));
|
|
78
78
|
const id = (0, nanoid.nanoid)();
|
|
79
|
-
const canvases = await Promise.all(pages.map((page) => page2Canvas(page, id)));
|
|
80
79
|
return {
|
|
81
80
|
pages,
|
|
82
81
|
id,
|
|
83
|
-
canvases
|
|
82
|
+
canvases: await Promise.all(pages.map((page) => page2Canvas(page, id)))
|
|
84
83
|
};
|
|
85
84
|
} catch (error) {
|
|
86
85
|
console.error(error);
|
|
@@ -100,8 +99,7 @@ async function openPdf(url) {
|
|
|
100
99
|
};
|
|
101
100
|
}
|
|
102
101
|
if (url instanceof File) {
|
|
103
|
-
const
|
|
104
|
-
const pdf = await (0, pdfjs_dist.getDocument)(buffer).promise;
|
|
102
|
+
const pdf = await (0, pdfjs_dist.getDocument)(await file2Buffer(url)).promise;
|
|
105
103
|
const { pages, id, canvases } = await pdf2Canvases(pdf);
|
|
106
104
|
return {
|
|
107
105
|
pdf,
|
package/dist/index.js
CHANGED
|
@@ -48,11 +48,10 @@ async function pdf2Canvases(pdf) {
|
|
|
48
48
|
try {
|
|
49
49
|
const pages = await Promise.all(Array.from({ length: pdf.numPages }).map((_, i) => pdf.getPage(i + 1)));
|
|
50
50
|
const id = nanoid();
|
|
51
|
-
const canvases = await Promise.all(pages.map((page) => page2Canvas(page, id)));
|
|
52
51
|
return {
|
|
53
52
|
pages,
|
|
54
53
|
id,
|
|
55
|
-
canvases
|
|
54
|
+
canvases: await Promise.all(pages.map((page) => page2Canvas(page, id)))
|
|
56
55
|
};
|
|
57
56
|
} catch (error) {
|
|
58
57
|
console.error(error);
|
|
@@ -72,8 +71,7 @@ async function openPdf(url) {
|
|
|
72
71
|
};
|
|
73
72
|
}
|
|
74
73
|
if (url instanceof File) {
|
|
75
|
-
const
|
|
76
|
-
const pdf = await getDocument(buffer).promise;
|
|
74
|
+
const pdf = await getDocument(await file2Buffer(url)).promise;
|
|
77
75
|
const { pages, id, canvases } = await pdf2Canvases(pdf);
|
|
78
76
|
return {
|
|
79
77
|
pdf,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oiij/js-pdf",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"description": "A simple PDF library for JavaScript",
|
|
6
6
|
"author": "oiij",
|
|
7
7
|
"license": "MIT",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"file-saver": "^2.0.5",
|
|
37
37
|
"jspdf": "^3.0.3",
|
|
38
38
|
"jszip": "^3.10.1",
|
|
39
|
-
"nanoid": "^5.1.
|
|
40
|
-
"pdfjs-dist": "^5.4.
|
|
39
|
+
"nanoid": "^5.1.6",
|
|
40
|
+
"pdfjs-dist": "^5.4.296"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/file-saver": "^2.0.7",
|
|
44
44
|
"file-saver": "^2.0.5",
|
|
45
45
|
"jspdf": "^3.0.3",
|
|
46
46
|
"jszip": "^3.10.1",
|
|
47
|
-
"nanoid": "^5.1.
|
|
48
|
-
"pdfjs-dist": "^5.4.
|
|
47
|
+
"nanoid": "^5.1.6",
|
|
48
|
+
"pdfjs-dist": "^5.4.296"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|