@embedpdf/svelte-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 +21 -0
- package/README.md +86 -0
- package/dist/PDFViewer.svelte +53 -0
- package/dist/PDFViewer.svelte.d.ts +28 -0
- package/dist/PDFViewer.svelte.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/package.json +52 -0
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,86 @@
|
|
|
1
|
+
# @embedpdf/svelte-pdf-viewer
|
|
2
|
+
|
|
3
|
+
Svelte component for embedding PDF documents with full-featured viewing capabilities.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @embedpdf/svelte-pdf-viewer
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @embedpdf/svelte-pdf-viewer
|
|
11
|
+
# or
|
|
12
|
+
yarn add @embedpdf/svelte-pdf-viewer
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```svelte
|
|
18
|
+
<script>
|
|
19
|
+
import { PDFViewer } from '@embedpdf/svelte-pdf-viewer';
|
|
20
|
+
|
|
21
|
+
const config = {
|
|
22
|
+
src: '/document.pdf',
|
|
23
|
+
theme: { preference: 'system' },
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function onReady(event) {
|
|
27
|
+
console.log('PDF viewer ready', event.detail);
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<PDFViewer {config} style="width: 100%; height: 100vh;" on:ready={onReady} />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Props
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Description |
|
|
37
|
+
| -------- | ----------------- | ---------------------------------------- |
|
|
38
|
+
| `config` | `PDFViewerConfig` | Full configuration object for the viewer |
|
|
39
|
+
| `class` | `string` | CSS class name for the container |
|
|
40
|
+
| `style` | `string` | Inline styles for the container |
|
|
41
|
+
|
|
42
|
+
The `config` prop accepts all configuration options from `@embedpdf/snippet`, including:
|
|
43
|
+
|
|
44
|
+
- `src` - URL or path to the PDF document
|
|
45
|
+
- `theme` - Theme configuration
|
|
46
|
+
- `zoom` - Zoom configuration
|
|
47
|
+
- `scroll` - Scroll configuration
|
|
48
|
+
- `annotations` - Annotation configuration
|
|
49
|
+
- And more...
|
|
50
|
+
|
|
51
|
+
## Events
|
|
52
|
+
|
|
53
|
+
| Event | Detail | Description |
|
|
54
|
+
| ------- | ------------------- | -------------------------------- |
|
|
55
|
+
| `init` | `EmbedPdfContainer` | Fired when viewer is initialized |
|
|
56
|
+
| `ready` | `PluginRegistry` | Fired when registry is ready |
|
|
57
|
+
|
|
58
|
+
## Accessing the Registry
|
|
59
|
+
|
|
60
|
+
Use bind: directives to access the viewer container and registry:
|
|
61
|
+
|
|
62
|
+
```svelte
|
|
63
|
+
<script>
|
|
64
|
+
import { PDFViewer } from '@embedpdf/svelte-pdf-viewer';
|
|
65
|
+
|
|
66
|
+
let container;
|
|
67
|
+
let registry;
|
|
68
|
+
|
|
69
|
+
async function handleClick() {
|
|
70
|
+
const reg = await registry;
|
|
71
|
+
// Use registry to access plugins
|
|
72
|
+
}
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<PDFViewer
|
|
76
|
+
bind:container
|
|
77
|
+
bind:registry
|
|
78
|
+
config={{ src: '/document.pdf' }}
|
|
79
|
+
style="width: 100%; height: 100vh;"
|
|
80
|
+
/>
|
|
81
|
+
<button on:click={handleClick}>Get Registry</button>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
|
|
3
|
+
import EmbedPDF, {
|
|
4
|
+
type EmbedPdfContainer,
|
|
5
|
+
type PDFViewerConfig,
|
|
6
|
+
type PluginRegistry,
|
|
7
|
+
} from '@embedpdf/snippet';
|
|
8
|
+
|
|
9
|
+
/** Full configuration for the PDF viewer */
|
|
10
|
+
export let config: PDFViewerConfig = {};
|
|
11
|
+
|
|
12
|
+
/** Exposed bindings for accessing the viewer */
|
|
13
|
+
export let container: EmbedPdfContainer | null = null;
|
|
14
|
+
export let registry: Promise<PluginRegistry> | null = null;
|
|
15
|
+
|
|
16
|
+
const dispatch = createEventDispatcher<{
|
|
17
|
+
init: EmbedPdfContainer;
|
|
18
|
+
ready: PluginRegistry;
|
|
19
|
+
}>();
|
|
20
|
+
|
|
21
|
+
let containerEl: HTMLDivElement;
|
|
22
|
+
|
|
23
|
+
onMount(() => {
|
|
24
|
+
// Initialize the viewer with the config prop
|
|
25
|
+
const viewer = EmbedPDF.init({
|
|
26
|
+
type: 'container',
|
|
27
|
+
target: containerEl,
|
|
28
|
+
...config,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (viewer) {
|
|
32
|
+
container = viewer;
|
|
33
|
+
registry = viewer.registry;
|
|
34
|
+
dispatch('init', viewer);
|
|
35
|
+
|
|
36
|
+
// Dispatch ready when registry is available
|
|
37
|
+
viewer.registry.then((reg) => {
|
|
38
|
+
dispatch('ready', reg);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
onDestroy(() => {
|
|
44
|
+
// Cleanup: remove the viewer element
|
|
45
|
+
if (container && containerEl) {
|
|
46
|
+
containerEl.innerHTML = '';
|
|
47
|
+
container = null;
|
|
48
|
+
registry = null;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<div bind:this={containerEl} class={$$props.class} style={$$props.style} />
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type EmbedPdfContainer, type PDFViewerConfig, type PluginRegistry } from '@embedpdf/snippet';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const PDFViewer: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
config?: PDFViewerConfig | undefined;
|
|
18
|
+
container?: (EmbedPdfContainer | null) | undefined;
|
|
19
|
+
registry?: (Promise<PluginRegistry> | null) | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
init: CustomEvent<EmbedPdfContainer>;
|
|
22
|
+
ready: CustomEvent<PluginRegistry>;
|
|
23
|
+
} & {
|
|
24
|
+
[evt: string]: CustomEvent<any>;
|
|
25
|
+
}, {}, {}, string>;
|
|
26
|
+
type PDFViewer = InstanceType<typeof PDFViewer>;
|
|
27
|
+
export default PDFViewer;
|
|
28
|
+
//# sourceMappingURL=PDFViewer.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PDFViewer.svelte.d.ts","sourceRoot":"","sources":["../src/PDFViewer.svelte.ts"],"names":[],"mappings":"AAIA,OAAiB,EACb,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AA2D7B,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,SAAS;;aAdsC,eAAe;iBACR,iBAAiB,GAAG,IAAI;gBAAa,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;;;;;;kBAaV,CAAC;AACpG,KAAK,SAAS,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,CAAC;AAClD,eAAe,SAAS,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG1D,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@embedpdf/svelte-pdf-viewer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Svelte component for embedding PDF documents",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"svelte": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"svelte": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@embedpdf/snippet": "1.0.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@sveltejs/package": "^2.3.0",
|
|
26
|
+
"rimraf": "^5.0.5",
|
|
27
|
+
"svelte": "^5.0.0",
|
|
28
|
+
"typescript": "^5.1.6"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"svelte": ">=4.0.0"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"svelte",
|
|
35
|
+
"pdf",
|
|
36
|
+
"viewer",
|
|
37
|
+
"embed",
|
|
38
|
+
"document"
|
|
39
|
+
],
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/embedpdf/embed-pdf-viewer.git",
|
|
43
|
+
"directory": "viewers/svelte"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"clean": "rimraf dist",
|
|
50
|
+
"build": "pnpm run clean && svelte-package -i src -o dist"
|
|
51
|
+
}
|
|
52
|
+
}
|