@june24/expo-pdf-reader 0.1.4 → 0.1.6

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.
@@ -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
- var points: [[String: Double]] = []
400
+ // Extract points from all paths in the annotation
401
+ var allStrokes: [[[String: Double]]] = []
401
402
 
402
- // Simplified extraction logic
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": [points],
437
+ "points": allStrokes,
420
438
  "width": annotation.border?.lineWidth ?? 10.0
421
439
  ])
422
440
  } else if annotation.type == "FreeText" {
@@ -584,9 +602,17 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
584
602
  }
585
603
 
586
604
  case .ended:
587
- guard let viewPath = currentPath else { return }
605
+ guard let viewPath = currentPath else {
606
+ print("❌ No path to save!")
607
+ return
608
+ }
588
609
  viewPath.addLine(to: viewLocation) // Complete view path
589
610
 
611
+ print("✏️ Pen gesture ended, saving annotation...")
612
+ print(" Tool: \(currentTool)")
613
+ print(" Color: \(currentColor)")
614
+ print(" Stroke width: \(currentStrokeWidth)")
615
+
590
616
  // Remove drawing layer
591
617
  drawingLayer?.removeFromSuperlayer()
592
618
  drawingLayer = nil
@@ -631,8 +657,15 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
631
657
  border.lineWidth = currentStrokeWidth
632
658
  annotation.border = border
633
659
  annotation.add(pagePathForAnnotation)
660
+
661
+ print("✅ Adding pen annotation to page")
662
+ print(" Bounds: \(pathBounds)")
663
+ print(" Paths count: \(annotation.paths?.count ?? 0)")
664
+
634
665
  page.addAnnotation(annotation)
635
666
 
667
+ print(" Total annotations on page: \(page.annotations.count)")
668
+
636
669
  // Force PDF view to update
637
670
  pdfView.setNeedsDisplay()
638
671
  }
@@ -643,8 +676,14 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
643
676
  border.lineWidth = currentStrokeWidth * 3.0
644
677
  annotation.border = border
645
678
  annotation.add(pagePathForAnnotation)
679
+
680
+ print("✅ Adding highlighter annotation to page")
681
+ print(" Bounds: \(pathBounds)")
682
+
646
683
  page.addAnnotation(annotation)
647
684
 
685
+ print(" Total annotations on page: \(page.annotations.count)")
686
+
648
687
  // Force PDF view to update
649
688
  pdfView.setNeedsDisplay()
650
689
  }
@@ -656,8 +695,10 @@ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
656
695
  currentAnnotation = nil
657
696
 
658
697
  // Emit event
698
+ let allAnnotations = getAnnotations()
699
+ print("📤 Emitting annotation change event: \(allAnnotations.count) annotations")
659
700
  onAnnotationChange([
660
- "annotations": getAnnotations()
701
+ "annotations": allAnnotations
661
702
  ])
662
703
 
663
704
  case .cancelled:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@june24/expo-pdf-reader",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
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",