|
@@ -1,520 +0,0 @@
|
|
|
-//
|
|
|
-// CPDFAnnotationModel.m
|
|
|
-// ComPDFKit
|
|
|
-//
|
|
|
-// Copyright © 2014-2022 PDF Technologies, Inc. All Rights Reserved.
|
|
|
-//
|
|
|
-// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
|
|
|
-// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
|
|
|
-// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
|
|
|
-// This notice may not be removed from this file.
|
|
|
-//
|
|
|
-
|
|
|
-#import "CPDFAnnotationModel.h"
|
|
|
-
|
|
|
-#import "CSelfSignAnnotationFreeText.h"
|
|
|
-#import "CSelfSignAnnotation.h"
|
|
|
-#import <PDF_Reader_Pro-Swift.h>
|
|
|
-
|
|
|
-#define kWidth 2.0
|
|
|
-@interface CPDFAnnotationModel()
|
|
|
-
|
|
|
-@property (nonatomic,assign) CAnnotationType annotationType;
|
|
|
-
|
|
|
-@property (nonatomic,retain) CPDFAnnotation *annotation;
|
|
|
-
|
|
|
-@property (nonatomic,retain) NSArray *annotations;
|
|
|
-
|
|
|
-@end
|
|
|
-
|
|
|
-@implementation CPDFAnnotationModel
|
|
|
-
|
|
|
-- (instancetype)initWithAnnotationType:(CAnnotationType)annotationType {
|
|
|
- if (self = [super init]) {
|
|
|
- self.annotationType = annotationType;
|
|
|
- }
|
|
|
- return self;
|
|
|
-}
|
|
|
-
|
|
|
-- (instancetype)initWithPDFAnnotations:(NSArray *)annotations {
|
|
|
- if (self = [super init]) {
|
|
|
- self.annotation = annotations.firstObject;
|
|
|
- self.annotations = [NSArray arrayWithArray:annotations];
|
|
|
- self.annotationType = [self convertAnnotationType];
|
|
|
-
|
|
|
- }
|
|
|
- return self;
|
|
|
-}
|
|
|
-
|
|
|
-+ (NSString *)tagString {
|
|
|
- NSDateFormatter *formatter = [[NSDateFormatter alloc ] init];
|
|
|
- [formatter setDateFormat:@"YYYY-MM-dd hh:mm:ss"];
|
|
|
- NSString *dateString = [formatter stringFromDate:[NSDate date]];
|
|
|
- return [NSString stringWithFormat:@"%@ %d ", dateString,rand()%10000];
|
|
|
-}
|
|
|
-
|
|
|
-+ (NSMutableArray *)supportFonts {
|
|
|
- NSMutableArray*fonts = [NSMutableArray array];
|
|
|
-
|
|
|
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
- [dic setValue:@[@"Regular",@"Bold",@"Bold Oblique",@"Oblique"] forKey:@"Courier"];
|
|
|
- [fonts addObject:dic];
|
|
|
-
|
|
|
- dic = [NSMutableDictionary dictionary];
|
|
|
- [dic setValue:@[@"Regular",@"Bold",@"Bold Oblique",@"Oblique"] forKey:@"Helvetica"];
|
|
|
- [fonts addObject:dic];
|
|
|
-
|
|
|
- dic = [NSMutableDictionary dictionary];
|
|
|
- [dic setValue:@[@"Roman",@"Bold",@"Bold Italic",@"Italic"] forKey:@"Times"];
|
|
|
- [fonts addObject:dic];
|
|
|
- return fonts;
|
|
|
-}
|
|
|
-
|
|
|
-+ (NSMutableArray <NSDictionary *>*)defaultFreeTextPropert {
|
|
|
- NSMutableArray*defaultFreeTexts = [NSMutableArray array];
|
|
|
- NSDictionary *dich1 = [[NSUserDefaults standardUserDefaults] objectForKey:@"CPDFFreeTextDefaultFontObjects_H1"] ? : @{@"fontName":@"Helvetica-Bold",@"fontSize":@"36"};
|
|
|
- NSDictionary *dich2 = [[NSUserDefaults standardUserDefaults] objectForKey:@"CPDFFreeTextDefaultFontObjects_H2"] ? : @{@"fontName":@"Helvetica-Bold",@"fontSize":@"24"};
|
|
|
- NSDictionary *dich3 = [[NSUserDefaults standardUserDefaults] objectForKey:@"CPDFFreeTextDefaultFontObjects_H3"] ? : @{@"fontName":@"Helvetica-Bold",@"fontSize":@"18"};
|
|
|
- NSDictionary *dicb1 = [[NSUserDefaults standardUserDefaults] objectForKey:@"CPDFFreeTextDefaultFontObjects_B1"] ? : @{@"fontName":@"Helvetica",@"fontSize":@"14"};
|
|
|
- NSDictionary *dicb2 = [[NSUserDefaults standardUserDefaults] objectForKey:@"CPDFFreeTextDefaultFontObjects_B2"] ? : @{@"fontName":@"Helvetica",@"fontSize":@"12"};
|
|
|
- NSDictionary *dicb3 = [[NSUserDefaults standardUserDefaults] objectForKey:@"CPDFFreeTextDefaultFontObjects_B3"] ? : @{@"fontName":@"Helvetica",@"fontSize":@"11"};
|
|
|
- NSDictionary *normal = @{@"fontName":@"Helvetica",@"fontSize":@"12"};
|
|
|
-
|
|
|
- [defaultFreeTexts addObject:normal];
|
|
|
- [defaultFreeTexts addObject:dich1];
|
|
|
- [defaultFreeTexts addObject:dich2];
|
|
|
- [defaultFreeTexts addObject:dich3];
|
|
|
- [defaultFreeTexts addObject:dicb1];
|
|
|
- [defaultFreeTexts addObject:dicb2];
|
|
|
- [defaultFreeTexts addObject:dicb3];
|
|
|
-
|
|
|
- return defaultFreeTexts;
|
|
|
-}
|
|
|
-
|
|
|
-+ (NSString *)timeStringWithTimeDate:(NSDate *)date {
|
|
|
- static NSDateFormatter *formatter = nil;
|
|
|
- if (formatter == nil) {
|
|
|
- formatter = [[NSDateFormatter alloc] init];
|
|
|
- }
|
|
|
- NSCalendar *calendar = [NSCalendar currentCalendar];
|
|
|
- int unit =NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear;
|
|
|
- NSDateComponents *nowCmps = [calendar components:unit fromDate:[NSDate date]];
|
|
|
- NSDateComponents *currentCmps = [calendar components:unit fromDate:date];
|
|
|
- [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
|
|
|
-
|
|
|
- return [formatter stringFromDate:date];
|
|
|
-}
|
|
|
-
|
|
|
-- (CAnnotationType)convertAnnotationType {
|
|
|
- CAnnotationType annotationType = CAnnotationTypeFreeText;
|
|
|
-
|
|
|
- return annotationType;
|
|
|
-}
|
|
|
-
|
|
|
-- (NSRect)annotationImageBounds {
|
|
|
- NSRect bounds = CGRectMake(0, 0, 140, 60);
|
|
|
-
|
|
|
- return bounds;
|
|
|
-}
|
|
|
-
|
|
|
-- (NSImage *)annotationImage {
|
|
|
- NSImage *image = nil;
|
|
|
-
|
|
|
- return image;
|
|
|
-}
|
|
|
-
|
|
|
-- (BOOL)isMultiAnnottation {
|
|
|
-
|
|
|
- return NO;
|
|
|
-}
|
|
|
-
|
|
|
-- (NSColor *)color {
|
|
|
- NSColor *color = nil;
|
|
|
-
|
|
|
- return color;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setColor:(NSColor *)color {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)opacity {
|
|
|
- CGFloat opacity = 1;
|
|
|
-
|
|
|
- return opacity;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setOpacity:(CGFloat)opacity {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CPDFBorderStyle)style {
|
|
|
- CPDFBorderStyle style = CPDFBorderStyleSolid;
|
|
|
-
|
|
|
-
|
|
|
- return style;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setStyle:(CPDFBorderStyle)style {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (NSArray *)dashPattern {
|
|
|
-
|
|
|
- return @[@5];
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)lineWidth {
|
|
|
- CGFloat lineWidth = 2;
|
|
|
-
|
|
|
- return lineWidth;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setLineWidth:(CGFloat)lineWidth {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (BOOL)shouldDisplay {
|
|
|
- BOOL shouldDisplay = YES;
|
|
|
-
|
|
|
- return shouldDisplay;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setShouldDisplay:(BOOL)shouldDisplay {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (BOOL)shouldPrint {
|
|
|
- BOOL shouldPrint = YES;
|
|
|
-
|
|
|
- return shouldPrint;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setShouldPrint:(BOOL)shouldPrint {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (NSString *)contents {
|
|
|
- NSString *contents = nil;
|
|
|
-
|
|
|
- return contents?:NSLocalizedString(@"Sample", nil);
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setContents:(NSString *)contents {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark - Text
|
|
|
-
|
|
|
-- (CPDFTextAnnotationIconType)anchoredIconType {
|
|
|
- CPDFTextAnnotationIconType anchoredIconType = CPDFTextAnnotationIconComment;
|
|
|
-
|
|
|
- return anchoredIconType;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setAnchoredIconType:(CPDFTextAnnotationIconType)anchoredIconType {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark - Line
|
|
|
-
|
|
|
-- (CGPoint)annotationImageStartPoint {
|
|
|
- return NSMakePoint(self.lineWidth, self.lineWidth);
|
|
|
-}
|
|
|
-
|
|
|
-- (CGPoint)annotationImageEndPoint {
|
|
|
- return NSMakePoint(50, 50);
|
|
|
-}
|
|
|
-
|
|
|
-- (CPDFLineStyle)startLineStyle {
|
|
|
- CPDFLineStyle startLineStyle = CPDFLineStyleNone;
|
|
|
-
|
|
|
- return startLineStyle;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setStartLineStyle:(CPDFLineStyle)startLineStyle {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CPDFLineStyle)endLineStyle {
|
|
|
- CPDFLineStyle endLineStyle = CPDFLineStyleNone;
|
|
|
-
|
|
|
- return endLineStyle;
|
|
|
-}
|
|
|
-
|
|
|
--(void)setEndLineStyle:(CPDFLineStyle)endLineStyle {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark - FreeText
|
|
|
-
|
|
|
-- (NSColor *)fontColor {
|
|
|
- NSColor *color = nil;
|
|
|
-
|
|
|
- return color;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setFontColor:(NSColor *)fontColor {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)fontSize {
|
|
|
- CGFloat fontSize = 11;
|
|
|
-
|
|
|
- return fontSize;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setFontSize:(CGFloat)fontSize {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (NSString *)fontName {
|
|
|
- NSString *fontName = nil;
|
|
|
-
|
|
|
- return fontName;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setFontName:(NSString *)fontName {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (NSTextAlignment)alignment {
|
|
|
- NSTextAlignment alignment = NSTextAlignmentLeft;
|
|
|
-
|
|
|
- return alignment;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setAlignment:(NSTextAlignment)alignment {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark - Circle&Square
|
|
|
-
|
|
|
-- (NSColor *)interiorColor {
|
|
|
- NSColor *interiorColor = nil;
|
|
|
-
|
|
|
- return interiorColor;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setInteriorColor:(NSColor *)interiorColor {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)interiorOpacity {
|
|
|
- CGFloat opacity = 1;
|
|
|
-
|
|
|
- return opacity;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setInteriorOpacity:(CGFloat)interiorOpacity {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark - Widget
|
|
|
-
|
|
|
-- (NSColor *)backgroundColor {
|
|
|
- NSColor *backgroundColor = nil;
|
|
|
-
|
|
|
- return backgroundColor;
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)backgroundOpacity {
|
|
|
- CGFloat opacity = 0;
|
|
|
-
|
|
|
- return opacity;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setBackgroundOpacity:(CGFloat)backgroundOpacity {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setBackgroundColor:(NSColor *)backgroundColor {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (BOOL)isMultiline {
|
|
|
- BOOL isMultiline = YES;
|
|
|
-
|
|
|
- return isMultiline;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setIsMultiline:(BOOL)isMultiline {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (NSString *)stringValue {
|
|
|
-
|
|
|
- return @"";
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setStringValue:(NSString *)stringValue {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark - Redact
|
|
|
-
|
|
|
-- (BOOL)isOverlayText {
|
|
|
- BOOL isOverlayText = NO;
|
|
|
-
|
|
|
- return isOverlayText;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setIsOverlayText:(BOOL)isOverlayText {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (NSString *)overlayText {
|
|
|
-
|
|
|
- return nil;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setOverlayText:(NSString *)overlayText {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark - SelfSign
|
|
|
-
|
|
|
-- (NSInteger)dateFormatIndex {
|
|
|
- NSInteger dateFormatIndex = 0;
|
|
|
-
|
|
|
- return dateFormatIndex;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setDateFormatIndex:(NSInteger)dateFormatIndex {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (BOOL)includeTime {
|
|
|
- BOOL includeTime = YES;
|
|
|
-
|
|
|
- return includeTime;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setIncludeTime:(BOOL)includeTime {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CAnnotationType)stampAnnotationType {
|
|
|
- CAnnotationType stampAnnotationType = CAnnotationTypeUnkown;
|
|
|
-
|
|
|
- return stampAnnotationType;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setStampAnnotationType:(CAnnotationType)stampAnnotationType {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark - Measure
|
|
|
-
|
|
|
-- (NSColor *)measureBorderColor {
|
|
|
- NSColor *color = nil;
|
|
|
-
|
|
|
- return color;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setMeasureBorderColor:(NSColor *)color {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (NSColor *)measureLineColor {
|
|
|
- NSColor *color = nil;
|
|
|
-
|
|
|
- return color;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setMeasureLineColor:(NSColor *)color {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)measureOpacity {
|
|
|
- CGFloat opacity = 1;
|
|
|
-
|
|
|
- return opacity;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setMeasureOpacity:(CGFloat)opacity {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)measureLineWidth {
|
|
|
- CGFloat lineWidth = 2;
|
|
|
-
|
|
|
- return lineWidth;
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setMeasureLineWidth:(CGFloat)lineWidth {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CPDFBorderStyle)measureLineStyle {
|
|
|
- CPDFBorderStyle style = CPDFBorderStyleSolid;
|
|
|
-
|
|
|
- return style;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setMeasureLineStyle:(CPDFBorderStyle)style {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (NSArray *)measureDashPattern {
|
|
|
- NSArray *dashPattern = @[@5];
|
|
|
-
|
|
|
- return dashPattern;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setMeasureDashPattern:(NSArray *)dashPattern {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CPDFLineStyle)measureStartLineStyle {
|
|
|
- CPDFLineStyle startLineStyle = CPDFLineStyleNone;
|
|
|
-
|
|
|
- return startLineStyle;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setMeasureStartLineStyle:(CPDFLineStyle)startLineStyle {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CPDFLineStyle)measureEndLineStyle {
|
|
|
- CPDFLineStyle endLineStyle = CPDFLineStyleNone;
|
|
|
-
|
|
|
- return endLineStyle;
|
|
|
-}
|
|
|
-
|
|
|
--(void)setMeasureEndLineStyle:(CPDFLineStyle)endLineStyle {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (NSColor *)measureFontColor {
|
|
|
- NSColor *fontColor = nil;
|
|
|
-
|
|
|
- return fontColor;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setMeasureFontColor:(NSColor *)fontColor {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (CGFloat)measureFontSize {
|
|
|
- CGFloat fontSize = 11;
|
|
|
-
|
|
|
- return fontSize;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setMeasureFontSize:(CGFloat)fontSize {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-- (NSString *)measureFontName {
|
|
|
- NSString *fontName = nil;
|
|
|
-
|
|
|
- return fontName;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setMeasureFontName:(NSString *)fontName {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-@end
|