ソースを参照

eSign 20170410

修改pdf 保存函数,对新建和修改进行区分。
Ray Zhang 9 年 前
コミット
94f0b5bc25

+ 1 - 1
RedAnt ERP Mobile/common/PDFUtils.h

@@ -14,7 +14,7 @@
 +(CGPDFDocumentRef)OpenPDF:(NSString*) file;
 
 //+ (CGRect)scaleToSize:(CGRect )from to:(CGSize)to;
-+(NSString*)SavePDF:(NSMutableDictionary*) controlTemplate source:(CGPDFDocumentRef )document window_rect:(CGRect)window_rect name:(NSString*)name;
++(NSString*)SavePDF:(NSMutableDictionary*) controlTemplate source:(CGPDFDocumentRef )document window_rect:(CGRect)window_rect name:(NSString*)name isnew:(bool)isNewDocument; 
 +(NSMutableDictionary*) loadControl:(NSString*)templateName;
 +(CGRect)WindowRect2PDFRect:(CGRect)rect pdf_rect:(CGRect)pdf_rect window_size:(CGSize)window_size;
 +(CGRect)PDFRect2WindowRect:(CGRect)rect pdf_rect:(CGRect)pdf_rect window_size:(CGSize)window_size;

+ 11 - 2
RedAnt ERP Mobile/common/PDFUtils.m

@@ -234,6 +234,7 @@
 }
 
 +(NSString*)SavePDF:(NSMutableDictionary*) controlTemplate source:(CGPDFDocumentRef )document window_rect:(CGRect)window_rect name:(NSString*)name
+isnew:(bool)isNewDocument
 {
     
     //获取路径
@@ -381,11 +382,19 @@
                 double margin_left = [control[@"margin_left"] doubleValue];
                 double margin_top = [control[@"margin_top"] doubleValue];
                 
-                
-                control_drawable=[[TextDrawable alloc] init:[self WindowRect2PDFRect:control_rect pdf_rect:papersize window_size:window_rect.size] source_type:@"const" source:value textAlignment:textAlignment vAlign:@"middle" size:size];
+                CGRect text_rect = [self WindowRect2PDFRect:control_rect pdf_rect:papersize window_size:window_rect.size];
+                control_drawable=[[TextDrawable alloc] init:text_rect source_type:@"const" source:value textAlignment:textAlignment vAlign:@"middle" size:size];
                 
                 [control_drawable setMargin_left:margin_left];
                 [control_drawable setMargin_top:margin_top];
+                
+                
+                
+                
+                CGRect bg_rect= text_rect;
+                PDFDrawable * rect_drawable = [[RectDrawable alloc] init:bg_rect color:@"0x0000ff"];
+                if(rect_drawable)
+                    [pdfPage DirectDraw:pdfContext drawable:rect_drawable];
             }
             else if([control_type isEqualToString:@"Check"])
             {

+ 2 - 0
RedAnt ERP Mobile/common/customUI/TouchImageView.h

@@ -11,7 +11,9 @@
 @protocol TouchImageViewDelegate <NSObject>
 @required
 - (void)TouchImageViewOnTouche:(TouchImageView *)touchImageView;
+- (void)TouchImageViewOnLongPress:(TouchImageView *)touchImageView;
 @end
+
 @interface TouchImageView : UIImageView
 {
 @private

+ 24 - 0
RedAnt ERP Mobile/common/customUI/TouchImageView.m

@@ -17,6 +17,11 @@
     if (self) {
         [self becomeFirstResponder];
         self.userInteractionEnabled=true;
+        
+        
+        UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
+        longPress.minimumPressDuration = 0.8; //定义按的时间
+        [self addGestureRecognizer:longPress];
 //        self.layer.borderColor = [UIColor darkGrayColor].CGColor;
 //        self.layer.borderWidth = 1.0;
     }
@@ -29,6 +34,10 @@
     self.userInteractionEnabled=true;
     self.layer.borderColor = [UIColor darkGrayColor].CGColor;
     self.layer.borderWidth = 1.0;
+    
+    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
+    longPress.minimumPressDuration = 0.8; //定义按的时间
+    [self addGestureRecognizer:longPress];
     // Initialization code
 }
 /*
@@ -39,7 +48,22 @@
 }
 */
 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
+    
+    if(delegate)
         [delegate TouchImageViewOnTouche:self];
 
 }
+-(void)longPress:(UILongPressGestureRecognizer*)gestureRecognizer{
+    if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
+        
+        if(delegate)
+            [delegate TouchImageViewOnLongPress:self];
+        
+    }
+
+}
+//- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(nullable UIPressesEvent *)event
+//{
+//   // event
+//}
 @end