svelte-pdf-view 0.1.9 → 0.1.10

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/README.md CHANGED
@@ -112,11 +112,12 @@ The main container component that provides context for toolbar and renderer.
112
112
  </PdfViewer>
113
113
  ```
114
114
 
115
- | Prop | Type | Default | Description |
116
- | ------- | ----------- | -------- | -------------------------------------------------- |
117
- | `src` | `PdfSource` | required | PDF source (URL, ArrayBuffer, Uint8Array, or Blob) |
118
- | `scale` | `number` | `1.0` | Initial zoom scale |
119
- | `class` | `string` | `''` | CSS class for the container |
115
+ | Prop | Type | Default | Description |
116
+ | ------------------ | ----------- | -------- | ---------------------------------------------------------------------- |
117
+ | `src` | `PdfSource` | required | PDF source (URL, ArrayBuffer, Uint8Array, or Blob) |
118
+ | `scale` | `number` | `1.0` | Initial zoom scale |
119
+ | `downloadFilename` | `string` | - | Custom filename for PDF download (default: from URL or 'document.pdf') |
120
+ | `class` | `string` | `''` | CSS class for the container |
120
121
 
121
122
  ### `<PdfToolbar>`
122
123
 
@@ -18,13 +18,21 @@
18
18
  src: PdfSource;
19
19
  /** Initial scale (default: 1.0) */
20
20
  scale?: number;
21
+ /** Custom filename for PDF download (default: extracted from URL or 'document.pdf') */
22
+ downloadFilename?: string;
21
23
  /** CSS class for the container */
22
24
  class?: string;
23
25
  /** Children (toolbar and renderer) */
24
26
  children?: Snippet;
25
27
  }
26
28
 
27
- let { src, scale: initialScale = 1.0, class: className = '', children }: Props = $props();
29
+ let {
30
+ src,
31
+ scale: initialScale = 1.0,
32
+ downloadFilename,
33
+ class: className = '',
34
+ children
35
+ }: Props = $props();
28
36
 
29
37
  // Reactive state that will be shared via context
30
38
  let state = $state<PdfViewerState>({
@@ -44,9 +52,10 @@
44
52
  let rendererActions: PdfViewerActions | null = null;
45
53
 
46
54
  // Download helper function
47
- function downloadPdf(filename?: string) {
55
+ function downloadPdf(filenameOverride?: string) {
48
56
  const downloadName =
49
- filename ||
57
+ filenameOverride ||
58
+ downloadFilename ||
50
59
  (typeof src === 'string' ? src.split('/').pop() : 'document.pdf') ||
51
60
  'document.pdf';
52
61
 
@@ -7,6 +7,8 @@ interface Props {
7
7
  src: PdfSource;
8
8
  /** Initial scale (default: 1.0) */
9
9
  scale?: number;
10
+ /** Custom filename for PDF download (default: extracted from URL or 'document.pdf') */
11
+ downloadFilename?: string;
10
12
  /** CSS class for the container */
11
13
  class?: string;
12
14
  /** Children (toolbar and renderer) */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-pdf-view",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "A modern, modular PDF viewer component for Svelte 5. Built on PDF.js with TypeScript support",
5
5
  "author": "Louis Li",
6
6
  "license": "Apache-2.0",