@monime/pdfio 0.1.5 → 0.1.7
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 +77 -22
- package/dist/Icons.d.ts +19 -0
- package/dist/Icons.d.ts.map +1 -0
- package/dist/PdfViewer.d.ts +19 -2
- package/dist/PdfViewer.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +351 -344
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,39 +1,92 @@
|
|
|
1
1
|
# `@monime/pdfio`
|
|
2
2
|
|
|
3
|
-
A
|
|
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
|
-
-
|
|
8
|
-
-
|
|
9
|
-
- Zoom in, zoom out, and
|
|
10
|
-
-
|
|
11
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
34
|
+
import { PDFViewer } from '@monime/pdfio';
|
|
25
35
|
import '@monime/pdfio/style.css';
|
|
26
36
|
|
|
27
37
|
export function Example() {
|
|
28
38
|
return (
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
97
|
+
## Build the library
|
|
45
98
|
|
|
46
99
|
```bash
|
|
47
100
|
pnpm build
|
|
48
101
|
```
|
|
49
102
|
|
|
50
|
-
|
|
103
|
+
Output in `dist/`:
|
|
51
104
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
105
|
+
| File | Format |
|
|
106
|
+
| ----------------- | ------ |
|
|
107
|
+
| `index.js` | ESM |
|
|
108
|
+
| `index.cjs` | CJS |
|
|
109
|
+
| `index.d.ts` | Types |
|
|
110
|
+
| `style.css` | CSS |
|
|
56
111
|
|
|
57
|
-
##
|
|
112
|
+
## Build the demo app
|
|
58
113
|
|
|
59
114
|
```bash
|
|
60
115
|
pnpm build:demo
|
|
61
116
|
```
|
|
62
117
|
|
|
63
|
-
|
|
118
|
+
Writes a standalone demo to `demo-dist/`.
|
|
64
119
|
|
|
65
120
|
## Publish
|
|
66
121
|
|
|
67
|
-
|
|
122
|
+
Bump the version in `package.json`, then:
|
|
68
123
|
|
|
69
124
|
```bash
|
|
70
125
|
pnpm publish --access public
|
package/dist/Icons.d.ts
ADDED
|
@@ -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"}
|
package/dist/PdfViewer.d.ts
CHANGED
|
@@ -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
|
package/dist/PdfViewer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PdfViewer.d.ts","sourceRoot":"","sources":["../src/lib/PdfViewer.tsx"],"names":[],"mappings":"
|
|
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"}
|