pdf-diff-viewer 1.3.0 → 1.3.2

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.
Files changed (2) hide show
  1. package/README.md +46 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -136,15 +136,17 @@ new PDFDiffViewer(container, options)
136
136
  - `colorTolerance` (number) - Color difference threshold, default: 120
137
137
  - `minHighlightArea` (number) - Min area to highlight in pixels, default: 60
138
138
  - `minWordSize` (number) - Min word box size in pixels, default: 8
139
- - `highlightAlpha` (number) - Highlight transparency, default: 0.32
139
+ - `highlightAlpha` (number) - Highlight transparency (0-1), default: 0.32
140
+ - **`highlightColorA` (string)** - Hex color for Document A highlights, default: '#FF1744' (red)
141
+ - **`highlightColorB` (string)** - Hex color for Document B highlights, default: '#2196F3' (blue)
142
+ - **`backgroundFillColor` (string)** - Canvas background fill color, default: 'white'
140
143
  - `labelA` (string) - Label for first document, default: 'Document A'
141
144
  - `labelB` (string) - Label for second document, default: 'Document B'
142
145
  - `showPageNumbers` (boolean) - Show page numbers, default: true
143
146
  - `cropRegions` (Array) - Regions to crop: `[{ page: 1, x, y, width, height }]`
144
147
  - `maskRegions` (Array) - Regions to mask/ignore: `[{ page: 1, x, y, width, height }]`
145
- - **`smartAlignment` (boolean)** - Enable text-based page alignment for content reflow, default: true
146
- - **`alignmentTolerance` (number)** - Search range for matching pages (+/- pages), default: 2
147
- - **`similarityThreshold` (number)** - Minimum text similarity (0-1) for page matching, default: 0.3
148
+ - `alignmentTolerance` (number) - Search range for matching pages (+/- pages), default: 2
149
+ - `similarityThreshold` (number) - Minimum text similarity (0-1) for page matching, default: 0.3
148
150
 
149
151
  ### Methods
150
152
 
@@ -238,6 +240,41 @@ const viewer = new PDFDiffViewer('#container', {
238
240
  });
239
241
  ```
240
242
 
243
+ ### Custom Highlight Colors
244
+
245
+ ```javascript
246
+ // Perfect for gray backgrounds (#D9D9D9)
247
+ const viewer = new PDFDiffViewer('#container', {
248
+ highlightColorA: '#FF1744', // Vibrant red for Doc A changes
249
+ highlightColorB: '#2196F3', // Bright blue for Doc B changes
250
+ backgroundFillColor: '#D9D9D9', // Match your PDF background
251
+ highlightAlpha: 0.4 // Adjust transparency
252
+ });
253
+ ```
254
+
255
+ **Recommended color combinations:**
256
+
257
+ For light backgrounds:
258
+ ```javascript
259
+ // Red vs Blue (high contrast)
260
+ { highlightColorA: '#FF1744', highlightColorB: '#2196F3' }
261
+
262
+ // Purple vs Orange
263
+ { highlightColorA: '#9C27B0', highlightColorB: '#FF6F00' }
264
+
265
+ // Pink vs Teal
266
+ { highlightColorA: '#E91E63', highlightColorB: '#00BCD4' }
267
+ ```
268
+
269
+ For dark backgrounds:
270
+ ```javascript
271
+ // Bright yellow vs Cyan
272
+ { highlightColorA: '#FFEB3B', highlightColorB: '#00E5FF' }
273
+
274
+ // Lime vs Magenta
275
+ { highlightColorA: '#CDDC39', highlightColorB: '#E040FB' }
276
+ ```
277
+
241
278
  ### With Crop Regions (Compare Specific Areas)
242
279
 
243
280
  ```javascript
@@ -251,12 +288,12 @@ const viewer = new PDFDiffViewer('#container', {
251
288
  ### With Smart Alignment (Content Reflow Handling)
252
289
 
253
290
  ```javascript
291
+ // Smart alignment is now automatic! No configuration needed
254
292
  // Handles cases where content shifts across pages
255
293
  // (e.g., adding text pushes content to next page)
256
294
  const viewer = new PDFDiffViewer('#container', {
257
- smartAlignment: true, // Enable intelligent page matching
258
- alignmentTolerance: 2, // Search +/- 2 pages for matches
259
- similarityThreshold: 0.3 // Require 30% content similarity
295
+ alignmentTolerance: 2, // Search +/- 2 pages for matches (default)
296
+ similarityThreshold: 0.3 // Require 30% content similarity (default)
260
297
  });
261
298
 
262
299
  const results = await viewer.compare(pdfA, pdfB);
@@ -266,10 +303,10 @@ console.log('Page mappings:', results.pageMapping);
266
303
  ```
267
304
 
268
305
  **How it works:**
306
+ - Automatically detects and handles different page counts
269
307
  - Extracts text from all pages in both documents
270
308
  - Uses Jaccard similarity to find best-matching pages
271
- - Handles different page counts gracefully
272
- - Shows similarity scores in the UI
309
+ - Shows similarity scores in the results
273
310
 
274
311
  ### With Mask Regions (Ignore Dynamic Content)
275
312
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdf-diff-viewer",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
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",