@june24/expo-pdf-reader 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/ios/ExpoPdfReaderView.swift +35 -5
- package/package.json +1 -1
|
@@ -397,9 +397,27 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
397
397
|
guard let page = document.page(at: i) else { continue }
|
|
398
398
|
for annotation in page.annotations {
|
|
399
399
|
if annotation.type == "Ink" {
|
|
400
|
-
|
|
400
|
+
// Extract points from all paths in the annotation
|
|
401
|
+
var allStrokes: [[[String: Double]]] = []
|
|
401
402
|
|
|
402
|
-
|
|
403
|
+
if let paths = annotation.paths {
|
|
404
|
+
for path in paths {
|
|
405
|
+
var points: [[String: Double]] = []
|
|
406
|
+
|
|
407
|
+
// Extract points from CGPath
|
|
408
|
+
path.cgPath.applyWithBlock { element in
|
|
409
|
+
let pt = element.pointee.points[0]
|
|
410
|
+
points.append([
|
|
411
|
+
"x": Double(pt.x),
|
|
412
|
+
"y": Double(pt.y)
|
|
413
|
+
])
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if !points.isEmpty {
|
|
417
|
+
allStrokes.append(points)
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
403
421
|
|
|
404
422
|
var colorHex = "#000000"
|
|
405
423
|
let strokeColor = annotation.color
|
|
@@ -416,7 +434,7 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
416
434
|
"type": type,
|
|
417
435
|
"color": colorHex,
|
|
418
436
|
"page": i,
|
|
419
|
-
"points":
|
|
437
|
+
"points": allStrokes,
|
|
420
438
|
"width": annotation.border?.lineWidth ?? 10.0
|
|
421
439
|
])
|
|
422
440
|
} else if annotation.type == "FreeText" {
|
|
@@ -644,12 +662,18 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
644
662
|
print(" Bounds: \(pathBounds)")
|
|
645
663
|
print(" Paths count: \(annotation.paths?.count ?? 0)")
|
|
646
664
|
|
|
665
|
+
// Make sure annotation is visible
|
|
666
|
+
annotation.shouldDisplay = true
|
|
667
|
+
annotation.shouldPrint = true
|
|
668
|
+
|
|
647
669
|
page.addAnnotation(annotation)
|
|
648
670
|
|
|
649
671
|
print(" Total annotations on page: \(page.annotations.count)")
|
|
650
672
|
|
|
651
|
-
// Force PDF view
|
|
673
|
+
// Force comprehensive PDF view update
|
|
674
|
+
pdfView.layoutDocumentView()
|
|
652
675
|
pdfView.setNeedsDisplay()
|
|
676
|
+
pdfView.currentPage?.setNeedsDisplay(pdfView.displayBox)
|
|
653
677
|
}
|
|
654
678
|
else if currentTool == "highlighter" {
|
|
655
679
|
let annotation = PDFAnnotation(bounds: pathBounds, forType: .ink, withProperties: nil)
|
|
@@ -662,12 +686,18 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
662
686
|
print("✅ Adding highlighter annotation to page")
|
|
663
687
|
print(" Bounds: \(pathBounds)")
|
|
664
688
|
|
|
689
|
+
// Make sure annotation is visible
|
|
690
|
+
annotation.shouldDisplay = true
|
|
691
|
+
annotation.shouldPrint = true
|
|
692
|
+
|
|
665
693
|
page.addAnnotation(annotation)
|
|
666
694
|
|
|
667
695
|
print(" Total annotations on page: \(page.annotations.count)")
|
|
668
696
|
|
|
669
|
-
// Force PDF view
|
|
697
|
+
// Force comprehensive PDF view update
|
|
698
|
+
pdfView.layoutDocumentView()
|
|
670
699
|
pdfView.setNeedsDisplay()
|
|
700
|
+
pdfView.currentPage?.setNeedsDisplay(pdfView.displayBox)
|
|
671
701
|
}
|
|
672
702
|
|
|
673
703
|
// Clear redo stack when new annotation is added
|
package/package.json
CHANGED