Skip to content

Commit

Permalink
add pdfjs
Browse files Browse the repository at this point in the history
  • Loading branch information
zapaz committed Feb 1, 2024
1 parent 938b5dc commit 3d278fc
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 33 deletions.
2 changes: 1 addition & 1 deletion common/lib/common/pdfjs.tos → common/lib/common/pdfjs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PDFDocumentProxy, PDFPageProxy } from "pdfjs-dist";

import { GlobalWorkerOptions, getDocument, PageViewport } from "pdfjs-dist";
import pdfjsWorker from "pdfjs-dist/build/pdf.worker.entry";
import pdfjsWorker from "pdfjs-dist/build/pdf.worker";

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
GlobalWorkerOptions.workerSrc = pdfjsWorker;
Expand Down
4 changes: 2 additions & 2 deletions common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@ipld/dag-pb": "^4.0.8",
"@types/findup-sync": "^4.0.4",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.11.15",
"@types/node": "^20.11.16",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"dotenv": "^16.4.1",
Expand All @@ -38,7 +38,7 @@
"findup-sync": "^5.0.0",
"fs-extra": "^11.2.0",
"multiformats": "^13.0.1",
"pdfjs-dist": "^4.0.379",
"pdfjs-dist": "^3.11.174",
"prettier": "^3.2.4",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "ISC",
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.11.13",
"@types/node": "^20.11.16",
"fs-extra": "^11.2.0",
"handlebars": "^4.7.8"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"pnpm": "^8"
},
"devDependencies": {
"turbo": "^1.12.0"
"turbo": "^1.12.2"
}
}
61 changes: 36 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions sveltekit/src/lib/components/Nft/NftMintPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import NftMint from "./NftMint.svelte";
import { storageLinkToUrlHttp } from "@kredeum/common/lib/nft/storage/storage";
// import { pdfjsGetPage, pdfjsCrop } from "@kredeum/common/lib/common/pdfjs";
import { pdfjsGetPage, pdfjsCrop } from "@kredeum/common/lib/common/pdfjs";
////////////////////////////////////////////////////////////////
// <NftMintPopup {chainId} {signer} />
Expand Down Expand Up @@ -138,8 +138,13 @@
};
const pdfToCoverImg = async () => {
// const page = await pdfjsGetPage(storageLinkToUrlHttp(pdf), 1);
// src = await pdfjsCrop(page, 437, 437, -89, -179);
if (!pdf) return;
const page = await pdfjsGetPage(storageLinkToUrlHttp(pdf), 1);
if (!page) return;
src = await pdfjsCrop(page, 437, 437, -89, -179);
};
const setDefaultAudioCover = () => {
Expand Down

0 comments on commit 3d278fc

Please sign in to comment.