Standardize coordinate system to use INCHES
Updated the digital document signing system to use INCHES as the standard unit for annotations and signatures, aligning with GdPicture14's native format. Previously used DevExpress units (1/100 inch) and other formats have been replaced.
- Updated `AnnotationDto` to reflect the new coordinate system.
- Introduced `SignatureDto` for signature positions, deprecating `AnnotationDto`.
- Added conversion formulas for transforming coordinates between INCHES and other systems (DevExpress, PDF Points, PDF.js, etc.).
- Added a unit comparison table and A4 page dimensions in various units.
- Introduced a new read-only PDF.js viewer for envelopes (`/envelope/{EnvelopeKey}`).
These changes improve consistency, simplify conversions, and align with modern tools like PSPDFKit and iText7.
This commit is contained in:
@@ -40,22 +40,60 @@ A digital document signing system. Senders upload PDFs and place signature annot
|
||||
|
||||
---
|
||||
|
||||
## AnnotationDto — Coordinate System
|
||||
## SignatureDto / AnnotationDto — Coordinate System
|
||||
|
||||
**Database Storage Format:** INCHES (GdPicture14 native unit)
|
||||
**Origin:** Top-left corner of page
|
||||
**Axes:** X increases rightward, Y increases downward
|
||||
|
||||
### Source Evidence (VB.NET Legacy Code)
|
||||
|
||||
```vb
|
||||
' From: EnvelopeGenerator.Form/frmFieldEditor.vb
|
||||
' GdPicture14.Annotations.AnnotationStickyNote
|
||||
|
||||
'Breite und Höhe in Inches (4,5*5cm)
|
||||
Private Const SIGNATURE_WIDTH As Single = 1.77 ' 1.77 inches = 4.5cm
|
||||
Private Const SIGNATURE_HEIGHT As Single = 1.96 ' 1.96 inches = 5cm
|
||||
|
||||
Sub LoadAnnotation(pElement As Signature, ...)
|
||||
oAnnotation.Left = CSng(pElement.X) ' Direct assignment ? INCHES
|
||||
oAnnotation.Top = CSng(pElement.Y)
|
||||
oAnnotation.Width = CSng(pElement.Width)
|
||||
oAnnotation.Height = CSng(pElement.Height)
|
||||
End Sub
|
||||
```
|
||||
|
||||
### Conversion Formulas
|
||||
|
||||
```
|
||||
Unit : 1/100 inch (DX units) — DevExpress XtraReports native
|
||||
Origin : Top-left corner of page
|
||||
X : increases rightward
|
||||
Y : increases downward
|
||||
Inches ? DevExpress (DX): x_DX = x_inches * 100.0
|
||||
y_DX = y_inches * 100.0
|
||||
|
||||
A4 in DX units: Width = 827, Height = 1169
|
||||
Inches ? PDF Points: x_pt = x_inches * 72.0
|
||||
y_pt = x_inches * 72.0
|
||||
|
||||
Conversions:
|
||||
PSPDFKit (pt, top-left): xDX = xPsPdf * (100/72)
|
||||
GDPicture (pt, bottom-left): yDX = (pageHeightPt - yGD - elemHeightPt) * (100/72)
|
||||
DX ? PDF points: pt = dx * (72/100)
|
||||
Inches ? PDF.js Canvas: normalize to [0,1], then scale to pixels
|
||||
x_norm = x_inches / pageWidth_inches
|
||||
y_norm = y_inches / pageHeight_inches
|
||||
x_px = x_norm * canvasWidth * scale * dpr
|
||||
y_px = y_norm * canvasHeight * scale * dpr
|
||||
```
|
||||
|
||||
### Unit Comparison Table
|
||||
|
||||
| System | Unit | Origin | Conversion from INCHES |
|
||||
|--------|------|--------|------------------------|
|
||||
| **GdPicture14** (Source) | **Inches** | Top-left | Database format (no conversion) |
|
||||
| DevExpress (LEGACY) | 1/100 inch (DX) | Top-left | `x_DX = x_inches * 100` |
|
||||
| PDF.js (NEW) | Pixels | Top-left | `normalize ? scale` |
|
||||
| PDF Points (iText7) | Points (1/72") | **Bottom-left** | `x_pt = x_inches * 72` + Y-flip |
|
||||
| PSPDFKit (Web) | Points (1/72") | Top-left | `x_pt = x_inches * 72` |
|
||||
|
||||
**A4 Page Dimensions:**
|
||||
- Width: 8.27 inches = 595 points = 827 DX units
|
||||
- Height: 11.69 inches = 842 points = 1169 DX units
|
||||
|
||||
---
|
||||
|
||||
## EnvelopeViewer (NEW) — PDF.js Read-Only Viewer
|
||||
|
||||
Reference in New Issue
Block a user