@june24/expo-pdf-reader 0.1.9 → 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.
@@ -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": annotation.border?.lineWidth ?? 10.0
441
+ "width": extractedWidth
439
442
  ])
440
443
  } else if annotation.type == "FreeText" {
441
444
  var colorHex = "#000000"
@@ -464,7 +467,11 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
464
467
  // Clear all existing annotations first
465
468
  for i in 0..<document.pageCount {
466
469
  guard let page = document.page(at: i) else { continue }
467
- page.annotations.removeAll()
470
+ // Remove annotations one by one (annotations is read-only)
471
+ let annotationsToRemove = page.annotations
472
+ for annotation in annotationsToRemove {
473
+ page.removeAnnotation(annotation)
474
+ }
468
475
  }
469
476
 
470
477
  // Clear undo/redo stacks when setting annotations
@@ -512,6 +519,18 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
512
519
  let annotation = PDFAnnotation(bounds: bounds, forType: .ink, withProperties: nil)
513
520
  annotation.add(path)
514
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
+
515
534
  if type == "highlighter" {
516
535
  annotation.color = color.withAlphaComponent(0.3)
517
536
  } else {
@@ -531,7 +550,8 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
531
550
  }
532
551
 
533
552
  @objc func handlePan(_ gesture: UIPanGestureRecognizer) {
534
- guard let page = pdfView.currentPage else { return }
553
+ guard let page = pdfView.currentPage,
554
+ let document = pdfView.document else { return }
535
555
  let location = gesture.location(in: pdfView)
536
556
  let convertedPoint = pdfView.convert(location, to: page)
537
557
  let viewLocation = location // Keep view coordinates for drawing layer
@@ -673,18 +693,23 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
673
693
  print("✅ Adding pen annotation to page")
674
694
  print(" Bounds: \(pathBounds)")
675
695
  print(" Paths count: \(annotation.paths?.count ?? 0)")
696
+ print(" Stroke width: \(currentStrokeWidth)")
697
+ print(" Border lineWidth: \(annotation.border?.lineWidth ?? 0)")
676
698
 
677
699
  // Make sure annotation is visible
678
700
  annotation.shouldDisplay = true
679
701
  annotation.shouldPrint = true
680
-
681
702
  page.addAnnotation(annotation)
682
703
 
683
704
  print(" Total annotations on page: \(page.annotations.count)")
705
+ print(" Page index: \(document.index(for: page))")
684
706
 
685
- // Force comprehensive PDF view update
707
+ // Force comprehensive PDF view update immediately
686
708
  pdfView.layoutDocumentView()
687
709
  pdfView.setNeedsDisplay(pdfView.bounds)
710
+
711
+ // Also force the specific page to redraw
712
+ pdfView.go(to: page)
688
713
  }
689
714
  else if currentTool == "highlighter" {
690
715
  let annotation = PDFAnnotation(bounds: pathBounds, forType: .ink, withProperties: nil)
@@ -696,6 +721,8 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
696
721
 
697
722
  print("✅ Adding highlighter annotation to page")
698
723
  print(" Bounds: \(pathBounds)")
724
+ print(" Stroke width: \(currentStrokeWidth)")
725
+ print(" Border lineWidth: \(annotation.border?.lineWidth ?? 0)")
699
726
 
700
727
  // Make sure annotation is visible
701
728
  annotation.shouldDisplay = true
@@ -704,10 +731,14 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
704
731
  page.addAnnotation(annotation)
705
732
 
706
733
  print(" Total annotations on page: \(page.annotations.count)")
734
+ print(" Page index: \(document.index(for: page))")
707
735
 
708
- // Force comprehensive PDF view update
736
+ // Force comprehensive PDF view update immediately
709
737
  pdfView.layoutDocumentView()
710
738
  pdfView.setNeedsDisplay(pdfView.bounds)
739
+
740
+ // Also force the specific page to redraw
741
+ pdfView.go(to: page)
711
742
  }
712
743
 
713
744
  // Clear redo stack when new annotation is added
@@ -716,6 +747,18 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
716
747
  currentPath = nil
717
748
  currentAnnotation = nil
718
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
+
719
762
  // Emit event
720
763
  let allAnnotations = getAnnotations()
721
764
  print("📤 Emitting annotation change event: \(allAnnotations.count) annotations")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@june24/expo-pdf-reader",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "A PDF reader for Expo apps with annotation and zoom controls",
5
5
  "homepage": "git@gitlab.com:june_241/expo-pdf-reader.git",
6
6
  "main": "build/index.js",