12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- //
- // KMPDFAnnotationTextWidgetSub.swift
- // PDF Reader Pro
- //
- // Created by wanjun on 2024/1/31.
- //
- import Cocoa
- class KMPDFAnnotationTextWidgetSub: CPDFTextWidgetAnnotation {
- func transformContext(for page: PDFPage, displayBox box: PDFDisplayBox) {
- var transform = NSAffineTransform()
- // Identity.
- transform = NSAffineTransform()
- // Bounds for page.
- let boxRect = page.bounds(for: box)
- // Handle rotation.
- let rotation = page.rotation
- switch rotation {
- case 90:
- transform.rotate(byDegrees: -90)
- transform.translateX(by: -boxRect.size.width, yBy: 0.0)
- case 180:
- transform.rotate(byDegrees: 180)
- transform.translateX(by: -boxRect.size.width, yBy: -boxRect.size.height)
- case 270:
- transform.rotate(byDegrees: 90)
- transform.translateX(by: 0.0, yBy: -boxRect.size.height)
- default:
- break
- }
- // Origin.
- transform.translateX(by: -boxRect.origin.x, yBy: -boxRect.origin.y)
- // Concatenate.
- transform.concat()
- }
- func keysForValuesToObserveForUndo() -> Set<String> {
- return []
- }
- }
|