|
@@ -126,6 +126,74 @@ CGFloat DEFAULT_SNAPSHOT_HEIGHT = 200.0;
|
|
|
return annotation;
|
|
|
}
|
|
|
|
|
|
+- (CPDFAnnotation *)addPDFStampAnotationWithObject:(CStampSignatureObject *)stampObject atPagePoint:(CGPoint)pagePoint withPage:(CPDFPage *)page {
|
|
|
+ CGFloat defaultWidth = 160;
|
|
|
+ CGFloat defaultHeight = 40;
|
|
|
+ if (CPDFStampTypeImage == stampObject.stampCategoryType) {
|
|
|
+ defaultWidth = 360;
|
|
|
+ defaultHeight = 90;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((CPDFStampTypeStandard == stampObject.stampCategoryType) &&
|
|
|
+ (CStandardStampTypeCircle == stampObject.stampType ||
|
|
|
+ CStandardStampTypeAccepted == stampObject.stampType ||
|
|
|
+ CStandardStampTypeRejected == stampObject.stampType ||
|
|
|
+ CStandardStampTypeChick == stampObject.stampType ||
|
|
|
+ CStandardStampTypeCross == stampObject.stampType)) {
|
|
|
+ defaultHeight = defaultWidth = 40;
|
|
|
+ }
|
|
|
+ CPDFAnnotation *annotation = nil;
|
|
|
+ NSSize defaultSize = NSMakeSize(defaultWidth, defaultHeight);
|
|
|
+
|
|
|
+ pagePoint = CPDFListViewIntegralPoint(pagePoint);
|
|
|
+ CGRect bounds = CPDFListViewRectFromCenterAndSize(pagePoint, defaultSize);
|
|
|
+
|
|
|
+ if (CPDFStampTypeImage == stampObject.stampCategoryType) {
|
|
|
+ NSImage * image = [[NSImage alloc] initWithContentsOfFile:stampObject.imagePath];
|
|
|
+ annotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document image:image];
|
|
|
+
|
|
|
+ CGFloat newWidth = image.size.width;
|
|
|
+ CGFloat newHeight = image.size.height;
|
|
|
+ CGSize size = CGSizeMake(360, 360);
|
|
|
+ if (bounds.size.width > newWidth || bounds.size.height > newWidth) {
|
|
|
+ if (size.width > size.height) {
|
|
|
+ newHeight = newHeight/size.width * size.height;
|
|
|
+ } else {
|
|
|
+ newWidth = newWidth/size.height * size.width;
|
|
|
+ }
|
|
|
+ bounds.size = CGSizeMake(newWidth, newHeight);
|
|
|
+ }
|
|
|
+
|
|
|
+ bounds = CPDFListViewRectFromCenterAndSize(pagePoint, bounds.size);
|
|
|
+ annotation.bounds = bounds;
|
|
|
+ } else if(stampObject.isSignatureAnnotation) {
|
|
|
+ NSImage * image = stampObject.signatureImage;
|
|
|
+ annotation = [[CPDFListSignatureAnnotation alloc] initWithDocument:self.document];
|
|
|
+ [(CPDFListSignatureAnnotation *)annotation setImage:image];
|
|
|
+ annotation.bounds = NSMakeRect(pagePoint.x, pagePoint.y-annotation.bounds.size.height, annotation.bounds.size.width, annotation.bounds.size.height);
|
|
|
+ } else if (CPDFStampTypeText == stampObject.stampCategoryType) {
|
|
|
+ annotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document text:stampObject.text detailText:stampObject.detailText style:stampObject.style shape:stampObject.shape];
|
|
|
+ annotation.bounds = NSMakeRect(pagePoint.x, pagePoint.y-annotation.bounds.size.height, annotation.bounds.size.width, annotation.bounds.size.height);
|
|
|
+ } else if (4/*CPDFStampTypeDynamic*/ == stampObject.stampCategoryType) {
|
|
|
+ annotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document text:stampObject.text detailText:stampObject.detailText style:stampObject.style shape:stampObject.shape];
|
|
|
+ annotation.bounds = NSMakeRect(pagePoint.x, pagePoint.y-annotation.bounds.size.height, annotation.bounds.size.width, annotation.bounds.size.height);
|
|
|
+ } else if (CPDFStampTypeDigital == stampObject.stampCategoryType) {
|
|
|
+ annotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document text:stampObject.text detailText:stampObject.detailText dateText:stampObject.dateText color:stampObject.color];
|
|
|
+ annotation.bounds = NSMakeRect(pagePoint.x, pagePoint.y-40, 80, 80);
|
|
|
+ } else if (CPDFStampTypeStandard == stampObject.stampCategoryType) {
|
|
|
+ if(stampObject.stampType > CStandardStampTypeCircle) {
|
|
|
+ annotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document text:stampObject.text detailText:stampObject.detailText style:stampObject.style shape:stampObject.shape];
|
|
|
+ annotation.bounds = NSMakeRect(pagePoint.x, pagePoint.y-annotation.bounds.size.height, annotation.bounds.size.width, annotation.bounds.size.height);
|
|
|
+ } else {
|
|
|
+ annotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document type:stampObject.stampType];
|
|
|
+ annotation.bounds = NSMakeRect(pagePoint.x, pagePoint.y - annotation.bounds.size.height, annotation.bounds.size.width, annotation.bounds.size.height);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return annotation;
|
|
|
+}
|
|
|
+
|
|
|
- (void)addAnnotationWithImage:(NSImage *)image isRemoveBGColor:(BOOL)isRemoveBGColor {
|
|
|
// First try the current mouse position
|
|
|
NSPoint center = [self convertPoint:[[self window] mouseLocationOutsideOfEventStream] fromView:nil];
|