@june24/expo-pdf-reader 0.1.10 → 0.1.11
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/ios/ExpoPdfReaderView.swift +44 -5
- package/package.json +1 -1
|
@@ -430,12 +430,15 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
430
430
|
type = "highlighter"
|
|
431
431
|
}
|
|
432
432
|
|
|
433
|
+
let extractedWidth = annotation.border?.lineWidth ?? 10.0
|
|
434
|
+
print("📏 Extracting annotation width: \(extractedWidth)")
|
|
435
|
+
|
|
433
436
|
annotationsData.append([
|
|
434
437
|
"type": type,
|
|
435
438
|
"color": colorHex,
|
|
436
439
|
"page": i,
|
|
437
440
|
"points": allStrokes,
|
|
438
|
-
"width":
|
|
441
|
+
"width": extractedWidth
|
|
439
442
|
])
|
|
440
443
|
} else if annotation.type == "FreeText" {
|
|
441
444
|
var colorHex = "#000000"
|
|
@@ -516,6 +519,18 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
516
519
|
let annotation = PDFAnnotation(bounds: bounds, forType: .ink, withProperties: nil)
|
|
517
520
|
annotation.add(path)
|
|
518
521
|
|
|
522
|
+
// Set stroke width from data
|
|
523
|
+
let border = PDFBorder()
|
|
524
|
+
if let width = data["width"] as? Double {
|
|
525
|
+
border.lineWidth = CGFloat(width)
|
|
526
|
+
print("📏 Applying annotation width: \(width) for type: \(type)")
|
|
527
|
+
} else {
|
|
528
|
+
// Default width based on type
|
|
529
|
+
border.lineWidth = type == "highlighter" ? 30.0 : 10.0
|
|
530
|
+
print("📏 Using default width: \(border.lineWidth) for type: \(type)")
|
|
531
|
+
}
|
|
532
|
+
annotation.border = border
|
|
533
|
+
|
|
519
534
|
if type == "highlighter" {
|
|
520
535
|
annotation.color = color.withAlphaComponent(0.3)
|
|
521
536
|
} else {
|
|
@@ -535,7 +550,8 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
535
550
|
}
|
|
536
551
|
|
|
537
552
|
@objc func handlePan(_ gesture: UIPanGestureRecognizer) {
|
|
538
|
-
guard let page = pdfView.currentPage
|
|
553
|
+
guard let page = pdfView.currentPage,
|
|
554
|
+
let document = pdfView.document else { return }
|
|
539
555
|
let location = gesture.location(in: pdfView)
|
|
540
556
|
let convertedPoint = pdfView.convert(location, to: page)
|
|
541
557
|
let viewLocation = location // Keep view coordinates for drawing layer
|
|
@@ -677,18 +693,23 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
677
693
|
print("✅ Adding pen annotation to page")
|
|
678
694
|
print(" Bounds: \(pathBounds)")
|
|
679
695
|
print(" Paths count: \(annotation.paths?.count ?? 0)")
|
|
696
|
+
print(" Stroke width: \(currentStrokeWidth)")
|
|
697
|
+
print(" Border lineWidth: \(annotation.border?.lineWidth ?? 0)")
|
|
680
698
|
|
|
681
699
|
// Make sure annotation is visible
|
|
682
700
|
annotation.shouldDisplay = true
|
|
683
701
|
annotation.shouldPrint = true
|
|
684
|
-
|
|
685
702
|
page.addAnnotation(annotation)
|
|
686
703
|
|
|
687
704
|
print(" Total annotations on page: \(page.annotations.count)")
|
|
705
|
+
print(" Page index: \(document.index(for: page))")
|
|
688
706
|
|
|
689
|
-
// Force comprehensive PDF view update
|
|
707
|
+
// Force comprehensive PDF view update immediately
|
|
690
708
|
pdfView.layoutDocumentView()
|
|
691
709
|
pdfView.setNeedsDisplay(pdfView.bounds)
|
|
710
|
+
|
|
711
|
+
// Also force the specific page to redraw
|
|
712
|
+
pdfView.go(to: page)
|
|
692
713
|
}
|
|
693
714
|
else if currentTool == "highlighter" {
|
|
694
715
|
let annotation = PDFAnnotation(bounds: pathBounds, forType: .ink, withProperties: nil)
|
|
@@ -700,6 +721,8 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
700
721
|
|
|
701
722
|
print("✅ Adding highlighter annotation to page")
|
|
702
723
|
print(" Bounds: \(pathBounds)")
|
|
724
|
+
print(" Stroke width: \(currentStrokeWidth)")
|
|
725
|
+
print(" Border lineWidth: \(annotation.border?.lineWidth ?? 0)")
|
|
703
726
|
|
|
704
727
|
// Make sure annotation is visible
|
|
705
728
|
annotation.shouldDisplay = true
|
|
@@ -708,10 +731,14 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
708
731
|
page.addAnnotation(annotation)
|
|
709
732
|
|
|
710
733
|
print(" Total annotations on page: \(page.annotations.count)")
|
|
734
|
+
print(" Page index: \(document.index(for: page))")
|
|
711
735
|
|
|
712
|
-
// Force comprehensive PDF view update
|
|
736
|
+
// Force comprehensive PDF view update immediately
|
|
713
737
|
pdfView.layoutDocumentView()
|
|
714
738
|
pdfView.setNeedsDisplay(pdfView.bounds)
|
|
739
|
+
|
|
740
|
+
// Also force the specific page to redraw
|
|
741
|
+
pdfView.go(to: page)
|
|
715
742
|
}
|
|
716
743
|
|
|
717
744
|
// Clear redo stack when new annotation is added
|
|
@@ -720,6 +747,18 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
720
747
|
currentPath = nil
|
|
721
748
|
currentAnnotation = nil
|
|
722
749
|
|
|
750
|
+
// Force PDF view to refresh again after annotation is added
|
|
751
|
+
DispatchQueue.main.async {
|
|
752
|
+
self.pdfView.layoutDocumentView()
|
|
753
|
+
self.pdfView.setNeedsDisplay(self.pdfView.bounds)
|
|
754
|
+
|
|
755
|
+
// Also refresh the current page specifically
|
|
756
|
+
if let currentPage = self.pdfView.currentPage {
|
|
757
|
+
// Force page to redraw
|
|
758
|
+
self.pdfView.go(to: currentPage)
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
723
762
|
// Emit event
|
|
724
763
|
let allAnnotations = getAnnotations()
|
|
725
764
|
print("📤 Emitting annotation change event: \(allAnnotations.count) annotations")
|
package/package.json
CHANGED