Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified CHANGELOG.md
100644 → 100755
Empty file.
Empty file modified Example/ISSUE_TEMPLATE.md
100644 → 100755
Empty file.
Empty file modified Example/Podfile
100644 → 100755
Empty file.
Empty file modified Example/Podfile.lock
100644 → 100755
Empty file.
Empty file modified Example/Pods/Local Podspecs/UXMPDFKit.podspec.json
100644 → 100755
Empty file.
Empty file modified Example/Pods/Manifest.lock
100644 → 100755
Empty file.
27 changes: 24 additions & 3 deletions Example/Pods/Pods.xcodeproj/project.pbxproj
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
2 changes: 1 addition & 1 deletion Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/UXMPDFKit.xcscheme
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified Example/Pods/Target Support Files/UXMPDFKit/Info.plist
100644 → 100755
Empty file.
Empty file.
Empty file modified Example/Pods/Target Support Files/UXMPDFKit/UXMPDFKit-dummy.m
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified Example/Pods/Target Support Files/UXMPDFKit/UXMPDFKit.modulemap
100644 → 100755
Empty file.
Empty file modified Example/Pods/Target Support Files/UXMPDFKit/UXMPDFKit.xcconfig
100644 → 100755
Empty file.
22 changes: 19 additions & 3 deletions Example/UXMPDFKit.xcodeproj/project.pbxproj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
Expand Down Expand Up @@ -294,14 +294,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -342,14 +350,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -399,7 +415,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.uxmstudio.uxmpdfit;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -428,7 +444,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.uxmstudio.uxmpdfit;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion Example/UXMPDFKit.xcodeproj/xcshareddata/xcschemes/UXMPDFKit-Example.xcscheme
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Empty file modified Example/UXMPDFKit.xcworkspace/contents.xcworkspacedata
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Example/UXMPDFKit/AppDelegate.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

let dirPaths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
print("App Path: \(dirPaths)")
Expand Down
Empty file modified Example/UXMPDFKit/Base.lproj/LaunchScreen.xib
100644 → 100755
Empty file.
Empty file modified Example/UXMPDFKit/Base.lproj/Main.storyboard
100644 → 100755
Empty file.
Empty file modified Example/UXMPDFKit/ExampleViewController.swift
100644 → 100755
Empty file.
Empty file modified Example/UXMPDFKit/Info.plist
100644 → 100755
Empty file.
Empty file modified Example/UXMPDFKit/ViewController.swift
100644 → 100755
Empty file.
Empty file modified Example/UXMPDFKit/sample.pdf
100644 → 100755
Empty file.
Empty file modified Example/UXMPDFKit/sample3.pdf
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified Package.swift
100644 → 100755
Empty file.
Empty file modified Pod/Classes/.gitkeep
100644 → 100755
Empty file.
Empty file modified Pod/Classes/Annotations/PDFAnnotation.swift
100644 → 100755
Empty file.
32 changes: 25 additions & 7 deletions Pod/Classes/Annotations/PDFAnnotationController.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ open class PDFAnnotationController: UIViewController {
var document: PDFDocument!

/// Store containing all annotations for document
var annotations = PDFAnnotationStore()
private (set) open var annotations = PDFAnnotationStore()

/// References to pages within view
var allPages = [PDFPageContentView]()
Expand Down Expand Up @@ -119,7 +119,8 @@ open class PDFAnnotationController: UIViewController {
view.isOpaque = false
view.backgroundColor = UIColor.clear

self.loadButtons(for: self.annotationTypes)
loadButtons(for: self.annotationTypes)
undoButton.isEnabled = (annotations.annotations.count > 0)
}

//MARK: - Annotation handling
Expand All @@ -136,7 +137,7 @@ open class PDFAnnotationController: UIViewController {
for annotation in annotationsForPage {
let view = annotation.mutableView()
contentView.contentView.addSubview(view)
contentView.contentView.bringSubview(toFront: view)
contentView.contentView.bringSubviewToFront(view)
}
}

Expand All @@ -145,13 +146,16 @@ open class PDFAnnotationController: UIViewController {
annotationType = type

view.isUserInteractionEnabled = annotationType != nil
undoButton.isEnabled = (annotationType != nil || annotations.annotations.count > 0)
}

open func finishAnnotation() {

annotationType = .none
addCurrentAnnotationToStore()

view.isUserInteractionEnabled = false
undoButton.isEnabled = (annotations.annotations.count > 0)
}

//MARK: - Bar button actions
Expand All @@ -176,9 +180,15 @@ open class PDFAnnotationController: UIViewController {
}

@IBAction func selectedUndo(_ button: PDFBarButton) {
//keep track of what kind of annotation we're adding
let currentAnnotationType = annotationType

//finish and undo it
finishAnnotation()
undo()

//then start a new annotation of the same type
startAnnotation(currentAnnotationType)
}

func select(annotation: PDFAnnotation?) {
Expand All @@ -188,7 +198,7 @@ open class PDFAnnotationController: UIViewController {
}

func loadButtons(for annotations: [PDFAnnotation.Type]) {
self.buttons = self.annotationTypes.flatMap {
self.buttons = self.annotationTypes.compactMap {

if let annotation = $0 as? PDFAnnotationButtonable.Type {
return PDFAnnotationBarButton(
Expand Down Expand Up @@ -231,7 +241,13 @@ open class PDFAnnotationController: UIViewController {

//MARK: - Touches methods to pass to annotation
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let touch = touches.first else { return }
// We only allow one-finger touches to start annotations, as otherwise
// when you are pen-editing then try to zoom, one of your fingers will draw instead of zooming
// This is a HACK, as IDEALLY the two-finger pinch would zoom while still in
// annotation editing mode, but for the life of me I could not get that to go, forwarding
// events/touches to pretty much anything.
guard let touch = touches.first, event?.allTouches?.count == 1
else { return }

let page = annotationDelegate?.annotationWillStart(touch: touch)

Expand All @@ -252,14 +268,16 @@ open class PDFAnnotationController: UIViewController {


open override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let touch = touches.first else { return }
guard let touch = touches.first, event?.allTouches?.count == 1
else { return }
let point = touch.location(in: pageView)

currentAnnotation?.touchMoved(touch, point: point)
}

open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let touch = touches.first else { return }
guard let touch = touches.first, event?.allTouches?.count == 1
else { return }
let point = touch.location(in: pageView)

currentAnnotation?.touchEnded(touch, point: point)
Expand Down
2 changes: 1 addition & 1 deletion Pod/Classes/Annotations/PDFAnnotationStore.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public protocol PDFAnnotationStoreDelegate {

open class PDFAnnotationStore: NSObject, NSCoding {

var annotations: [PDFAnnotation] = []
private (set) open var annotations: [PDFAnnotation] = []
var delegate: PDFAnnotationStoreDelegate?


Expand Down
1 change: 1 addition & 0 deletions Pod/Classes/Annotations/PDFPathAnnotation.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ open class PDFPathAnnotation: NSObject, NSCoding {

func drawRect(_ frame: CGRect, point: CGPoint = CGPoint.zero) {
self.incrementalImage?.draw(at: point)
self.path.lineWidth = self.lineWidth
self.color.setStroke()
self.path.stroke()
}
Expand Down
23 changes: 17 additions & 6 deletions Pod/Classes/Annotations/PDFTextAnnotation.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ extension PDFTextAnnotation: PDFAnnotation {
paragraphStyle.alignment = NSTextAlignment.left

let attributes: [String:AnyObject] = [
NSFontAttributeName: font,
NSForegroundColorAttributeName: UIColor.black,
NSParagraphStyleAttributeName: paragraphStyle
convertFromNSAttributedStringKey(NSAttributedString.Key.font): font,
convertFromNSAttributedStringKey(NSAttributedString.Key.foregroundColor): UIColor.black,
convertFromNSAttributedStringKey(NSAttributedString.Key.paragraphStyle): paragraphStyle
]

let size = nsText.size(attributes: attributes)
let size = nsText.size(withAttributes: convertToOptionalNSAttributedStringKeyDictionary(attributes))
let textRect = CGRect(origin: rect.origin, size: size)

nsText.draw(in: textRect, withAttributes: attributes)
nsText.draw(in: textRect, withAttributes: convertToOptionalNSAttributedStringKeyDictionary(attributes))

UIGraphicsPopContext()
}
Expand Down Expand Up @@ -209,7 +209,7 @@ class PDFTextAnnotationView: ResizableView, PDFAnnotationView {
self.addSubview(textView)
}

func menuActionEdit(_ sender: Any!) {
@objc func menuActionEdit(_ sender: Any!) {
self.delegate?.resizableViewDidSelectAction(view: self, action: "edit")

self.isLocked = true
Expand All @@ -225,3 +225,14 @@ class PDFTextAnnotationView: ResizableView, PDFAnnotationView {
return super.canPerformAction(action, withSender: sender)
}
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromNSAttributedStringKey(_ input: NSAttributedString.Key) -> String {
return input.rawValue
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToOptionalNSAttributedStringKeyDictionary(_ input: [String: Any]?) -> [NSAttributedString.Key: Any]? {
guard let input = input else { return nil }
return Dictionary(uniqueKeysWithValues: input.map { key, value in (NSAttributedString.Key(rawValue: key), value)})
}
4 changes: 2 additions & 2 deletions Pod/Classes/Extensions/CGPoint.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ extension CGPoint {
func rect(from point: CGPoint) -> CGRect {
return CGRect(x: min(self.x, point.x),
y: min(self.y, point.y),
width: fabs(self.x - point.x),
height: fabs(self.y - point.y))
width: abs(self.x - point.x),
height: abs(self.y - point.y))
}

/// Get the distance between two points
Expand Down
4 changes: 2 additions & 2 deletions Pod/Classes/Extensions/CGRect.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ extension CGRect {
return CGRect(
x: minX,
y: minY,
width: fabs(maxX - minX),
height: fabs(maxY - minY)
width: abs(maxX - minX),
height: abs(maxY - minY)
)
}
}
Empty file modified Pod/Classes/Extensions/UIColor.swift
100644 → 100755
Empty file.
Empty file modified Pod/Classes/Extensions/UIImage.swift
100644 → 100755
Empty file.
Empty file modified Pod/Classes/Extensions/UIViewController.swift
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Pod/Classes/Form/PDFArray.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ internal class PDFArray: PDFObject {

extension PDFArray: NSCopying {
func copy(with zone: NSZone?) -> Any {
return type(of: self).init(arrayRef: arr)
return Swift.type(of: self).init(arrayRef: arr)
}
}

Expand Down
Empty file modified Pod/Classes/Form/PDFDictionary.swift
100644 → 100755
Empty file.
Loading