diff --git a/examples/nextjs/.gitignore b/examples/nextjs/.gitignore index adbf2f0..f6f5953 100644 --- a/examples/nextjs/.gitignore +++ b/examples/nextjs/.gitignore @@ -3,3 +3,4 @@ node_modules public/pspdfkit-lib .next .tool-versions +public/nutrient-viewer \ No newline at end of file diff --git a/examples/nextjs/Readme.md b/examples/nextjs/Readme.md index e5bc9b7..58de088 100644 --- a/examples/nextjs/Readme.md +++ b/examples/nextjs/Readme.md @@ -8,7 +8,7 @@ This example shows how to integrate [Nutrient Web SDK](https://www.nutrient.io/w ## Support, Issues and License Questions -PSPDFKit offers support for customers with an active SDK license via https://www.nutrient.io/support/request/ +Nutrient offers support for customers with an active SDK license via https://www.nutrient.io/support/request/ Are you [evaluating our SDK](https://www.nutrient.io/try/)? That's great, we're happy to help out! To make sure this is fast, please use a work email and have someone from your company fill out our sales form: https://www.nutrient.io/sales/ @@ -17,20 +17,12 @@ Are you [evaluating our SDK](https://www.nutrient.io/try/)? That's great, we're Clone the repo: ```bash -git clone https://github.com/PSPDFKit/pspdfkit-web-example-nextjs.git -cd pspdfkit-web-example-nextjs +git clone https://github.com/PSPDFKit/nutrient-web-examples +cd nutrient-web-examples/examples/nextjs ``` Install the project dependencies: -yarn: - -```bash -yarn -``` - -npm: - ```shell script npm install ``` @@ -39,14 +31,6 @@ npm install We are ready to launch the app! 🎉 -yarn: - -```bash -yarn dev -``` - -npm: - ```shell script npm run dev ``` diff --git a/examples/nextjs/app/layout.js b/examples/nextjs/app/layout.js index 7595b1b..070e24f 100644 --- a/examples/nextjs/app/layout.js +++ b/examples/nextjs/app/layout.js @@ -9,10 +9,10 @@ const RootLayout = ({ children }) => { return (
- {/* Load PSPDFKit script using Next.js Script component */} + {/* Load Nutrient script using Next.js Script component */} {children} diff --git a/examples/nextjs/app/page.js b/examples/nextjs/app/page.js index 92118de..34be6a3 100644 --- a/examples/nextjs/app/page.js +++ b/examples/nextjs/app/page.js @@ -12,17 +12,16 @@ export default function App() { useEffect(() => { const container = containerRef.current; - const { PSPDFKit } = window; - if (container && PSPDFKit) { - PSPDFKit.load({ + const { NutrientViewer } = window; + if (container && NutrientViewer) { + NutrientViewer.load({ container, document: "/example.pdf", - baseUrl: `${window.location.protocol}//${window.location.host}/`, }); } return () => { - PSPDFKit?.unload(container); + NutrientViewer?.unload(container); }; }, []); diff --git a/examples/nextjs/next.config.js b/examples/nextjs/next.config.js index 3e98807..f8fb2c0 100644 --- a/examples/nextjs/next.config.js +++ b/examples/nextjs/next.config.js @@ -1,11 +1,11 @@ -// Exclude pspdfkit from the client-side bundle to optimize performance +// Exclude @nutrient-sdk/viewer from the client-side bundle to optimize performance // and avoid potential conflicts with the script loaded in layout.js const nextConfig = { webpack: (config, { isServer }) => { if (!isServer) { config.externals = config.externals || []; config.externals.push({ - pspdfkit: "pspdfkit", + "@nutrient-sdk/viewer": "@nutrient-sdk/viewer", }); } @@ -14,7 +14,7 @@ const nextConfig = { experimental: { turbo: { resolveAlias: { - pspdfkit: "pspdfkit", + "@nutrient-sdk/viewer": "@nutrient-sdk/viewer", }, }, }, diff --git a/examples/nextjs/package-lock.json b/examples/nextjs/package-lock.json index a0bae37..425d983 100644 --- a/examples/nextjs/package-lock.json +++ b/examples/nextjs/package-lock.json @@ -9,8 +9,8 @@ "version": "1.0.0", "license": "SEE LICENSE IN https://www.nutrient.io/legal/Nutrient_SDK_User_Evaluation_Subscription_Agreement", "dependencies": { + "@nutrient-sdk/viewer": "^1.0.0", "next": "^15.1.3", - "pspdfkit": "2024.8.1", "react": "^19.0.0", "react-dom": "^19.0.0" } @@ -140,6 +140,14 @@ "node": ">= 10" } }, + "node_modules/@nutrient-sdk/viewer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@nutrient-sdk/viewer/-/viewer-1.0.0.tgz", + "integrity": "sha512-o2zp0xWwqIA7bEav5ymamNe/61EnSjY/7mkwy6nwgB2cudFFn8L8mI6Axd94UovqQrkCr9LT8gQOGboR0GBdvQ==", + "dependencies": { + "@types/react": "^17.0.39" + } + }, "node_modules/@swc/counter": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", @@ -371,15 +379,6 @@ "node": "^10 || ^12 || >=14" } }, - "node_modules/pspdfkit": { - "version": "2024.8.1", - "resolved": "https://registry.npmjs.org/pspdfkit/-/pspdfkit-2024.8.1.tgz", - "integrity": "sha512-NLRZdRa9L9sO+Xbd3LD+xyZ9+o3cFNdZHvH2iOAkNl5xcQUdxGMJLhJsU6xtkeXgdYPoYQbPb1EvuCtNdJIHaA==", - "license": "SEE LICENSE IN https://www.nutrient.io/legal/Nutrient_SDK_User_Evaluation_Subscription_Agreement", - "dependencies": { - "@types/react": "^17.0.39" - } - }, "node_modules/react": { "version": "19.0.0", "resolved": "https://registry.npmjs.org/react/-/react-19.0.0.tgz", diff --git a/examples/nextjs/package.json b/examples/nextjs/package.json index a81f1c1..e027010 100644 --- a/examples/nextjs/package.json +++ b/examples/nextjs/package.json @@ -4,13 +4,13 @@ "main": "index.js", "license": "SEE LICENSE IN https://www.nutrient.io/legal/Nutrient_SDK_User_Evaluation_Subscription_Agreement", "dependencies": { + "@nutrient-sdk/viewer": "^1.0.0", "next": "^15.1.3", - "pspdfkit": "2024.8.1", "react": "^19.0.0", "react-dom": "^19.0.0" }, "scripts": { - "copy-assets": "cp -R ./node_modules/pspdfkit/dist/pspdfkit-lib ./public/ && cp -R ./node_modules/pspdfkit/dist/pspdfkit.js ./public/pspdfkit-lib/pspdfkit.js", + "copy-assets": "cp -R ./node_modules/@nutrient-sdk/viewer/dist/ ./public/nutrient-viewer", "dev": "npm run copy-assets && next dev --turbo", "build": "npm run copy-assets && next build", "start": "next start", diff --git a/examples/vite/.gitignore b/examples/vite/.gitignore index a32d36b..12011fc 100644 --- a/examples/vite/.gitignore +++ b/examples/vite/.gitignore @@ -23,3 +23,4 @@ yarn-debug.log* yarn-error.log* public/pspdfkit-lib +public/nutrient-viewer-lib \ No newline at end of file diff --git a/examples/vite/README.md b/examples/vite/README.md index c18358a..cdf4778 100644 --- a/examples/vite/README.md +++ b/examples/vite/README.md @@ -1,6 +1,6 @@ # Nutrient Web SDK Example – Vite.js -This example shows how to integrate [PSPDFKit for Web](https://www.nutrient.io/web/) into a [Vite.js](https://vitejs.dev/) with React app. +This example shows how to integrate [Nutrient for Web](https://www.nutrient.io/web/) into a [Vite.js](https://vitejs.dev/) with React app. ## Prerequisites @@ -8,7 +8,7 @@ This example shows how to integrate [PSPDFKit for Web](https://www.nutrient.io/w ## Support, Issues and License Questions -PSPDFKit offers support for customers with an active SDK license via https://www.nutrient.io/support/request/ +Nutrient offers support for customers with an active SDK license via https://www.nutrient.io/support/request/ Are you [evaluating our SDK](https://www.nutrient.io/try/)? That's great, we're happy to help out! To make sure this is fast, please use a work email and have someone from your company fill out our sales form: https://www.nutrient.io/sales/ @@ -17,8 +17,8 @@ Are you [evaluating our SDK](https://www.nutrient.io/try/)? That's great, we're Clone the repo: ```bash -git clone https://github.com/PSPDFKit/pspdfkit-web-example-vite.git -cd pspdfkit-web-example-vite +git clone https://github.com/PSPDFKit/nutrient-web-examples +cd nutrient-web-examples/examples/vite ``` Install the project dependencies: @@ -50,9 +50,9 @@ Enjoy 🍕 ## React Component -The React component which implements the PSPDFKit for Web integration can be found at `src/components/PdfViewerComponent.jsx`. +The React component which implements the Nutrient for Web integration can be found at `src/components/PdfViewerComponent.jsx`. -In order to make the PSPDFKit SDK assets available they have to be copied from the `node_modules/pspdfkit/dist` folder to `public/pspdfkit-lib` folder. For that purpose this example uses a copy plugin which you can find at `vite.config.js`. +In order to make the Nutrient SDK assets available they have to be copied from the `node_modules/@nutrient-sdk/viewer/dist/nutrient-viewer-lib` folder to `public/nutrient-viewer-lib` folder. For that purpose this example uses a copy plugin which you can find at `vite.config.js`. ## License diff --git a/examples/vite/package-lock.json b/examples/vite/package-lock.json index 3d9e034..b596f3b 100644 --- a/examples/vite/package-lock.json +++ b/examples/vite/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "SEE LICENSE IN https://www.nutrient.io/legal/Nutrient_SDK_User_Evaluation_Subscription_Agreement", "dependencies": { - "pspdfkit": "2024.8.1", + "@nutrient-sdk/viewer": "^1.0.0", "react": "^18.2.0", "react-dom": "^18.2.0" }, @@ -818,6 +818,14 @@ "node": ">= 8" } }, + "node_modules/@nutrient-sdk/viewer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@nutrient-sdk/viewer/-/viewer-1.0.0.tgz", + "integrity": "sha512-o2zp0xWwqIA7bEav5ymamNe/61EnSjY/7mkwy6nwgB2cudFFn8L8mI6Axd94UovqQrkCr9LT8gQOGboR0GBdvQ==", + "dependencies": { + "@types/react": "^17.0.39" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.22.4", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", @@ -1877,15 +1885,6 @@ "node": "^10 || ^12 || >=14" } }, - "node_modules/pspdfkit": { - "version": "2024.8.1", - "resolved": "https://registry.npmjs.org/pspdfkit/-/pspdfkit-2024.8.1.tgz", - "integrity": "sha512-NLRZdRa9L9sO+Xbd3LD+xyZ9+o3cFNdZHvH2iOAkNl5xcQUdxGMJLhJsU6xtkeXgdYPoYQbPb1EvuCtNdJIHaA==", - "license": "SEE LICENSE IN https://www.nutrient.io/legal/Nutrient_SDK_User_Evaluation_Subscription_Agreement", - "dependencies": { - "@types/react": "^17.0.39" - } - }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", diff --git a/examples/vite/package.json b/examples/vite/package.json index 719cbb1..1ce05aa 100644 --- a/examples/vite/package.json +++ b/examples/vite/package.json @@ -26,7 +26,7 @@ "start:e2e": "vite --port 3000" }, "dependencies": { - "pspdfkit": "2024.8.1", + "@nutrient-sdk/viewer": "^1.0.0", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/examples/vite/src/components/PdfViewerComponent.jsx b/examples/vite/src/components/PdfViewerComponent.jsx index fcf90d9..49b4be5 100644 --- a/examples/vite/src/components/PdfViewerComponent.jsx +++ b/examples/vite/src/components/PdfViewerComponent.jsx @@ -5,14 +5,14 @@ export default function PdfViewerComponent(props) { useEffect(() => { const container = containerRef.current; - let PSPDFKit; + let NutrientViewer; (async () => { - PSPDFKit = await import("pspdfkit"); + NutrientViewer = await import("@nutrient-sdk/viewer"); - PSPDFKit.unload(container); // Ensure that there's only one PSPDFKit instance. + NutrientViewer.unload(container); // Ensure that there's only one PSPDFKit instance. - await PSPDFKit.load({ + await NutrientViewer.load({ // Container where PSPDFKit should be mounted. container, // The document to open. @@ -24,7 +24,7 @@ export default function PdfViewerComponent(props) { }); })(); - return () => PSPDFKit?.unload(container); + return () => NutrientViewer?.unload(container); }, [props.document]); return ; diff --git a/examples/vite/vite.config.js b/examples/vite/vite.config.js index 871f9f9..72241a5 100644 --- a/examples/vite/vite.config.js +++ b/examples/vite/vite.config.js @@ -10,7 +10,7 @@ export default defineConfig({ copy({ targets: [ { - src: "node_modules/pspdfkit/dist/pspdfkit-lib", + src: "node_modules/@nutrient-sdk/viewer/dist/nutrient-viewer-lib", dest: "public/", }, ], diff --git a/examples/vue-composition-api/.gitignore b/examples/vue-composition-api/.gitignore index 2d144df..3d4d198 100644 --- a/examples/vue-composition-api/.gitignore +++ b/examples/vue-composition-api/.gitignore @@ -30,4 +30,5 @@ coverage *.tsbuildinfo # Web SDK static files -public/pspdfkit-lib/ \ No newline at end of file +public/pspdfkit-lib/ +public/nutrient-viewer-lib/ \ No newline at end of file diff --git a/examples/vue-composition-api/package.json b/examples/vue-composition-api/package.json index 7e06b06..326708d 100644 --- a/examples/vue-composition-api/package.json +++ b/examples/vue-composition-api/package.json @@ -11,7 +11,7 @@ "type-check": "vue-tsc --build" }, "dependencies": { - "pspdfkit": "^2024.8.1", + "@nutrient-sdk/viewer": "^1.0.0", "vue": "^3.5.13" }, "devDependencies": { diff --git a/examples/vue-composition-api/pnpm-lock.yaml b/examples/vue-composition-api/pnpm-lock.yaml index 326fe86..1789a7b 100644 --- a/examples/vue-composition-api/pnpm-lock.yaml +++ b/examples/vue-composition-api/pnpm-lock.yaml @@ -8,9 +8,9 @@ importers: .: dependencies: - pspdfkit: - specifier: ^2024.8.1 - version: 2024.8.1 + '@nutrient-sdk/viewer': + specifier: ^1.0.0 + version: 1.0.0 vue: specifier: ^3.5.13 version: 3.5.13(typescript@5.7.3) @@ -371,6 +371,9 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} + '@nutrient-sdk/viewer@1.0.0': + resolution: {integrity: sha512-o2zp0xWwqIA7bEav5ymamNe/61EnSjY/7mkwy6nwgB2cudFFn8L8mI6Axd94UovqQrkCr9LT8gQOGboR0GBdvQ==} + '@polka/url@1.0.0-next.28': resolution: {integrity: sha512-8LduaNlMZGwdZ6qWrKlfa+2M4gahzFkprZiAt2TF8uS0qQgBizKXpXURqvTJ4WtmupWxaLqjRb2UCTe72mu+Aw==} @@ -1006,9 +1009,6 @@ packages: resolution: {integrity: sha512-4yf0QO/sllf/1zbZWYnvWw3NxCQwLXKzIj0G849LSufP15BXKM0rbD2Z3wVnkMfjdn/CB0Dpp444gYAACdsplg==} engines: {node: '>=18'} - pspdfkit@2024.8.1: - resolution: {integrity: sha512-NLRZdRa9L9sO+Xbd3LD+xyZ9+o3cFNdZHvH2iOAkNl5xcQUdxGMJLhJsU6xtkeXgdYPoYQbPb1EvuCtNdJIHaA==} - queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} @@ -1525,6 +1525,10 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.19.0 + '@nutrient-sdk/viewer@1.0.0': + dependencies: + '@types/react': 17.0.83 + '@polka/url@1.0.0-next.28': {} '@rollup/pluginutils@5.1.4(rollup@4.32.1)': @@ -2144,10 +2148,6 @@ snapshots: dependencies: parse-ms: 4.0.0 - pspdfkit@2024.8.1: - dependencies: - '@types/react': 17.0.83 - queue-microtask@1.2.3: {} read-package-json-fast@4.0.0: diff --git a/examples/vue-composition-api/src/App.vue b/examples/vue-composition-api/src/App.vue index 0c3dda2..a01057d 100644 --- a/examples/vue-composition-api/src/App.vue +++ b/examples/vue-composition-api/src/App.vue @@ -2,14 +2,14 @@ import { onMounted, onUnmounted, useTemplateRef } from "vue"; const containerRef = useTemplateRef("container"); -let PSPDFKit: typeof import("pspdfkit").default | undefined; +let NutrientViewer: typeof import("@nutrient-sdk/viewer").default | undefined; onMounted(async () => { - PSPDFKit = (await import("pspdfkit")).default; + NutrientViewer = (await import("@nutrient-sdk/viewer")).default; const container = containerRef.value; - if (container && PSPDFKit) { - PSPDFKit.load({ + if (container && NutrientViewer) { + NutrientViewer.load({ container, // you may also specify a file in public directory e.g. /document.pdf document: "https://www.nutrient.io/downloads/pspdfkit-web-demo.pdf", @@ -22,8 +22,8 @@ onMounted(async () => { onUnmounted(() => { const container = containerRef.value; - if (container && PSPDFKit) { - PSPDFKit.unload(container); + if (container && NutrientViewer) { + NutrientViewer.unload(container); } }); diff --git a/examples/vue-composition-api/vite.config.ts b/examples/vue-composition-api/vite.config.ts index 6833beb..06166af 100644 --- a/examples/vue-composition-api/vite.config.ts +++ b/examples/vue-composition-api/vite.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ copy({ targets: [ { - src: "node_modules/pspdfkit/dist/pspdfkit-lib", + src: "node_modules/@nutrient-sdk/viewer/dist/nutrient-viewer-lib", dest: "public/", }, ],