@june24/expo-pdf-reader 0.1.8 → 0.1.10
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 +16 -0
- package/package.json +1 -1
|
@@ -461,6 +461,16 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
461
461
|
func setAnnotations(_ annotations: [[String: Any]]) {
|
|
462
462
|
guard let document = pdfView.document else { return }
|
|
463
463
|
|
|
464
|
+
// Clear all existing annotations first
|
|
465
|
+
for i in 0..<document.pageCount {
|
|
466
|
+
guard let page = document.page(at: i) else { continue }
|
|
467
|
+
// Remove annotations one by one (annotations is read-only)
|
|
468
|
+
let annotationsToRemove = page.annotations
|
|
469
|
+
for annotation in annotationsToRemove {
|
|
470
|
+
page.removeAnnotation(annotation)
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
464
474
|
// Clear undo/redo stacks when setting annotations
|
|
465
475
|
undoStack.removeAll()
|
|
466
476
|
redoStack.removeAll()
|
|
@@ -512,10 +522,16 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
|
|
|
512
522
|
annotation.color = color
|
|
513
523
|
}
|
|
514
524
|
|
|
525
|
+
annotation.shouldDisplay = true
|
|
526
|
+
annotation.shouldPrint = true
|
|
515
527
|
page.addAnnotation(annotation)
|
|
516
528
|
}
|
|
517
529
|
}
|
|
518
530
|
}
|
|
531
|
+
|
|
532
|
+
// Force PDF view to refresh after setting annotations
|
|
533
|
+
pdfView.layoutDocumentView()
|
|
534
|
+
pdfView.setNeedsDisplay(pdfView.bounds)
|
|
519
535
|
}
|
|
520
536
|
|
|
521
537
|
@objc func handlePan(_ gesture: UIPanGestureRecognizer) {
|
package/package.json
CHANGED