@monime/pdfio 0.1.5 → 0.1.6

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
@@ -1,39 +1,92 @@
1
1
  # `@monime/pdfio`
2
2
 
3
- A simple custom PDF viewer for React, built with Vite and managed with `pnpm`.
3
+ A lightweight, zero-config PDF viewer component for React. Built on top of `pdfjs-dist`, styled with Tailwind CSS v4, and bundled with Vite.
4
4
 
5
5
  ## Features
6
6
 
7
- - Preview PDFs from a remote URL, `File`, `Blob`, or `Uint8Array`
8
- - Built-in previous/next page controls
9
- - Zoom in, zoom out, and reset actions
10
- - Vite-based demo app for local development
11
- - Library build ready to publish to npm
7
+ - Render PDFs from a URL, `ArrayBuffer`, or `URL` object
8
+ - Page navigation with prev / next controls and a click-to-jump page input
9
+ - Zoom in, zoom out, preset zoom levels, fit-to-width, and fit-to-height
10
+ - Fullscreen mode
11
+ - **Watermark overlay** tiled diagonal text on every page, fully customisable
12
+ - HiDPI / Retina-aware canvas rendering
13
+ - ESM + CJS dual build, ships TypeScript declarations
12
14
 
13
15
  ## Install
14
16
 
15
17
  ```bash
16
- pnpm add @monime/pdfio react react-dom
18
+ # npm
19
+ npm install @monime/pdfio
20
+
21
+ # pnpm
22
+ pnpm add @monime/pdfio
23
+
24
+ # yarn
25
+ yarn add @monime/pdfio
17
26
  ```
18
27
 
19
- This package also relies on `pdfjs-dist`, which is installed automatically as a dependency.
28
+ Peer dependencies: `react >=18` and `react-dom >=18` (or v19).
29
+ `pdfjs-dist` is loaded dynamically at runtime — no extra install needed.
20
30
 
21
31
  ## Usage
22
32
 
23
33
  ```tsx
24
- import { PdfViewer } from '@monime/pdfio';
34
+ import { PDFViewer } from '@monime/pdfio';
25
35
  import '@monime/pdfio/style.css';
26
36
 
27
37
  export function Example() {
28
38
  return (
29
- <PdfViewer
30
- file="https://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf"
31
- height={700}
32
- />
39
+ <div style={{ height: '100vh' }}>
40
+ <PDFViewer src="https://example.com/document.pdf" />
41
+ </div>
33
42
  );
34
43
  }
35
44
  ```
36
45
 
46
+ The component fills the height of its container, so give the wrapper a defined height.
47
+
48
+ ## Props
49
+
50
+ | Prop | Type | Default | Description |
51
+ | ----------- | --------------------------- | ----------- | ------------------------------------------------ |
52
+ | `src` | `string \| ArrayBuffer \| URL` | — | PDF source. Omit (or pass `undefined`) to show the empty state. |
53
+ | `watermark` | `string \| WatermarkConfig` | — | Watermark text stamped diagonally across every page. |
54
+
55
+ ## Watermark
56
+
57
+ Pass a plain string for a quick stamp, or a `WatermarkConfig` object for full control.
58
+
59
+ ```tsx
60
+ {/* Quick string */}
61
+ <PDFViewer src={url} watermark="CONFIDENTIAL" />
62
+
63
+ {/* Full config */}
64
+ <PDFViewer
65
+ src={url}
66
+ watermark={{
67
+ text: "DRAFT",
68
+ color: "rgba(220, 38, 38, 0.15)",
69
+ fontSize: 32,
70
+ angle: -40,
71
+ gap: 60,
72
+ fontFamily: "Georgia, serif",
73
+ fontWeight: "700",
74
+ }}
75
+ />
76
+ ```
77
+
78
+ ### `WatermarkConfig`
79
+
80
+ | Property | Type | Default | Description |
81
+ | ------------ | -------- | ------------------------ | ---------------------------------------------------- |
82
+ | `text` | `string` | — | The text to repeat across each page. |
83
+ | `color` | `string` | `"rgba(0,0,0,0.12)"` | Any valid CSS color string. |
84
+ | `fontSize` | `number` | `28` | Base font size in px (scales automatically with zoom). |
85
+ | `angle` | `number` | `-35` | Rotation angle in degrees. |
86
+ | `gap` | `number` | `80` | Horizontal spacing between repeated labels in px. |
87
+ | `fontFamily` | `string` | `"sans-serif"` | CSS font-family value. |
88
+ | `fontWeight` | `string` | `"600"` | CSS font-weight value. |
89
+
37
90
  ## Local development
38
91
 
39
92
  ```bash
@@ -41,30 +94,32 @@ pnpm install
41
94
  pnpm dev
42
95
  ```
43
96
 
44
- ## Build the package
97
+ ## Build the library
45
98
 
46
99
  ```bash
47
100
  pnpm build
48
101
  ```
49
102
 
50
- This generates:
103
+ Output in `dist/`:
51
104
 
52
- - `dist/index.js`
53
- - `dist/index.cjs`
54
- - `dist/index.d.ts`
55
- - `dist/style.css`
105
+ | File | Format |
106
+ | ----------------- | ------ |
107
+ | `index.js` | ESM |
108
+ | `index.cjs` | CJS |
109
+ | `index.d.ts` | Types |
110
+ | `style.css` | CSS |
56
111
 
57
- ## Demo build
112
+ ## Build the demo app
58
113
 
59
114
  ```bash
60
115
  pnpm build:demo
61
116
  ```
62
117
 
63
- This writes the standalone demo app to `demo-dist/`.
118
+ Writes a standalone demo to `demo-dist/`.
64
119
 
65
120
  ## Publish
66
121
 
67
- Update the package version, then publish with:
122
+ Bump the version in `package.json`, then:
68
123
 
69
124
  ```bash
70
125
  pnpm publish --access public
@@ -0,0 +1,19 @@
1
+ type IconProps = {
2
+ size?: number;
3
+ className?: string;
4
+ };
5
+ export declare const Icons: {
6
+ ChevronLeft: ({ size, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
7
+ ChevronRight: ({ size, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
8
+ ZoomIn: ({ size, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
9
+ ZoomOut: ({ size, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
10
+ Maximize: ({ size, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
11
+ Minimize: ({ size, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
12
+ ArrowLeftRight: ({ size, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
13
+ ArrowUpDown: ({ size, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
14
+ Loader2: ({ size, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
15
+ AlertTriangle: ({ size, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
16
+ FileText: ({ size, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
17
+ };
18
+ export {};
19
+ //# sourceMappingURL=Icons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Icons.d.ts","sourceRoot":"","sources":["../src/lib/Icons.tsx"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAuBF,eAAO,MAAM,KAAK;uCACwB,SAAS;wCAKR,SAAS;kCAKf,SAAS;mCAQR,SAAS;oCAOR,SAAS;oCAQT,SAAS;0CAQH,SAAS;uCAQZ,SAAS;mCAQb,SAAS;yCAKH,SAAS;oCAOd,SAAS;CAS/C,CAAC"}
@@ -1,5 +1,22 @@
1
+ export interface WatermarkConfig {
2
+ text: string;
3
+ /** CSS color string — default: "rgba(0,0,0,0.12)" */
4
+ color?: string;
5
+ /** Font size in px at scale=1 — default: 28 */
6
+ fontSize?: number;
7
+ /** Rotation angle in degrees — default: -35 */
8
+ angle?: number;
9
+ /** Horizontal gap between repeated labels in px — default: 80 */
10
+ gap?: number;
11
+ /** Font family — default: "sans-serif" */
12
+ fontFamily?: string;
13
+ /** Font weight — default: "600" */
14
+ fontWeight?: string;
15
+ }
1
16
  export interface PDFViewerProps {
2
- src?: string;
17
+ src?: string | ArrayBuffer | URL;
18
+ /** Pass a string for a quick watermark, or a WatermarkConfig for full control. */
19
+ watermark?: string | WatermarkConfig;
3
20
  }
4
- export declare function PDFViewer({ src, }: PDFViewerProps): import("react/jsx-runtime").JSX.Element;
21
+ export declare function PDFViewer({ src, watermark }: PDFViewerProps): import("react/jsx-runtime").JSX.Element;
5
22
  //# sourceMappingURL=PdfViewer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PdfViewer.d.ts","sourceRoot":"","sources":["../src/lib/PdfViewer.tsx"],"names":[],"mappings":"AAkCA,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAID,wBAAgB,SAAS,CAAC,EACxB,GAA8C,GAC/C,EAAE,cAAc,2CAobhB"}
1
+ {"version":3,"file":"PdfViewer.d.ts","sourceRoot":"","sources":["../src/lib/PdfViewer.tsx"],"names":[],"mappings":"AAsBA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,GAAG,CAAC;IACjC,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;CACtC;AA0ED,wBAAgB,SAAS,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,cAAc,2CA6d3D"}