pdf-diff-viewer 1.3.0 → 1.3.3
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 +57 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,17 @@ A browser-based PDF comparison library with intelligent visual diff highlighting
|
|
|
5
5
|

|
|
6
6
|

|
|
7
7
|
|
|
8
|
+
## 🌐 Live Demo
|
|
9
|
+
|
|
10
|
+
[Check out the live demo here!](https://a-subhaneel.github.io/pdf-diff-viewer/example/)
|
|
11
|
+
|
|
12
|
+
You can instantly try the PDF Diff Viewer in your browser.
|
|
13
|
+
|
|
14
|
+
## 📸 Screenshots
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+

|
|
18
|
+
|
|
8
19
|
## ✨ Features
|
|
9
20
|
|
|
10
21
|
- **🌐 Browser-Based** - Runs entirely in the browser using PDF.js
|
|
@@ -136,15 +147,17 @@ new PDFDiffViewer(container, options)
|
|
|
136
147
|
- `colorTolerance` (number) - Color difference threshold, default: 120
|
|
137
148
|
- `minHighlightArea` (number) - Min area to highlight in pixels, default: 60
|
|
138
149
|
- `minWordSize` (number) - Min word box size in pixels, default: 8
|
|
139
|
-
- `highlightAlpha` (number) - Highlight transparency, default: 0.32
|
|
150
|
+
- `highlightAlpha` (number) - Highlight transparency (0-1), default: 0.32
|
|
151
|
+
- **`highlightColorA` (string)** - Hex color for Document A highlights, default: '#FF1744' (red)
|
|
152
|
+
- **`highlightColorB` (string)** - Hex color for Document B highlights, default: '#2196F3' (blue)
|
|
153
|
+
- **`backgroundFillColor` (string)** - Canvas background fill color, default: 'white'
|
|
140
154
|
- `labelA` (string) - Label for first document, default: 'Document A'
|
|
141
155
|
- `labelB` (string) - Label for second document, default: 'Document B'
|
|
142
156
|
- `showPageNumbers` (boolean) - Show page numbers, default: true
|
|
143
157
|
- `cropRegions` (Array) - Regions to crop: `[{ page: 1, x, y, width, height }]`
|
|
144
158
|
- `maskRegions` (Array) - Regions to mask/ignore: `[{ page: 1, x, y, width, height }]`
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
- **`similarityThreshold` (number)** - Minimum text similarity (0-1) for page matching, default: 0.3
|
|
159
|
+
- `alignmentTolerance` (number) - Search range for matching pages (+/- pages), default: 2
|
|
160
|
+
- `similarityThreshold` (number) - Minimum text similarity (0-1) for page matching, default: 0.3
|
|
148
161
|
|
|
149
162
|
### Methods
|
|
150
163
|
|
|
@@ -238,6 +251,41 @@ const viewer = new PDFDiffViewer('#container', {
|
|
|
238
251
|
});
|
|
239
252
|
```
|
|
240
253
|
|
|
254
|
+
### Custom Highlight Colors
|
|
255
|
+
|
|
256
|
+
```javascript
|
|
257
|
+
// Perfect for gray backgrounds (#D9D9D9)
|
|
258
|
+
const viewer = new PDFDiffViewer('#container', {
|
|
259
|
+
highlightColorA: '#FF1744', // Vibrant red for Doc A changes
|
|
260
|
+
highlightColorB: '#2196F3', // Bright blue for Doc B changes
|
|
261
|
+
backgroundFillColor: '#D9D9D9', // Match your PDF background
|
|
262
|
+
highlightAlpha: 0.4 // Adjust transparency
|
|
263
|
+
});
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**Recommended color combinations:**
|
|
267
|
+
|
|
268
|
+
For light backgrounds:
|
|
269
|
+
```javascript
|
|
270
|
+
// Red vs Blue (high contrast)
|
|
271
|
+
{ highlightColorA: '#FF1744', highlightColorB: '#2196F3' }
|
|
272
|
+
|
|
273
|
+
// Purple vs Orange
|
|
274
|
+
{ highlightColorA: '#9C27B0', highlightColorB: '#FF6F00' }
|
|
275
|
+
|
|
276
|
+
// Pink vs Teal
|
|
277
|
+
{ highlightColorA: '#E91E63', highlightColorB: '#00BCD4' }
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
For dark backgrounds:
|
|
281
|
+
```javascript
|
|
282
|
+
// Bright yellow vs Cyan
|
|
283
|
+
{ highlightColorA: '#FFEB3B', highlightColorB: '#00E5FF' }
|
|
284
|
+
|
|
285
|
+
// Lime vs Magenta
|
|
286
|
+
{ highlightColorA: '#CDDC39', highlightColorB: '#E040FB' }
|
|
287
|
+
```
|
|
288
|
+
|
|
241
289
|
### With Crop Regions (Compare Specific Areas)
|
|
242
290
|
|
|
243
291
|
```javascript
|
|
@@ -251,12 +299,12 @@ const viewer = new PDFDiffViewer('#container', {
|
|
|
251
299
|
### With Smart Alignment (Content Reflow Handling)
|
|
252
300
|
|
|
253
301
|
```javascript
|
|
302
|
+
// Smart alignment is now automatic! No configuration needed
|
|
254
303
|
// Handles cases where content shifts across pages
|
|
255
304
|
// (e.g., adding text pushes content to next page)
|
|
256
305
|
const viewer = new PDFDiffViewer('#container', {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
similarityThreshold: 0.3 // Require 30% content similarity
|
|
306
|
+
alignmentTolerance: 2, // Search +/- 2 pages for matches (default)
|
|
307
|
+
similarityThreshold: 0.3 // Require 30% content similarity (default)
|
|
260
308
|
});
|
|
261
309
|
|
|
262
310
|
const results = await viewer.compare(pdfA, pdfB);
|
|
@@ -266,10 +314,10 @@ console.log('Page mappings:', results.pageMapping);
|
|
|
266
314
|
```
|
|
267
315
|
|
|
268
316
|
**How it works:**
|
|
317
|
+
- Automatically detects and handles different page counts
|
|
269
318
|
- Extracts text from all pages in both documents
|
|
270
319
|
- Uses Jaccard similarity to find best-matching pages
|
|
271
|
-
-
|
|
272
|
-
- Shows similarity scores in the UI
|
|
320
|
+
- Shows similarity scores in the results
|
|
273
321
|
|
|
274
322
|
### With Mask Regions (Ignore Dynamic Content)
|
|
275
323
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdf-diff-viewer",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Browser-based PDF comparison tool with visual diff highlighting. Zero system dependencies, pure JavaScript, client-side processing.",
|
|
5
5
|
"main": "src/PDFDiffViewer.js",
|
|
6
6
|
"type": "module",
|