@embedpdf/vue-pdf-viewer 1.0.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 CloudPDF
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:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
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.
package/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # @embedpdf/vue-pdf-viewer
2
+
3
+ Vue 3 component for embedding PDF documents with full-featured viewing capabilities.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @embedpdf/vue-pdf-viewer
9
+ # or
10
+ pnpm add @embedpdf/vue-pdf-viewer
11
+ # or
12
+ yarn add @embedpdf/vue-pdf-viewer
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```vue
18
+ <template>
19
+ <PDFViewer
20
+ :config="{
21
+ src: '/document.pdf',
22
+ theme: { preference: 'system' },
23
+ }"
24
+ :style="{ width: '100%', height: '100vh' }"
25
+ @ready="onReady"
26
+ />
27
+ </template>
28
+
29
+ <script setup lang="ts">
30
+ import { PDFViewer } from '@embedpdf/vue-pdf-viewer';
31
+ import type { PluginRegistry } from '@embedpdf/vue-pdf-viewer';
32
+
33
+ function onReady(registry: PluginRegistry) {
34
+ console.log('PDF viewer ready', registry);
35
+ }
36
+ </script>
37
+ ```
38
+
39
+ ## Props
40
+
41
+ | Prop | Type | Description |
42
+ | -------- | ----------------- | ---------------------------------------- |
43
+ | `config` | `PDFViewerConfig` | Full configuration object for the viewer |
44
+ | `class` | `string` | CSS class name for the container |
45
+ | `style` | `CSSProperties` | Inline styles for the container |
46
+
47
+ The `config` prop accepts all configuration options from `@embedpdf/snippet`, including:
48
+
49
+ - `src` - URL or path to the PDF document
50
+ - `theme` - Theme configuration
51
+ - `zoom` - Zoom configuration
52
+ - `scroll` - Scroll configuration
53
+ - `annotations` - Annotation configuration
54
+ - And more...
55
+
56
+ ## Events
57
+
58
+ | Event | Payload | Description |
59
+ | ------- | ------------------- | ---------------------------------- |
60
+ | `init` | `EmbedPdfContainer` | Emitted when viewer is initialized |
61
+ | `ready` | `PluginRegistry` | Emitted when registry is ready |
62
+
63
+ ## Accessing the Registry
64
+
65
+ Use a template ref to access the viewer container and registry:
66
+
67
+ ```vue
68
+ <template>
69
+ <PDFViewer
70
+ ref="viewerRef"
71
+ :config="{ src: '/document.pdf' }"
72
+ :style="{ width: '100%', height: '100vh' }"
73
+ />
74
+ <button @click="handleClick">Get Registry</button>
75
+ </template>
76
+
77
+ <script setup lang="ts">
78
+ import { ref } from 'vue';
79
+ import { PDFViewer, type PDFViewerExpose } from '@embedpdf/vue-pdf-viewer';
80
+
81
+ const viewerRef = ref<PDFViewerExpose | null>(null);
82
+
83
+ async function handleClick() {
84
+ const registry = await viewerRef.value?.registry;
85
+ // Use registry to access plugins
86
+ }
87
+ </script>
88
+ ```
89
+
90
+ ## License
91
+
92
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),t=require("@embedpdf/snippet"),r=e.defineComponent({name:"PDFViewer",props:{config:{type:Object,default:()=>({})}},emits:{init:e=>!0,ready:e=>!0},setup(r,{emit:n,expose:l,attrs:u}){const o=e.ref(null),i=e.ref(null);return l({get container(){return i.value},get registry(){var e;return(null==(e=i.value)?void 0:e.registry)??null}}),e.onMounted(()=>{if(!o.value)return;const e=t.init({type:"container",target:o.value,...r.config});e&&(i.value=e,n("init",e),e.registry.then(e=>{n("ready",e)}))}),e.onBeforeUnmount(()=>{i.value&&o.value&&(o.value.innerHTML="",i.value=null)}),()=>e.h("div",{ref:o,class:u.class,style:u.style})}});exports.PDFViewer=r,exports.default=r,Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { defineComponent, ref, onMounted, onBeforeUnmount, h, type PropType } from 'vue';\nimport EmbedPDF, {\n type EmbedPdfContainer,\n type PDFViewerConfig,\n type PluginRegistry,\n} from '@embedpdf/snippet';\n\n// Re-export everything from snippet for convenience\nexport * from '@embedpdf/snippet';\n\nexport interface PDFViewerExpose {\n /** The EmbedPdfContainer element */\n container: EmbedPdfContainer | null;\n /** Promise that resolves to the PluginRegistry */\n registry: Promise<PluginRegistry> | null;\n}\n\n/**\n * Vue component for embedding PDF documents\n *\n * @example\n * ```vue\n * <template>\n * <PDFViewer\n * :config=\"{ src: '/document.pdf', theme: { preference: 'system' } }\"\n * :style=\"{ width: '100%', height: '100vh' }\"\n * @ready=\"onReady\"\n * />\n * </template>\n *\n * <script setup lang=\"ts\">\n * import { PDFViewer } from '@embedpdf/vue-pdf-viewer';\n *\n * function onReady(registry) {\n * console.log('PDF viewer ready', registry);\n * }\n * </script>\n * ```\n */\nexport const PDFViewer = defineComponent({\n name: 'PDFViewer',\n\n props: {\n /** Full configuration for the PDF viewer */\n config: {\n type: Object as PropType<PDFViewerConfig>,\n default: () => ({}),\n },\n },\n\n emits: {\n /** Emitted when the viewer is initialized */\n init: (_container: EmbedPdfContainer) => true,\n /** Emitted when the registry is ready */\n ready: (_registry: PluginRegistry) => true,\n },\n\n setup(props, { emit, expose, attrs }) {\n const containerRef = ref<HTMLDivElement | null>(null);\n const viewerRef = ref<EmbedPdfContainer | null>(null);\n\n // Expose container and registry to parent\n expose({\n get container() {\n return viewerRef.value;\n },\n get registry() {\n return viewerRef.value?.registry ?? null;\n },\n } as PDFViewerExpose);\n\n onMounted(() => {\n if (!containerRef.value) return;\n\n // Initialize the viewer with the config prop\n const viewer = EmbedPDF.init({\n type: 'container',\n target: containerRef.value,\n ...props.config,\n });\n\n if (viewer) {\n viewerRef.value = viewer;\n emit('init', viewer);\n\n // Emit ready when registry is available\n viewer.registry.then((registry) => {\n emit('ready', registry);\n });\n }\n });\n\n onBeforeUnmount(() => {\n // Cleanup: remove the viewer element\n if (viewerRef.value && containerRef.value) {\n containerRef.value.innerHTML = '';\n viewerRef.value = null;\n }\n });\n\n return () =>\n h('div', {\n ref: containerRef,\n class: attrs.class,\n style: attrs.style,\n });\n },\n});\n\nexport default PDFViewer;\n"],"names":["PDFViewer","defineComponent","name","props","config","type","Object","default","emits","init","_container","ready","_registry","setup","emit","expose","attrs","containerRef","ref","viewerRef","container","value","registry","_a","onMounted","viewer","EmbedPDF","target","then","onBeforeUnmount","innerHTML","h","class","style"],"mappings":"kKAuCaA,EAAYC,EAAAA,gBAAgB,CACvCC,KAAM,YAENC,MAAO,CAELC,OAAQ,CACNC,KAAMC,OACNC,QAAS,MAAO,KAIpBC,MAAO,CAELC,KAAOC,IAAkC,EAEzCC,MAAQC,IAA8B,GAGxC,KAAAC,CAAMV,GAAOW,KAAEA,EAAAC,OAAMA,EAAAC,MAAQA,IAC3B,MAAMC,EAAeC,EAAAA,IAA2B,MAC1CC,EAAYD,EAAAA,IAA8B,MAyChD,OAtCAH,EAAO,CACL,aAAIK,GACF,OAAOD,EAAUE,KACnB,EACA,YAAIC,SACF,OAAO,OAAAC,EAAAJ,EAAUE,YAAV,EAAAE,EAAiBD,WAAY,IACtC,IAGFE,EAAAA,UAAU,KACR,IAAKP,EAAaI,MAAO,OAGzB,MAAMI,EAASC,EAASjB,KAAK,CAC3BJ,KAAM,YACNsB,OAAQV,EAAaI,SAClBlB,EAAMC,SAGPqB,IACFN,EAAUE,MAAQI,EAClBX,EAAK,OAAQW,GAGbA,EAAOH,SAASM,KAAMN,IACpBR,EAAK,QAASQ,QAKpBO,EAAAA,gBAAgB,KAEVV,EAAUE,OAASJ,EAAaI,QAClCJ,EAAaI,MAAMS,UAAY,GAC/BX,EAAUE,MAAQ,QAIf,IACLU,EAAAA,EAAE,MAAO,CACPb,IAAKD,EACLe,MAAOhB,EAAMgB,MACbC,MAAOjB,EAAMiB,OAEnB"}
@@ -0,0 +1,58 @@
1
+ import { PropType } from 'vue';
2
+ import { EmbedPdfContainer, PDFViewerConfig, PluginRegistry } from '@embedpdf/snippet';
3
+ export * from '@embedpdf/snippet';
4
+ export interface PDFViewerExpose {
5
+ /** The EmbedPdfContainer element */
6
+ container: EmbedPdfContainer | null;
7
+ /** Promise that resolves to the PluginRegistry */
8
+ registry: Promise<PluginRegistry> | null;
9
+ }
10
+ /**
11
+ * Vue component for embedding PDF documents
12
+ *
13
+ * @example
14
+ * ```vue
15
+ * <template>
16
+ * <PDFViewer
17
+ * :config="{ src: '/document.pdf', theme: { preference: 'system' } }"
18
+ * :style="{ width: '100%', height: '100vh' }"
19
+ * @ready="onReady"
20
+ * />
21
+ * </template>
22
+ *
23
+ * <script setup lang="ts">
24
+ * import { PDFViewer } from '@embedpdf/vue-pdf-viewer';
25
+ *
26
+ * function onReady(registry) {
27
+ * console.log('PDF viewer ready', registry);
28
+ * }
29
+ * </script>
30
+ * ```
31
+ */
32
+ export declare const PDFViewer: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
33
+ /** Full configuration for the PDF viewer */
34
+ config: {
35
+ type: PropType<PDFViewerConfig>;
36
+ default: () => {};
37
+ };
38
+ }>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
39
+ [key: string]: any;
40
+ }>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
41
+ /** Emitted when the viewer is initialized */
42
+ init: (_container: EmbedPdfContainer) => true;
43
+ /** Emitted when the registry is ready */
44
+ ready: (_registry: PluginRegistry) => true;
45
+ }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
46
+ /** Full configuration for the PDF viewer */
47
+ config: {
48
+ type: PropType<PDFViewerConfig>;
49
+ default: () => {};
50
+ };
51
+ }>> & Readonly<{
52
+ onInit?: ((_container: EmbedPdfContainer) => any) | undefined;
53
+ onReady?: ((_registry: PluginRegistry) => any) | undefined;
54
+ }>, {
55
+ config: PDFViewerConfig;
56
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
57
+ export default PDFViewer;
58
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuD,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAC;AACzF,OAAiB,EACf,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAG3B,cAAc,mBAAmB,CAAC;AAElC,MAAM,WAAW,eAAe;IAC9B,oCAAoC;IACpC,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC,kDAAkD;IAClD,QAAQ,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,SAAS;IAIlB,4CAA4C;;cAE1B,QAAQ,CAAC,eAAe,CAAC;;;;;;IAM3C,6CAA6C;uBAC1B,iBAAiB;IACpC,yCAAyC;uBACtB,cAAc;;IAXjC,4CAA4C;;cAE1B,QAAQ,CAAC,eAAe,CAAC;;;;;;;;4EA8D7C,CAAC;AAEH,eAAe,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ import { defineComponent, ref, onMounted, onBeforeUnmount, h } from "vue";
2
+ import EmbedPDF__default from "@embedpdf/snippet";
3
+ export * from "@embedpdf/snippet";
4
+ const PDFViewer = defineComponent({
5
+ name: "PDFViewer",
6
+ props: {
7
+ /** Full configuration for the PDF viewer */
8
+ config: {
9
+ type: Object,
10
+ default: () => ({})
11
+ }
12
+ },
13
+ emits: {
14
+ /** Emitted when the viewer is initialized */
15
+ init: (_container) => true,
16
+ /** Emitted when the registry is ready */
17
+ ready: (_registry) => true
18
+ },
19
+ setup(props, { emit, expose, attrs }) {
20
+ const containerRef = ref(null);
21
+ const viewerRef = ref(null);
22
+ expose({
23
+ get container() {
24
+ return viewerRef.value;
25
+ },
26
+ get registry() {
27
+ var _a;
28
+ return ((_a = viewerRef.value) == null ? void 0 : _a.registry) ?? null;
29
+ }
30
+ });
31
+ onMounted(() => {
32
+ if (!containerRef.value) return;
33
+ const viewer = EmbedPDF__default.init({
34
+ type: "container",
35
+ target: containerRef.value,
36
+ ...props.config
37
+ });
38
+ if (viewer) {
39
+ viewerRef.value = viewer;
40
+ emit("init", viewer);
41
+ viewer.registry.then((registry) => {
42
+ emit("ready", registry);
43
+ });
44
+ }
45
+ });
46
+ onBeforeUnmount(() => {
47
+ if (viewerRef.value && containerRef.value) {
48
+ containerRef.value.innerHTML = "";
49
+ viewerRef.value = null;
50
+ }
51
+ });
52
+ return () => h("div", {
53
+ ref: containerRef,
54
+ class: attrs.class,
55
+ style: attrs.style
56
+ });
57
+ }
58
+ });
59
+ export {
60
+ PDFViewer,
61
+ PDFViewer as default
62
+ };
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { defineComponent, ref, onMounted, onBeforeUnmount, h, type PropType } from 'vue';\nimport EmbedPDF, {\n type EmbedPdfContainer,\n type PDFViewerConfig,\n type PluginRegistry,\n} from '@embedpdf/snippet';\n\n// Re-export everything from snippet for convenience\nexport * from '@embedpdf/snippet';\n\nexport interface PDFViewerExpose {\n /** The EmbedPdfContainer element */\n container: EmbedPdfContainer | null;\n /** Promise that resolves to the PluginRegistry */\n registry: Promise<PluginRegistry> | null;\n}\n\n/**\n * Vue component for embedding PDF documents\n *\n * @example\n * ```vue\n * <template>\n * <PDFViewer\n * :config=\"{ src: '/document.pdf', theme: { preference: 'system' } }\"\n * :style=\"{ width: '100%', height: '100vh' }\"\n * @ready=\"onReady\"\n * />\n * </template>\n *\n * <script setup lang=\"ts\">\n * import { PDFViewer } from '@embedpdf/vue-pdf-viewer';\n *\n * function onReady(registry) {\n * console.log('PDF viewer ready', registry);\n * }\n * </script>\n * ```\n */\nexport const PDFViewer = defineComponent({\n name: 'PDFViewer',\n\n props: {\n /** Full configuration for the PDF viewer */\n config: {\n type: Object as PropType<PDFViewerConfig>,\n default: () => ({}),\n },\n },\n\n emits: {\n /** Emitted when the viewer is initialized */\n init: (_container: EmbedPdfContainer) => true,\n /** Emitted when the registry is ready */\n ready: (_registry: PluginRegistry) => true,\n },\n\n setup(props, { emit, expose, attrs }) {\n const containerRef = ref<HTMLDivElement | null>(null);\n const viewerRef = ref<EmbedPdfContainer | null>(null);\n\n // Expose container and registry to parent\n expose({\n get container() {\n return viewerRef.value;\n },\n get registry() {\n return viewerRef.value?.registry ?? null;\n },\n } as PDFViewerExpose);\n\n onMounted(() => {\n if (!containerRef.value) return;\n\n // Initialize the viewer with the config prop\n const viewer = EmbedPDF.init({\n type: 'container',\n target: containerRef.value,\n ...props.config,\n });\n\n if (viewer) {\n viewerRef.value = viewer;\n emit('init', viewer);\n\n // Emit ready when registry is available\n viewer.registry.then((registry) => {\n emit('ready', registry);\n });\n }\n });\n\n onBeforeUnmount(() => {\n // Cleanup: remove the viewer element\n if (viewerRef.value && containerRef.value) {\n containerRef.value.innerHTML = '';\n viewerRef.value = null;\n }\n });\n\n return () =>\n h('div', {\n ref: containerRef,\n class: attrs.class,\n style: attrs.style,\n });\n },\n});\n\nexport default PDFViewer;\n"],"names":["EmbedPDF"],"mappings":";;;AAuCO,MAAM,YAAY,gBAAgB;AAAA,EACvC,MAAM;AAAA,EAEN,OAAO;AAAA;AAAA,IAEL,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,SAAS,OAAO,CAAA;AAAA,IAAC;AAAA,EACnB;AAAA,EAGF,OAAO;AAAA;AAAA,IAEL,MAAM,CAAC,eAAkC;AAAA;AAAA,IAEzC,OAAO,CAAC,cAA8B;AAAA,EAAA;AAAA,EAGxC,MAAM,OAAO,EAAE,MAAM,QAAQ,SAAS;AACpC,UAAM,eAAe,IAA2B,IAAI;AACpD,UAAM,YAAY,IAA8B,IAAI;AAGpD,WAAO;AAAA,MACL,IAAI,YAAY;AACd,eAAO,UAAU;AAAA,MACnB;AAAA,MACA,IAAI,WAAW;;AACb,iBAAO,eAAU,UAAV,mBAAiB,aAAY;AAAA,MACtC;AAAA,IAAA,CACkB;AAEpB,cAAU,MAAM;AACd,UAAI,CAAC,aAAa,MAAO;AAGzB,YAAM,SAASA,kBAAS,KAAK;AAAA,QAC3B,MAAM;AAAA,QACN,QAAQ,aAAa;AAAA,QACrB,GAAG,MAAM;AAAA,MAAA,CACV;AAED,UAAI,QAAQ;AACV,kBAAU,QAAQ;AAClB,aAAK,QAAQ,MAAM;AAGnB,eAAO,SAAS,KAAK,CAAC,aAAa;AACjC,eAAK,SAAS,QAAQ;AAAA,QACxB,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,oBAAgB,MAAM;AAEpB,UAAI,UAAU,SAAS,aAAa,OAAO;AACzC,qBAAa,MAAM,YAAY;AAC/B,kBAAU,QAAQ;AAAA,MACpB;AAAA,IACF,CAAC;AAED,WAAO,MACL,EAAE,OAAO;AAAA,MACP,KAAK;AAAA,MACL,OAAO,MAAM;AAAA,MACb,OAAO,MAAM;AAAA,IAAA,CACd;AAAA,EACL;AACF,CAAC;"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@embedpdf/vue-pdf-viewer",
3
+ "version": "1.0.0",
4
+ "description": "Vue component for embedding PDF documents",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "license": "MIT",
9
+ "type": "module",
10
+ "sideEffects": false,
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "dependencies": {
23
+ "@embedpdf/snippet": "1.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "@vitejs/plugin-vue": "^6.0.0",
27
+ "rimraf": "^5.0.5",
28
+ "typescript": "^5.1.6",
29
+ "unplugin-dts": "1.0.0-beta.6",
30
+ "vite": "^6.3.5",
31
+ "vue": "^3.4.0"
32
+ },
33
+ "peerDependencies": {
34
+ "vue": ">=3.0.0"
35
+ },
36
+ "keywords": [
37
+ "vue",
38
+ "pdf",
39
+ "viewer",
40
+ "embed",
41
+ "document"
42
+ ],
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "https://github.com/embedpdf/embed-pdf-viewer.git",
46
+ "directory": "viewers/vue"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "scripts": {
52
+ "clean": "rimraf dist",
53
+ "build": "pnpm run clean && vite build"
54
+ }
55
+ }