'Resize and Rotate image Annotation added in pdf

Using this Link I have added signature image annotation in PDF file

But i could not find any guide for how to rotate and resize image annotation using the button added on top of annotation image like shown in the image.

What i want to do is:

  1. want to scale/resize signature image(make it small or large by adding this resize button)
  2. want to rotate signature image

Rotate using the annotation top button

For Pinch to zoom i am adding pinch gesture to PDFView but that gesture zoom in / zoom out the main pdf.tried to fix it by below code but not worked.

@objc func scale(sender : UIPinchGestureRecognizer) {
    print("----------Scale----------")
    let touchLocation = sender.location(in: pdfContainerView)
    
    guard let page = pdfContainerView.page(for: touchLocation, nearest: true)
    else {
        return
    }
    let locationOnPage = pdfContainerView.convert(touchLocation, to: page)
    switch sender.state {
    case .began:
        guard let annotation = page.annotation(at: locationOnPage) else {
            return
        }
        
        if annotation.isKind(of: ImageStampAnnotation.self) {
            currentlySelectedAnnotation = annotation
            // to disable pinch gesture for pdfview but it is not working
            pdfContainerView.minScaleFactor = pdfContainerView.scaleFactor
            pdfContainerView.maxScaleFactor = pdfContainerView.scaleFactor
        }
        
    case .changed,.ended:
        guard let annotation = currentlySelectedAnnotation else {
            return
        }
        let initialBounds = annotation.bounds
        //scale annotation
    case .cancelled:
        break
    default:
        break
    }
}

Thanks in advance!!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source