فهرست منبع

161021
Add pdfCreator

Ray Zhang 9 سال پیش
والد
کامیت
e603f40d02
24فایلهای تغییر یافته به همراه1828 افزوده شده و 0 حذف شده
  1. BIN
      RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/UserInterfaceState.xcuserstate
  2. 32 0
      RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. 7 0
      RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m
  4. 14 0
      RedAnt ERP Mobile/common/pdfCreator/BasicDrawable.h
  5. 25 0
      RedAnt ERP Mobile/common/pdfCreator/BasicDrawable.m
  6. 13 0
      RedAnt ERP Mobile/common/pdfCreator/GridDrawable.h
  7. 174 0
      RedAnt ERP Mobile/common/pdfCreator/GridDrawable.m
  8. 13 0
      RedAnt ERP Mobile/common/pdfCreator/GroupDrawable.h
  9. 72 0
      RedAnt ERP Mobile/common/pdfCreator/GroupDrawable.m
  10. 13 0
      RedAnt ERP Mobile/common/pdfCreator/ImageDrawable.h
  11. 65 0
      RedAnt ERP Mobile/common/pdfCreator/ImageDrawable.m
  12. 13 0
      RedAnt ERP Mobile/common/pdfCreator/LineDrawable.h
  13. 43 0
      RedAnt ERP Mobile/common/pdfCreator/LineDrawable.m
  14. 48 0
      RedAnt ERP Mobile/common/pdfCreator/PDFDrawable.h
  15. 67 0
      RedAnt ERP Mobile/common/pdfCreator/PDFDrawable.m
  16. 35 0
      RedAnt ERP Mobile/common/pdfCreator/PDFPage.h
  17. 230 0
      RedAnt ERP Mobile/common/pdfCreator/PDFPage.m
  18. 13 0
      RedAnt ERP Mobile/common/pdfCreator/TableDrawable.h
  19. 109 0
      RedAnt ERP Mobile/common/pdfCreator/TableDrawable.m
  20. 22 0
      RedAnt ERP Mobile/common/pdfCreator/TextDrawable.h
  21. 565 0
      RedAnt ERP Mobile/common/pdfCreator/TextDrawable.m
  22. 13 0
      RedAnt ERP Mobile/common/pdfCreator/pdfCreator.h
  23. 174 0
      RedAnt ERP Mobile/common/pdfCreator/pdfCreator.m
  24. 68 0
      RedAnt ERP Mobile/iSales-NPD.xcodeproj/project.pbxproj

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/UserInterfaceState.xcuserstate


+ 32 - 0
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -892,5 +892,37 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/pdfCreator/pdfCreator.m"
+            timestampString = "498732233.37945"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "168"
+            endingLineNumber = "168"
+            landmarkName = "+CreatePdf:dataSource:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/pdfCreator/TextDrawable.m"
+            timestampString = "498732517.200441"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "392"
+            endingLineNumber = "392"
+            landmarkName = "-Draw1:dataSource:ParentRect:startX:startY:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 7 - 0
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -21,6 +21,13 @@
 @end
 
 @implementation OLDataProvider
+
++(NSString*) create_portfolio
+{
+    // not impl
+    return nil;
+}
+
 +(NSString*) get_offline_soid:(sqlite3*)db
 {
     NSString* soid=nil;

+ 14 - 0
RedAnt ERP Mobile/common/pdfCreator/BasicDrawable.h

@@ -0,0 +1,14 @@
+//
+//  BasicDrawable.h
+//  pdftest
+//
+//  Created by Ray on 10/18/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "PDFDrawable.h"
+
+@interface BasicDrawable : PDFDrawable
+//-(void) flipContext:(CGContextRef) context ContextHeight:(double)height ;
+//-(void) restoreFlip:(CGContextRef) context ContextHeight:(double)height ;
+@end

+ 25 - 0
RedAnt ERP Mobile/common/pdfCreator/BasicDrawable.m

@@ -0,0 +1,25 @@
+//
+//  BasicDrawable.m
+//  pdftest
+//
+//  Created by Ray on 10/18/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "BasicDrawable.h"
+
+@implementation BasicDrawable
+//-(void) flipContext:(CGContextRef) context ContextHeight:(double)height
+//{
+//    // 翻转坐标系统以适应UIkit,左上为原点
+//    CGContextTranslateCTM(context, 0, height);
+//    CGContextScaleCTM(context, 1, -1);
+//}
+//
+//-(void) restoreFlip:(CGContextRef) context ContextHeight:(double)height
+//{
+//    // 恢复坐标系统Core Graphics,左下为原点
+//    CGContextScaleCTM(context, 1, -1);
+//    CGContextTranslateCTM(context, 0, -height);
+//}
+@end

+ 13 - 0
RedAnt ERP Mobile/common/pdfCreator/GridDrawable.h

@@ -0,0 +1,13 @@
+//
+//  GridDrawable.h
+//  pdftest
+//
+//  Created by Ray on 10/21/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "PDFDrawable.h"
+
+@interface GridDrawable : PDFDrawable
+
+@end

+ 174 - 0
RedAnt ERP Mobile/common/pdfCreator/GridDrawable.m

@@ -0,0 +1,174 @@
+//
+//  GridDrawable.m
+//  pdftest
+//
+//  Created by Ray on 10/21/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "GridDrawable.h"
+#import "GroupDrawable.h"
+@implementation GridDrawable
+-(CGRect) Query_Rect:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    NSMutableDictionary* table_data = data[self.drawableTemplate[@"data_source"]];
+    
+    NSMutableDictionary* celljson = self.drawableTemplate[@"cell"];
+    NSString* direction = celljson[@"direction"];
+    if(direction==nil)
+        direction=@"H";
+    
+    //    CGRect pdfrect = /*CGRectMake(self.rect.origin.x+self.margin_left+p_rect.origin.x, self.rect.origin.y+self.margin_top+p_rect.origin.y, self.rect.size.width-self.margin_right, self.rect.size.height-self.margin_bottom);//*/[self to_pdf_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    
+    CGRect pdfrect =  [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    CGRect parentrect =[self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    PDFDrawable* drawable_obj= [[GroupDrawable alloc] init:celljson];
+    drawable_obj.delegate = self.delegate;
+    NSMutableDictionary* rows_data = table_data[celljson[@"data_source"]];
+    int row_data_count=[rows_data[@"count"] intValue];
+    float dy=0;
+    float dx=0;
+    for(int j=0;j<row_data_count;j++)
+    {
+        
+        
+        
+        NSMutableDictionary * row_data =rows_data[ [NSString stringWithFormat:@"item_%d",j ] ];
+        CGRect row_rect= [drawable_obj Query_Rect:context dataSource:row_data ParentRect:(CGRect)pdfrect startX:0 startY:dy flipHeight:flip_height range:between_header_and_footer];
+        
+        if(row_rect.size.width>parentrect.size.width||row_rect.size.height>parentrect.size.height)
+        {
+            // cell 比 grid 还要大,模板有错,直接返回。
+            return parentrect;
+        }
+        
+        if(dy+row_rect.size.height> between_header_and_footer.location+between_header_and_footer.length && dx+row_rect.size.width>parentrect.size.width)
+        {
+            //越界,新起一页
+            if (self.delegate && [self.delegate respondsToSelector:@selector(outofPage:)]) {
+                [self.delegate addPageCount:context];
+                dy=0;
+                dx=0;
+            }
+        }
+        
+        
+        
+     //   [drawable_obj Draw:context dataSource:row_data ParentRect:(CGRect)pdfrect startX:dx startY:dy flipHeight:flip_height range:between_header_and_footer];
+        if([direction isEqualToString:@"H"])
+        {
+            dx+=row_rect.size.width;
+            if(dx+row_rect.size.width>parentrect.size.width)
+            {
+                dx=0;
+                dy+=row_rect.size.height;
+            }
+            
+        }
+        else
+        {
+            dy+=row_rect.size.height;
+            if(dy+row_rect.size.height>parentrect.size.height)
+            {
+                dy=0;
+                dx+=row_rect.size.width;
+            }
+            
+            
+        }
+        
+        
+        
+    }
+    
+    
+    
+    return parentrect;
+}
+-(CGRect) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    
+    
+    NSMutableDictionary* table_data = data[self.drawableTemplate[@"data_source"]];
+    
+    NSMutableDictionary* celljson = self.drawableTemplate[@"cell"];
+    NSString* direction = celljson[@"direction"];
+    if(direction==nil)
+        direction=@"H";
+    
+    //    CGRect pdfrect = /*CGRectMake(self.rect.origin.x+self.margin_left+p_rect.origin.x, self.rect.origin.y+self.margin_top+p_rect.origin.y, self.rect.size.width-self.margin_right, self.rect.size.height-self.margin_bottom);//*/[self to_pdf_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    
+    CGRect pdfrect =  [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    CGRect parentrect =[self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    PDFDrawable* drawable_obj= [[GroupDrawable alloc] init:celljson];
+    drawable_obj.delegate = self.delegate;
+    NSMutableDictionary* rows_data = table_data[celljson[@"data_source"]];
+    int row_data_count=[rows_data[@"count"] intValue];
+    float dy=0;
+    float dx=0;
+    for(int j=0;j<row_data_count;j++)
+    {
+        
+        
+        
+        NSMutableDictionary * row_data =rows_data[ [NSString stringWithFormat:@"item_%d",j ] ];
+        CGRect row_rect= [drawable_obj Query_Rect:context dataSource:row_data ParentRect:(CGRect)pdfrect startX:0 startY:dy flipHeight:flip_height range:between_header_and_footer];
+        
+        if(row_rect.size.width>parentrect.size.width||row_rect.size.height>parentrect.size.height)
+        {
+            // cell 比 grid 还要大,模板有错,直接返回。
+            return parentrect;
+        }
+        
+        if(dy+row_rect.size.height> between_header_and_footer.location+between_header_and_footer.length && dx+row_rect.size.width>parentrect.size.width)
+        {
+            //越界,新起一页
+            if (self.delegate && [self.delegate respondsToSelector:@selector(outofPage:)]) {
+                [self.delegate outofPage:context];
+                dy=0;
+                dx=0;
+            }
+        }
+        
+        
+        
+        [drawable_obj Draw:context dataSource:row_data ParentRect:(CGRect)pdfrect startX:dx startY:dy flipHeight:flip_height range:between_header_and_footer];
+        if([direction isEqualToString:@"H"])
+        {
+            dx+=row_rect.size.width;
+            if(dx+row_rect.size.width>parentrect.size.width)
+            {
+                dx=0;
+                dy+=row_rect.size.height;
+            }
+
+        }
+        else
+        {
+            dy+=row_rect.size.height;
+            if(dy+row_rect.size.height>parentrect.size.height)
+            {
+                dy=0;
+                dx+=row_rect.size.width;
+            }
+
+            
+        }
+        
+        
+        
+    }
+    
+    
+    
+    return parentrect;
+    //return CGPointMake(parentrect.origin.x+parentrect.size.width, parentrect.origin.y+parentrect.size.height);
+    //    if (self.delegate && [self.delegate respondsToSelector:@selector(outofPage:)]) {
+    //        [self.delegate outofPage:context];
+    //    }
+}
+@end

+ 13 - 0
RedAnt ERP Mobile/common/pdfCreator/GroupDrawable.h

@@ -0,0 +1,13 @@
+//
+//  GroupDrawable.h
+//  pdftest
+//
+//  Created by Ray on 10/12/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "PDFDrawable.h"
+
+@interface GroupDrawable : PDFDrawable
+
+@end

+ 72 - 0
RedAnt ERP Mobile/common/pdfCreator/GroupDrawable.m

@@ -0,0 +1,72 @@
+//
+//  GroupDrawable.m
+//  pdftest
+//
+//  Created by Ray on 10/12/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "GroupDrawable.h"
+#import "ImageDrawable.h"
+#import "LineDrawable.h"
+#import "TextDrawable.h"
+#import "TableDrawable.h"
+@implementation GroupDrawable
+
+
+-(CGRect) Query_Rect:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    CGRect parentrect = [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    return parentrect;
+}
+-(CGRect) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    
+    NSMutableDictionary* items = self.drawableTemplate[@"items"];
+    int count = [items[@"count"] intValue];
+    
+//    CGRect pdfrect = /*CGRectMake(self.rect.origin.x+self.margin_left+p_rect.origin.x, self.rect.origin.y+self.margin_top+p_rect.origin.y, self.rect.size.width-self.margin_right, self.rect.size.height-self.margin_bottom);//*/[self to_pdf_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    CGRect parentrect =[self to_parent_rect:p_rect pos:self.rect offsetX:x offsetY:y];
+    CGRect pdfrect =  [self to_parent_rect:p_rect pos:self.rect offsetX:x offsetY:y];
+    for(int i=0;i<count;i++)
+    {
+        NSMutableDictionary * item =items[ [NSString stringWithFormat:@"item_%d",i ] ];
+        PDFDrawable* drawable_obj=nil;
+        if([item[@"type"] isEqualToString:@"img"])
+        {
+            drawable_obj= [[ImageDrawable alloc] init:item];
+            
+        }
+        else if([item[@"type"] isEqualToString:@"line"])
+        {
+            drawable_obj= [[LineDrawable alloc] init:item];
+            
+        }
+        else if([item[@"type"] isEqualToString:@"text"])
+        {
+            drawable_obj= [[TextDrawable alloc] init:item];
+            
+        }
+        else if([item[@"type"] isEqualToString:@"group"])
+        {
+            drawable_obj= [[GroupDrawable alloc] init:item];
+            
+        }
+        else if([item[@"type"] isEqualToString:@"table"])
+        {
+            drawable_obj= [[TableDrawable alloc] init:item];
+            
+        }
+        drawable_obj.delegate=self.delegate;
+        [drawable_obj Draw:context dataSource:data ParentRect:(CGRect)pdfrect startX:0 startY:0 flipHeight:flip_height range:between_header_and_footer];
+    }
+    
+    return parentrect;
+//    return CGPointMake(parentrect.origin.x+parentrect.size.width, parentrect.origin.y+parentrect.size.height);    
+//    if (self.delegate && [self.delegate respondsToSelector:@selector(outofPage:)]) {
+//        [self.delegate outofPage:context];
+//    }
+}
+@end

+ 13 - 0
RedAnt ERP Mobile/common/pdfCreator/ImageDrawable.h

@@ -0,0 +1,13 @@
+//
+//  ImageDrawable.h
+//  pdftest
+//
+//  Created by Ray on 10/13/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "BasicDrawable.h"
+
+@interface ImageDrawable : BasicDrawable
+
+@end

+ 65 - 0
RedAnt ERP Mobile/common/pdfCreator/ImageDrawable.m

@@ -0,0 +1,65 @@
+//
+//  ImageDrawable.m
+//  pdftest
+//
+//  Created by Ray on 10/13/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "ImageDrawable.h"
+
+@implementation ImageDrawable
+-(CGRect) Query_Rect:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    CGRect parentrect = [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    return parentrect;
+}
+
+-(CGRect) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+//    [super flipContext:context ContextHeight:flip_height];
+    
+    UIImage* image=nil;
+    NSString * source=self.drawableTemplate[@"source_type"];
+    if([source isEqualToString:@"const"])
+    {
+        image= [UIImage imageNamed:self.drawableTemplate[@"source"]];
+        
+    }
+    else
+    {
+        
+        // not impl;
+        
+        image=[UIImage imageNamed:data[self.drawableTemplate[@"source"]]];
+    }
+    
+//    CGRect rect=[self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];//CGRectMake(self.rect.origin.x+x, self.rect.origin.y, self.rect.size.width, self.rect.size.height);
+//    rect=CGRectMake(rect.origin.x, flip_height-rect.origin.y-rect.size.height, rect.size.width, rect.size.height);
+    
+    CGRect parentrect = [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+
+    
+    CGRect rect = [self to_pdf_rect:p_rect pos:self.rect contextHeight:flip_height];
+    CGContextDrawImage(context, rect, image.CGImage);
+    
+  
+    return parentrect;
+//    return CGPointMake(parentrect.origin.x+parentrect.size.width, parentrect.origin.y+parentrect.size.height);
+
+    
+//    // 切换上下文 Core Graphics 和 UIKit 混用
+//    UIGraphicsPushContext(context);
+//
+//    // 使用UIKit绘制内容
+//    [image drawInRect:rect];
+//    
+//    // 绘制完位图后,再恢复上下文
+//    UIGraphicsPopContext();
+    
+//    [super restoreFlip:context ContextHeight:flip_height];
+}
+
+
+@end

+ 13 - 0
RedAnt ERP Mobile/common/pdfCreator/LineDrawable.h

@@ -0,0 +1,13 @@
+//
+//  LineDrawable.h
+//  pdftest
+//
+//  Created by Ray on 10/15/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "BasicDrawable.h"
+
+@interface LineDrawable : BasicDrawable
+
+@end

+ 43 - 0
RedAnt ERP Mobile/common/pdfCreator/LineDrawable.m

@@ -0,0 +1,43 @@
+//
+//  LineDrawable.m
+//  pdftest
+//
+//  Created by Ray on 10/15/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "LineDrawable.h"
+
+@implementation LineDrawable
+
+-(CGRect) Query_Rect:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    
+    return CGRectMake(0, 0, 0, 0);
+}
+
+-(CGRect) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    CGContextSaveGState(context);
+    //        CGContextSetRGBStrokeColor(context,1,1,1,1.0);//画笔线的颜色
+    CGContextSetLineWidth(context, [self.drawableTemplate[@"line_width"] doubleValue]);
+//    CGContextMoveToPoint(context, [self.drawableTemplate[@"x0"] doubleValue], [self.drawableTemplate[@"y0"] doubleValue]);
+//    
+//    CGContextAddLineToPoint(context, [self.drawableTemplate[@"x1"] doubleValue], [self.drawableTemplate[@"y1"] doubleValue]);
+//    
+//    CGContextStrokePath(context);
+    
+    
+    CGPoint aPoints[2];//坐标点
+    aPoints[0] =[self to_pdf_point:p_rect point:CGPointMake([self.drawableTemplate[@"x0"] doubleValue], [self.drawableTemplate[@"y0"] doubleValue]) contextHeight:flip_height];//坐标1
+    aPoints[1] =[self to_pdf_point:p_rect point:CGPointMake([self.drawableTemplate[@"x1"] doubleValue], [self.drawableTemplate[@"y1"] doubleValue]) contextHeight:flip_height];//坐标2
+    //CGContextAddLines(CGContextRef c, const CGPoint points[],size_t count)
+    //points[]坐标数组,和count大小
+    CGContextAddLines(context, aPoints, 2);//添加线
+    CGContextDrawPath(context, kCGPathStroke); //根据坐标绘制路径
+    
+    CGContextRestoreGState(context);
+    
+     return CGRectMake(0, 0, 0, 0);
+}
+@end

+ 48 - 0
RedAnt ERP Mobile/common/pdfCreator/PDFDrawable.h

@@ -0,0 +1,48 @@
+//
+//  PDFDrawable.h
+//  pdftest
+//
+//  Created by Ray on 10/11/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+#import "UIKit/UIDocument.h"
+#import "const.h"
+
+//#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
+
+
+@class PDFDrawable;
+@protocol PDFDrawableDelegate <NSObject>
+
+-(void) outofPage:(CGContextRef) context ;//indexPath :(NSIndexPath*) indexPath;
+-(void) addPageCount:(CGContextRef) context ;//indexPath :(NSIndexPath*) indexPath;
+
+@end
+
+
+
+@interface PDFDrawable : NSObject
+@property (nonatomic,strong) NSMutableDictionary* drawableTemplate;
+@property double margin_left;
+@property double margin_right;
+@property double margin_top;
+@property double margin_bottom;
+@property CGRect rect;
+
+//@property CGRect drawable_rect;
+@property (nonatomic, weak) id<PDFDrawableDelegate> delegate;
+
+-(CGRect) Query_Rect:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer;
+
+-(CGRect) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer;
+-(instancetype) init:(NSMutableDictionary *)drawableTemplate;
+-(CGRect)to_parent_rect:(CGRect)parentRect pos:(CGRect)rect offsetX:(double)x offsetY:(double)y;
+-(CGPoint)to_parent_point:(CGRect)parentRect point:(CGPoint)p offsetX:(double)x offsetY:(double)y;
+
+
+-(CGRect)to_pdf_rect:(CGRect)parentRect pos:(CGRect)rect contextHeight:(double) height;
+-(CGPoint)to_pdf_point:(CGRect)parentRect point:(CGPoint)p contextHeight:(double) height;
+@end

+ 67 - 0
RedAnt ERP Mobile/common/pdfCreator/PDFDrawable.m

@@ -0,0 +1,67 @@
+//
+//  PDFDrawable.m
+//  pdftest
+//
+//  Created by Ray on 10/11/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "PDFDrawable.h"
+
+
+@implementation PDFDrawable
+-(instancetype) init:(NSMutableDictionary *)drawableTemplate
+{
+    
+    if (self = [super init]) {
+        [self setDrawableTemplate:drawableTemplate];
+        
+    }
+    return self;
+    
+}
+-(void) setDrawableTemplate:(NSMutableDictionary *)drawableTemplate
+{
+    _drawableTemplate = drawableTemplate;
+    self.margin_left=[self.drawableTemplate[@"margin_left"] doubleValue];
+    self.margin_right=[self.drawableTemplate[@"margin_right"] doubleValue];
+    self.margin_top=[self.drawableTemplate[@"margin_top"] doubleValue];
+    self.margin_bottom=[self.drawableTemplate[@"margin_bottom"] doubleValue];
+    self.rect = CGRectMake([self.drawableTemplate[@"x"] doubleValue], [self.drawableTemplate[@"y"] doubleValue], [self.drawableTemplate[@"width"] doubleValue], [self.drawableTemplate[@"height"] doubleValue]);
+ //   self.drawable_rect = CGRectMake(self.rect.origin.x+self.margin_left, self.rect.origin.y+self.margin_top, self.rect.size.width-self.margin_right, self.rect.size.height-self.margin_bottom);
+}
+
+-(CGRect)to_parent_rect:(CGRect)parentRect pos:(CGRect)rect offsetX:(double)x offsetY:(double)y
+{
+    return CGRectMake(parentRect.origin.x+self.margin_left+rect.origin.x+x, parentRect.origin.y+self.margin_top+self.rect.origin.y+y/*-self.rect.size.height*/, self.rect.size.width-self.margin_left-self.margin_right, self.rect.size.height-self.margin_top-self.margin_bottom);
+}
+-(CGRect)to_pdf_rect:(CGRect)parentRect pos:(CGRect)rect contextHeight:(double) height
+{
+    CGRect pdfrect=[self to_parent_rect:parentRect pos:rect offsetX:0 offsetY:0];//CGRectMake(self.rect.origin.x+x, self.rect.origin.y, self.rect.size.width, self.rect.size.height);
+    pdfrect=CGRectMake(pdfrect.origin.x, height-pdfrect.origin.y-pdfrect.size.height, pdfrect.size.width, pdfrect.size.height);
+    return pdfrect;
+}
+
+
+-(CGPoint)to_parent_point:(CGRect)parentRect point:(CGPoint)p offsetX:(double)x offsetY:(double)y
+{
+    //return CGRectMake(parentRect.origin.x+self.margin_left+rect.origin.x, parentRect.size.height-self.margin_top-self.rect.origin.y-self.rect.size.height, rect.size.width-self.margin_right, rect.size.height-self.margin_bottom);
+    
+    return CGPointMake(parentRect.origin.x+ p.x, parentRect.origin.y+p.y);
+}
+
+-(CGPoint)to_pdf_point:(CGRect)parentRect point:(CGPoint)p contextHeight:(double) height
+{
+    
+    CGPoint pdfpoint=[self to_parent_point:parentRect point:p offsetX:0 offsetY:0];
+    
+    pdfpoint = CGPointMake(pdfpoint.x, height-pdfpoint.y);
+    return pdfpoint;
+}
+
+//-(void) Draw:(CGContextRef) context startX:(double) x startY:(double) y
+//{
+//
+//}
+
+@end

+ 35 - 0
RedAnt ERP Mobile/common/pdfCreator/PDFPage.h

@@ -0,0 +1,35 @@
+//
+//  PDFPage.h
+//  pdftest
+//
+//  Created by Ray on 10/11/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+#import "UIKit/UIDocument.h"
+#import "PDFDrawable.h"
+@interface PDFPage : NSObject<PDFDrawableDelegate>
+@property (nonatomic,strong) NSMutableDictionary* pageTemplate;
+@property double margin_left;
+@property double margin_right;
+@property double margin_top;
+@property double margin_bottom;
+
+@property (nonatomic,strong) NSMutableDictionary* header;
+@property (nonatomic,strong) NSMutableDictionary* footer;
+
+@property CGRect rect;
+@property CGRect drawable_rect;
+@property double pos_x;
+@property double pos_y;
+-(instancetype) init:(NSMutableDictionary *)page size:(CGRect)rect;
+-(void) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data;
+-(int) QueryPageCount:(CGContextRef) context dataSource:(NSMutableDictionary*)data;
+
+@property (nonatomic,strong) NSMutableDictionary* data;
+
+@property int pagecount;
+
+@end

+ 230 - 0
RedAnt ERP Mobile/common/pdfCreator/PDFPage.m

@@ -0,0 +1,230 @@
+//
+//  PDFPage.m
+//  pdftest
+//
+//  Created by Ray on 10/11/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "PDFPage.h"
+#import "GroupDrawable.h"
+#import "ImageDrawable.h"
+#import "LineDrawable.h"
+#import "TextDrawable.h"
+#import "TableDrawable.h"
+#import "GridDrawable.h"
+
+@implementation PDFPage
+-(instancetype) init:(NSMutableDictionary *)page size:(CGRect)rect
+{
+   if (self = [super init]) {
+       self.rect = rect;
+       [self setPageTemplate:page];
+       self.pagecount=1;
+          }
+     return self;
+    
+    
+
+}
+-(void) setPageTemplate:(NSMutableDictionary *)pageTemplate
+{
+    _pageTemplate = pageTemplate;
+    self.margin_left=[self.pageTemplate[@"margin_left"] doubleValue];
+    self.margin_right=[self.pageTemplate[@"margin_right"] doubleValue];
+    self.margin_top=[self.pageTemplate[@"margin_top"] doubleValue];
+    self.margin_bottom=[self.pageTemplate[@"margin_bottom"] doubleValue];
+    self.header=self.pageTemplate[@"header"];
+    self.footer=self.pageTemplate[@"footer"];
+    
+    
+    self.drawable_rect = CGRectMake(self.rect.origin.x+self.margin_left, self.rect.origin.y+self.margin_top, self.rect.size.width-self.margin_right, self.rect.size.height-self.margin_bottom);
+    
+    self.pos_x = _margin_left;
+    self.pos_y = _margin_top;
+    
+   // self.rect = CGRectMake(0, 0, [self.pageTemplate[@"width"] doubleValue], [self.pageTemplate[@"height"] doubleValue]);
+}
+-(int) QueryPageCount:(CGContextRef) context dataSource:(NSMutableDictionary*)data
+{
+    
+    
+    
+    
+    self.data=data;
+    GroupDrawable* pageHeader = [[GroupDrawable alloc]init:self.header];
+    
+    pageHeader.delegate = self;
+    GroupDrawable* pageFooter = [[GroupDrawable alloc]init:self.footer];
+    
+    pageFooter.delegate = self;
+    
+    
+    
+    
+    // while (true)
+    {
+        // page 去除页眉,页脚后的区域
+        NSRange range = NSMakeRange(self.drawable_rect.origin.y+pageHeader.rect.size.height, self.drawable_rect.origin.y+self.drawable_rect.size.height-pageFooter.rect.size.height);
+        
+        CGRect rect = self.rect;
+        
+ //       CGContextBeginPage(context, &rect);
+ //       [pageHeader Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
+        
+        
+        for (int i=0;i<[self.pageTemplate[@"contents"][@"count"] intValue];i++)
+        {
+            NSMutableDictionary * item =self.pageTemplate[@"contents"][ [NSString stringWithFormat:@"item_%d",i ] ];
+            PDFDrawable* drawable_obj=nil;
+            if([item[@"type"] isEqualToString:@"img"])
+            {
+                drawable_obj= [[ImageDrawable alloc] init:item];
+                
+            }
+            else if([item[@"type"] isEqualToString:@"line"])
+            {
+                drawable_obj= [[LineDrawable alloc] init:item];
+                
+            }
+            else if([item[@"type"] isEqualToString:@"text"])
+            {
+                drawable_obj= [[TextDrawable alloc] init:item];
+                
+            }
+            else if([item[@"type"] isEqualToString:@"group"])
+            {
+                drawable_obj= [[GroupDrawable alloc] init:item];
+                
+            }
+            else if([item[@"type"] isEqualToString:@"table"])
+            {
+                drawable_obj= [[TableDrawable alloc] init:item];
+                
+            }
+            else if([item[@"type"] isEqualToString:@"grid"])
+            {
+                drawable_obj= [[GridDrawable alloc] init:item];
+                
+            }
+            drawable_obj.delegate = self;
+            [drawable_obj Query_Rect:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:self.pos_x startY:_pos_y flipHeight:self.rect.size.height range:range];
+        }
+        
+    //    [pageFooter Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
+    //    CGContextEndPage(context);
+        
+    }
+    
+    return self.pagecount;
+}
+-(void) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data
+{
+    
+    
+    
+    
+    self.data=data;
+    GroupDrawable* pageHeader = [[GroupDrawable alloc]init:self.header];
+    
+    pageHeader.delegate = self;
+    GroupDrawable* pageFooter = [[GroupDrawable alloc]init:self.footer];
+    
+    pageFooter.delegate = self;
+    
+    
+    
+    
+   // while (true)
+    {
+        // page 去除页眉,页脚后的区域
+        NSRange range = NSMakeRange(self.drawable_rect.origin.y+pageHeader.rect.size.height, self.drawable_rect.origin.y+self.drawable_rect.size.height-pageFooter.rect.size.height);
+
+        CGRect rect = self.rect;
+        
+        CGContextBeginPage(context, &rect);
+        [pageHeader Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
+        
+        
+        for (int i=0;i<[self.pageTemplate[@"contents"][@"count"] intValue];i++)
+        {
+            NSMutableDictionary * item =self.pageTemplate[@"contents"][ [NSString stringWithFormat:@"item_%d",i ] ];
+            PDFDrawable* drawable_obj=nil;
+            if([item[@"type"] isEqualToString:@"img"])
+            {
+                drawable_obj= [[ImageDrawable alloc] init:item];
+                
+            }
+            else if([item[@"type"] isEqualToString:@"line"])
+            {
+                drawable_obj= [[LineDrawable alloc] init:item];
+                
+            }
+            else if([item[@"type"] isEqualToString:@"text"])
+            {
+                drawable_obj= [[TextDrawable alloc] init:item];
+                
+            }
+            else if([item[@"type"] isEqualToString:@"group"])
+            {
+                drawable_obj= [[GroupDrawable alloc] init:item];
+                
+            }
+            else if([item[@"type"] isEqualToString:@"table"])
+            {
+                drawable_obj= [[TableDrawable alloc] init:item];
+                
+            }
+            else if([item[@"type"] isEqualToString:@"grid"])
+            {
+                drawable_obj= [[GridDrawable alloc] init:item];
+                
+            }
+            drawable_obj.delegate = self;
+            [drawable_obj Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:self.pos_x startY:_pos_y flipHeight:self.rect.size.height range:range];
+        }
+
+        [pageFooter Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
+        CGContextEndPage(context);
+        
+    }
+}
+-(void) nextPage:(CGContextRef) context
+{
+    CGContextEndPage(context);
+    CGRect rect = self.rect;
+    
+    CGContextBeginPage(context, &rect);
+    
+
+    
+    GroupDrawable* pageHeader = [[GroupDrawable alloc]init:self.header];
+    pageHeader.delegate = self;
+    GroupDrawable* pageFooter = [[GroupDrawable alloc]init:self.footer];
+    pageFooter.delegate = self;
+    
+    // page 去除页眉,页脚后的区域
+    NSRange range = NSMakeRange(self.drawable_rect.origin.y+pageHeader.rect.size.height, self.drawable_rect.origin.y+self.drawable_rect.size.height-pageFooter.rect.size.height);
+
+    
+    [pageHeader Draw:context dataSource:self.data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
+    
+    
+    
+    
+    
+    [pageFooter Draw:context dataSource:self.data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
+   
+    
+}
+
+#pragma mark - commoneditor delegate
+-(void) outofPage:(CGContextRef) context
+{
+    [self nextPage:context];
+}
+-(void) addPageCount:(CGContextRef)context
+{
+    self.pagecount++;
+}
+@end

+ 13 - 0
RedAnt ERP Mobile/common/pdfCreator/TableDrawable.h

@@ -0,0 +1,13 @@
+//
+//  TableDrawable.h
+//  pdftest
+//
+//  Created by Ray on 10/18/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "PDFDrawable.h"
+
+@interface TableDrawable : PDFDrawable
+
+@end

+ 109 - 0
RedAnt ERP Mobile/common/pdfCreator/TableDrawable.m

@@ -0,0 +1,109 @@
+//
+//  TableDrawable.m
+//  pdftest
+//
+//  Created by Ray on 10/18/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "TableDrawable.h"
+#import "GroupDrawable.h"
+
+@implementation TableDrawable
+
+-(CGRect) Query_Rect:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    NSMutableDictionary* table_data = data[self.drawableTemplate[@"data_source"]];
+    
+    NSMutableDictionary* rows = self.drawableTemplate[@"rows"];
+    int count = [rows[@"count"] intValue];
+    
+    //    CGRect pdfrect = /*CGRectMake(self.rect.origin.x+self.margin_left+p_rect.origin.x, self.rect.origin.y+self.margin_top+p_rect.origin.y, self.rect.size.width-self.margin_right, self.rect.size.height-self.margin_bottom);//*/[self to_pdf_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    
+    CGRect pdfrect =  [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    CGRect parentrect =[self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    for(int i=0;i<count;i++)
+    {
+        NSMutableDictionary * rowjson =rows[ [NSString stringWithFormat:@"row_%d",i ] ];
+        PDFDrawable* drawable_obj= [[GroupDrawable alloc] init:rowjson];
+        drawable_obj.delegate = self.delegate;
+        NSMutableDictionary* rows_data = table_data[rowjson[@"data_source"]];
+        int row_data_count=[rows_data[@"count"] intValue];
+        float dy=0;
+        for(int j=0;j<row_data_count;j++)
+        {
+            
+            
+            
+            NSMutableDictionary * row_data =rows_data[ [NSString stringWithFormat:@"item_%d",j ] ];
+            CGRect row_rect= [drawable_obj Query_Rect:context dataSource:row_data ParentRect:(CGRect)pdfrect startX:0 startY:dy flipHeight:flip_height range:between_header_and_footer];
+            if(dy+row_rect.size.height> between_header_and_footer.location+between_header_and_footer.length)
+            {
+                //越界,新起一页
+                if (self.delegate && [self.delegate respondsToSelector:@selector(outofPage:)]) {
+                    [self.delegate addPageCount:context];
+                    dy=0;
+                }
+            }
+         //   [drawable_obj Draw:context dataSource:row_data ParentRect:(CGRect)pdfrect startX:0 startY:dy flipHeight:flip_height range:between_header_and_footer];
+            dy+=row_rect.size.height;
+            //            pos = CGPointMake(0, rowpos.y+pos.y);
+        }
+        
+    }
+    
+    return parentrect;
+}
+
+-(CGRect) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    
+    
+    NSMutableDictionary* table_data = data[self.drawableTemplate[@"data_source"]];
+
+    NSMutableDictionary* rows = self.drawableTemplate[@"rows"];
+    int count = [rows[@"count"] intValue];
+    
+    //    CGRect pdfrect = /*CGRectMake(self.rect.origin.x+self.margin_left+p_rect.origin.x, self.rect.origin.y+self.margin_top+p_rect.origin.y, self.rect.size.width-self.margin_right, self.rect.size.height-self.margin_bottom);//*/[self to_pdf_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    
+    CGRect pdfrect =  [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    CGRect parentrect =[self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    for(int i=0;i<count;i++)
+    {
+        NSMutableDictionary * rowjson =rows[ [NSString stringWithFormat:@"row_%d",i ] ];
+        PDFDrawable* drawable_obj= [[GroupDrawable alloc] init:rowjson];
+        drawable_obj.delegate = self.delegate;
+        NSMutableDictionary* rows_data = table_data[rowjson[@"data_source"]];
+        int row_data_count=[rows_data[@"count"] intValue];
+        float dy=0;
+        for(int j=0;j<row_data_count;j++)
+        {
+
+            
+            
+            NSMutableDictionary * row_data =rows_data[ [NSString stringWithFormat:@"item_%d",j ] ];
+            CGRect row_rect= [drawable_obj Query_Rect:context dataSource:row_data ParentRect:(CGRect)pdfrect startX:0 startY:dy flipHeight:flip_height range:between_header_and_footer];
+            if(dy+row_rect.size.height> between_header_and_footer.location+between_header_and_footer.length)
+            {
+                //越界,新起一页
+                if (self.delegate && [self.delegate respondsToSelector:@selector(outofPage:)]) {
+                    [self.delegate outofPage:context];
+                    dy=0;
+                }
+            }
+             [drawable_obj Draw:context dataSource:row_data ParentRect:(CGRect)pdfrect startX:0 startY:dy flipHeight:flip_height range:between_header_and_footer];
+            dy+=row_rect.size.height;
+//            pos = CGPointMake(0, rowpos.y+pos.y);
+        }
+        
+    }
+    
+    return parentrect;
+    //return CGPointMake(parentrect.origin.x+parentrect.size.width, parentrect.origin.y+parentrect.size.height);
+    //    if (self.delegate && [self.delegate respondsToSelector:@selector(outofPage:)]) {
+    //        [self.delegate outofPage:context];
+    //    }
+}
+@end

+ 22 - 0
RedAnt ERP Mobile/common/pdfCreator/TextDrawable.h

@@ -0,0 +1,22 @@
+//
+//  TextDrawable.h
+//  pdftest
+//
+//  Created by Ray on 10/12/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "BasicDrawable.h"
+
+@interface TextDrawable : BasicDrawable
+
+@property (nonatomic,strong) NSString* text;
+@property NSRange textRange;
+@property double lineSpace;
+@property double characterSpace;
+@property double paragraphSpace;
+
+@property (nonatomic,strong) UIColor * textColor;
+
+@property CTTextAlignment alignment;
+@end

+ 565 - 0
RedAnt ERP Mobile/common/pdfCreator/TextDrawable.m

@@ -0,0 +1,565 @@
+//
+//  TextDrawable.m
+//  pdftest
+//
+//  Created by Ray on 10/12/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "TextDrawable.h"
+#import <CoreText/CoreText.h>
+@implementation TextDrawable
+
+-(void) setDrawableTemplate:(NSMutableDictionary *)drawableTemplate
+{
+    
+    [super setDrawableTemplate:drawableTemplate];
+    
+
+    
+    NSString* align= drawableTemplate[@"align"];
+    if(align.length==0 || [align isEqualToString:@"left"])
+    {
+        self.alignment= kCTTextAlignmentLeft;
+    }
+    else if([align isEqualToString:@"right"])
+    {
+        self.alignment= kCTTextAlignmentRight;
+    }
+    else if([align isEqualToString:@"center"])
+    {
+        self.alignment= kCTTextAlignmentCenter;
+    }
+    else
+    {
+        self.alignment= kCTTextAlignmentLeft;
+    }
+    
+    NSString* colorvalue=drawableTemplate[@"color"];
+    if(colorvalue.length>0 )
+    {
+        unsigned long color = strtoul([colorvalue UTF8String],0,16);
+        self.textColor= UIColorFromRGB(color);
+    }
+   else
+   {
+       self.textColor= [UIColor blackColor];
+
+   }
+    
+    
+//    kCTTextAlignmentJustified CT_ENUM_AVAILABLE(10_8, 6_0) = 3,
+//    kCTTextAlignmentNatural   CT_ENUM_AVAILABLE(10_8, 6_0) = 4,
+
+    
+//    _drawableTemplate = drawableTemplate;
+//    self.margin_left=[self.drawableTemplate[@"margin_left"] doubleValue];
+//    self.margin_right=[self.drawableTemplate[@"margin_right"] doubleValue];
+//    self.margin_top=[self.drawableTemplate[@"margin_top"] doubleValue];
+//    self.margin_bottom=[self.drawableTemplate[@"margin_bottom"] doubleValue];
+//    self.rect = CGRectMake(0, 0, [self.drawableTemplate[@"width"] doubleValue], [self.drawableTemplate[@"height"] doubleValue]);
+}
+
+-(void) Draw3:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    CGRect pdfrect=[self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    
+    CGFloat fontsize = [self.drawableTemplate[@"size"] doubleValue];
+    
+    
+    
+    NSMutableAttributedString * string = [[NSMutableAttributedString alloc]initWithString:self.text] ;
+    
+    //创建字体以及字体大小
+    CTFontRef helvetica = CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);
+    CTFontRef helveticaBold = CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);
+    //字体,把helvetica 样式加到整个,string上
+    [string addAttribute:(id)kCTFontAttributeName
+                   value:CFBridgingRelease(helvetica)
+                   range:NSMakeRange(0, [string length])];
+    
+    //字体样式 ,把helveticaBold 样式加到整个,string上
+    [string addAttribute:(id)kCTFontAttributeName
+                   value:CFBridgingRelease(helveticaBold)
+                   range:NSMakeRange(0, [string length])];
+    
+    //颜色,此处为黑色,你可以自己改颜色,[UIColor redColor]
+    [string addAttribute:(id)kCTForegroundColorAttributeName
+                   value:(id)self.textColor.CGColor
+                   range:NSMakeRange(0, [string length])];
+    //设置字体间距
+    long number = self.characterSpace;
+    CFNumberRef num = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt8Type, &number);
+    [string addAttribute:(id)kCTKernAttributeName value:CFBridgingRelease(num) range:NSMakeRange(0, [string length])];
+    CFRelease(num);
+    
+    
+    
+    
+    //创建文本对齐方式
+    CTTextAlignment alignment = self.alignment;//对齐方
+    CTParagraphStyleSetting alignmentStyle;
+    alignmentStyle.spec=kCTParagraphStyleSpecifierAlignment;
+    alignmentStyle.valueSize=sizeof(alignment);
+    alignmentStyle.value=&alignment;
+    
+    //创建文本,    行间距
+    CGFloat lineSpace=self.lineSpace;//间距数据
+    CTParagraphStyleSetting lineSpaceStyle;
+    lineSpaceStyle.spec=kCTParagraphStyleSpecifierLineSpacing;
+    lineSpaceStyle.valueSize=sizeof(lineSpace);
+    lineSpaceStyle.value=&lineSpace;
+    
+    
+    //设置  段落间距
+    CGFloat paragraph = self.paragraphSpace;
+    CTParagraphStyleSetting paragraphStyle;
+    paragraphStyle.spec = kCTParagraphStyleSpecifierParagraphSpacing;
+    paragraphStyle.valueSize = sizeof(CGFloat);
+    paragraphStyle.value = &paragraph;
+    
+    
+    
+    
+    //创建样式数组
+    CTParagraphStyleSetting settings[]={
+        alignmentStyle,lineSpaceStyle,paragraphStyle
+    };
+    
+    //设置样式
+    CTParagraphStyleRef paragraphStyle1 = CTParagraphStyleCreate(settings, sizeof(settings));
+    
+    //给字符串添加样式attribute
+ //   [string addAttribute:(id)kCTParagraphStyleAttributeName
+//                   value:(id)paragraphStyle1
+//                   range:NSMakeRange(0, [string length])];
+
+    
+    
+//    [super flipContext:context ContextHeight:flip_height];
+    
+    
+    
+    // 切换上下文 Core Graphics 和 UIKit 混用
+    UIGraphicsPushContext(context);
+    
+    
+//    NSMutableDictionary* attribute = [[NSMutableDictionary alloc]init];
+//    
+
+//
+//    attribute[NSFontAttributeName]=[UIFont systemFontOfSize:fontsize];
+//    
+//    
+//    
+//    attribute[NSForegroundColorAttributeName]=self.textColor;
+    
+ 
+
+//
+//
+//    UIKIT_EXTERN NSString * const NSParagraphStyleAttributeName NS_AVAILABLE(10_0, 6_0);      // NSParagraphStyle, default defaultParagraphStyle
+//    UIKIT_EXTERN NSString * const NSBackgroundColorAttributeName NS_AVAILABLE(10_0, 6_0);     // UIColor, default nil: no background
+//    UIKIT_EXTERN NSString * const NSLigatureAttributeName NS_AVAILABLE(10_0, 6_0);            // NSNumber containing integer, default 1: default ligatures, 0: no ligatures
+//    UIKIT_EXTERN NSString * const NSKernAttributeName NS_AVAILABLE(10_0, 6_0);                // NSNumber containing floating point value, in points; amount to modify default kerning. 0 means kerning is disabled.
+//    UIKIT_EXTERN NSString * const NSStrikethroughStyleAttributeName NS_AVAILABLE(10_0, 6_0);  // NSNumber containing integer, default 0: no strikethrough
+//    UIKIT_EXTERN NSString * const NSUnderlineStyleAttributeName NS_AVAILABLE(10_0, 6_0);      // NSNumber containing integer, default 0: no underline
+//    UIKIT_EXTERN NSString * const NSStrokeColorAttributeName NS_AVAILABLE(10_0, 6_0);         // UIColor, default nil: same as foreground color
+//    UIKIT_EXTERN NSString * const NSStrokeWidthAttributeName NS_AVAILABLE(10_0, 6_0);         // NSNumber containing floating point value, in percent of font point size, default 0: no stroke; positive for stroke alone, negative for stroke and fill (a typical value for outlined text would be 3.0)
+//    UIKIT_EXTERN NSString * const NSShadowAttributeName NS_AVAILABLE(10_0, 6_0);              // NSShadow, default nil: no shadow
+//    UIKIT_EXTERN NSString *const NSTextEffectAttributeName NS_AVAILABLE(10_10, 7_0);          // NSString, default nil: no text effect
+//    
+//    UIKIT_EXTERN NSString * const NSAttachmentAttributeName NS_AVAILABLE(10_0, 7_0);          // NSTextAttachment, default nil
+//    UIKIT_EXTERN NSString * const NSLinkAttributeName NS_AVAILABLE(10_0, 7_0);                // NSURL (preferred) or NSString
+//    UIKIT_EXTERN NSString * const NSBaselineOffsetAttributeName NS_AVAILABLE(10_0, 7_0);      // NSNumber containing floating point value, in points; offset from baseline, default 0
+//    UIKIT_EXTERN NSString * const NSUnderlineColorAttributeName NS_AVAILABLE(10_0, 7_0);      // UIColor, default nil: same as foreground color
+//    UIKIT_EXTERN NSString * const NSStrikethroughColorAttributeName NS_AVAILABLE(10_0, 7_0);  // UIColor, default nil: same as foreground color
+//    UIKIT_EXTERN NSString * const NSObliquenessAttributeName NS_AVAILABLE(10_0, 7_0);         // NSNumber containing floating point value; skew to be applied to glyphs, default 0: no skew
+//    UIKIT_EXTERN NSString * const NSExpansionAttributeName NS_AVAILABLE(10_0, 7_0);           // NSNumber containing floating point value; log of expansion factor to be applied to glyphs, default 0: no expansion
+//    
+//    UIKIT_EXTERN NSString * const NSWritingDirectionAttributeName NS_AVAILABLE(10_6, 7_0);    // NSArray of NSNumbers representing the nested levels of writing direction overrides as defined by Unicode LRE, RLE, LRO, and RLO characters.  The control characters can be obtained by masking NSWritingDirection and NSWritingDirectionFormatType values.  LRE: NSWritingDirectionLeftToRight|NSWritingDirectionEmbedding, RLE: NSWritingDirectionRightToLeft|NSWritingDirectionEmbedding, LRO: NSWritingDirectionLeftToRight|NSWritingDirectionOverride, RLO: NSWritingDirectionRightToLeft|NSWritingDirectionOverride,
+//    
+//    UIKIT_EXTERN NSString * const NSVerticalGlyphFormAttributeName NS_AVAILABLE(10_7, 6_0);   // An NSNumber containing an integer value.  0 means horizontal text.  1 indicates vertical text.  If not specified, it could follow higher-level vertical orientation settings.  Currently on iOS, it's always horizontal.  The behavior for any other value is undefined.
+//    
+//    
+
+    
+    
+    // 使用UIKit绘制内容
+ //   [self.text drawInRect:pdfrect withAttributes:attribute];
+    
+
+
+    [string drawInRect:pdfrect];
+    
+    // 绘制完位图后,再恢复上下文
+    UIGraphicsPopContext();
+    
+//    [super restoreFlip:context ContextHeight:flip_height];
+    
+}
+-(CGRect) Query_Rect:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    CGRect parentrect = [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    return parentrect;
+}
+-(CGRect) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    
+    
+    
+    
+    
+    NSString * source=self.drawableTemplate[@"source_type"];
+    if(source==nil)
+        source=@"const";
+    if([source isEqualToString:@"const"])
+    {
+        self.text=self.drawableTemplate[@"text"];
+        
+    }
+    else
+    {
+        
+        // not impl;
+        
+        self.text=data[self.drawableTemplate[@"source"]];
+    }
+    
+//    [super flipContext:context ContextHeight:flip_height];
+   // super flipContext:context ContextHeight:<#(double)#>
+            CGFloat fontsize = [self.drawableTemplate[@"size"] doubleValue];
+    
+    
+    //创建AttributeStringfdsa
+    NSMutableAttributedString *string = [[NSMutableAttributedString alloc]
+                                         initWithString:self.text];
+    //创建字体以及字体大小
+    CTFontRef helvetica = CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);
+    CTFontRef helveticaBold = CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);
+    //字体,把helvetica 样式加到整个,string上
+    [string addAttribute:(id)kCTFontAttributeName
+                   value:CFBridgingRelease(helvetica)
+                   range:NSMakeRange(0, [string length])];
+    
+    //字体样式 ,把helveticaBold 样式加到整个,string上
+    [string addAttribute:(id)kCTFontAttributeName
+                   value:CFBridgingRelease(helveticaBold)
+                   range:NSMakeRange(0, [string length])];
+    
+    //颜色,此处为黑色,你可以自己改颜色,[UIColor redColor]
+    [string addAttribute:(id)kCTForegroundColorAttributeName
+                   value:(id)self.textColor.CGColor
+                   range:NSMakeRange(0, [string length])];
+    
+
+    
+    
+    //设置字体间距
+    long number = self.characterSpace;
+    CFNumberRef num = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt8Type, &number);
+    [string addAttribute:(id)kCTKernAttributeName value:CFBridgingRelease(num) range:NSMakeRange(0, [string length])];
+    CFRelease(num);
+    
+    
+    //创建文本对齐方式
+    CTTextAlignment alignment = self.alignment;//对齐方
+    CTParagraphStyleSetting alignmentStyle;
+    alignmentStyle.spec=kCTParagraphStyleSpecifierAlignment;
+    alignmentStyle.valueSize=sizeof(alignment);
+    alignmentStyle.value=&alignment;
+    
+    //创建文本,    行间距
+    CGFloat lineSpace=self.lineSpace;//间距数据
+    CTParagraphStyleSetting lineSpaceStyle;
+    lineSpaceStyle.spec=kCTParagraphStyleSpecifierLineSpacing;
+    lineSpaceStyle.valueSize=sizeof(lineSpace);
+    lineSpaceStyle.value=&lineSpace;
+    
+    
+    //设置  段落间距
+    CGFloat paragraph = self.paragraphSpace;
+    CTParagraphStyleSetting paragraphStyle;
+    paragraphStyle.spec = kCTParagraphStyleSpecifierParagraphSpacing;
+    paragraphStyle.valueSize = sizeof(CGFloat);
+    paragraphStyle.value = &paragraph;
+    
+    
+    
+    
+    //创建样式数组
+    CTParagraphStyleSetting settings[]={
+        alignmentStyle,lineSpaceStyle,paragraphStyle
+    };
+    
+    //设置样式
+    CTParagraphStyleRef paragraphStyle1 = CTParagraphStyleCreate(settings, sizeof(settings));
+    
+    //给字符串添加样式attribute
+    [string addAttribute:(id)kCTParagraphStyleAttributeName
+                   value:(id)paragraphStyle1
+                   range:NSMakeRange(0, [string length])];
+   //     CGRect pdfrect=[self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+   // [string drawInRect:pdfrect];
+    
+    
+ //   [self.text drawInRect:pdfrect withAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:40],NSForegroundColorAttributeName : [UIColor redColor]}];
+ 
+    // layout master
+    CTFramesetterRef  framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)string);
+    //计算文本绘制size ,这里300是文字宽度,你可以自己更改为247,但是要记得,在height 方法里的这个位置,也改为247
+    CGSize tmpSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0,0), NULL, CGSizeMake(self.rect.size.width, MAXFLOAT), NULL);
+    //创建textBoxSize以设置view的frame
+    CGSize textBoxSize = CGSizeMake((int)tmpSize.width + 1, (int)tmpSize.height + 1);
+    //    NSLog(@"textBoxSize0  == %f,%f,%f",textBoxSize.width,textBoxSize.height,textBoxSize.width / textBoxSize.height);
+ //   self.frame = CGRectMake(0, 0, textBoxSize.width , textBoxSize.height);
+//    [string release];
+    
+    //- (void)drawRect:(CGRect)rect;代码
+    
+    
+    
+    
+    CGMutablePathRef leftColumnPath = CGPathCreateMutable();
+    
+    CGRect parentrect = [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
+    
+    CGRect pdfrect = [self to_pdf_rect:p_rect pos:self.rect contextHeight:flip_height];
+  //  pdfrect=CGRectMake(pdfrect.origin.x, flip_height-pdfrect.origin.y, pdfrect.size.width, pdfrect.size.height);
+    CGPathAddRect(leftColumnPath, NULL,
+                  pdfrect);
+    
+    CTFrameRef leftFrame = CTFramesetterCreateFrame(framesetter,
+                                                    CFRangeMake(0, 0),
+                                                    leftColumnPath, NULL);
+    
+    //    NSLog(@"textBoxSize1  == %f,%f",self.frame.size.width,self.frame.size.height);
+    // flip the coordinate system
+//    CGContextRef context = UIGraphicsGetCurrentContext();
+    
+    
+//    CGContextClearRect(context, self.rect);
+//    CGContextSetFillColorWithColor(context, [[UIColor whiteColor]CGColor]);
+//    CGContextFillRect(context, CGRectMake(0, 0, self.rect.size.width, self.rect.size.height));
+    
+    
+    CGContextSetTextMatrix(context, CGAffineTransformIdentity);
+ //   CGContextTranslateCTM(context, 0, self.rect.size.height);
+ //   CGContextScaleCTM(context, 1.0, -1.0);
+    
+    // draw
+    CTFrameDraw(leftFrame, context);
+    
+    // cleanup
+    
+    CGPathRelease(leftColumnPath);
+    CFRelease(framesetter);
+    
+    
+    return parentrect;
+//    return CGPointMake(parentrect.origin.x+parentrect.size.width, parentrect.origin.y+parentrect.size.height);
+    
+//    [super restoreFlip:context ContextHeight:flip_height];
+}
+-(void) Draw1:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y
+{
+    
+//    self.attributedText.length
+//    
+//    if (context == NULL ||
+//        attributedText == nil ||
+//        attributedText.length == 0 ||
+//        CGRectIsEmpty(rect) ||
+//        textRange.length == 0) return;
+    
+    
+//    NSAttributedString* attributedText = [[NSAttributedString alloc]initWithString:self.text];
+    
+    CGContextSaveGState(context);
+    {
+        // Prepare font
+        CGFloat fontsize = [self.drawableTemplate[@"size"] doubleValue];
+        NSString* font = self.drawableTemplate[@"font"] ;
+        
+        if(font==nil)
+        {
+            font=@"STHeitiSC-Medium";
+        }
+        
+        
+        CTFontRef ctfont = CTFontCreateWithName(  (__bridge CFStringRef)font, fontsize, NULL);
+        
+        // text color
+        CGColorRef ctColor = [[UIColor greenColor] CGColor];
+        
+        
+        //text align
+        CTTextAlignment alignment = kCTRightTextAlignment; //文本对齐方式
+        CTParagraphStyleSetting alignmentStyle;
+        
+        alignmentStyle.spec=kCTParagraphStyleSpecifierAlignment;//指定为对齐属性
+        
+        alignmentStyle.valueSize=sizeof(alignment);
+        
+        alignmentStyle.value=&alignment;
+        
+        CTParagraphStyleSetting settings[]={
+            
+            alignmentStyle
+            
+        };//设置样式
+        
+        CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(settings, sizeof(settings));
+        
+        
+        
+        CGContextSetShouldSmoothFonts(context, YES);
+        CGContextSetShouldAntialias(context, YES);
+        
+        
+        // Create an attributed string
+        CFStringRef keys[] = { kCTFontAttributeName,kCTForegroundColorAttributeName,kCTParagraphStyleAttributeName };
+        CFTypeRef values[] = { ctfont,ctColor,paragraphStyle};
+        CFDictionaryRef attr = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values,
+                                                  sizeof(keys) / sizeof(keys[0]), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+        
+        
+        CFStringRef ctStr = CFStringCreateWithCString(nil, [self.text UTF8String], kCFStringEncodingUTF8);
+        CFAttributedStringRef attrString = CFAttributedStringCreate(NULL,ctStr, attr);
+        
+
+//        //给字符串添加样式attribute
+//        
+//        [resultAttributedStringaddAttribute:(id)kCTParagraphStyleAttributeName
+//                                      value:(id)paragraphStyle  
+//         
+//                                      range:NSMakeRange(0, [resultAttributedString length])];
+        
+        
+        
+        CTLineRef line = CTLineCreateWithAttributedString(attrString);
+        CGContextSetTextMatrix(context, CGAffineTransformIdentity);
+        //CGContextSetTextMatrix(context, CGAffineTransformMakeRotation(3.14));
+        //CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1.0, -1.0)); //Use this one if the view's coordinates are flipped
+        CGContextSetTextPosition(context, fontsize, fontsize);
+        CTLineDraw(line, context);
+        
+        
+        
+//        CFRelease(line);
+//        CFRelease(attrString);
+//        CFRelease(ctStr);
+//        
+//        CFStringRef ctStr2 = CFStringCreateWithCString(nil, [sY UTF8String], kCFStringEncodingUTF8);
+//        CFAttributedStringRef attrString2 = CFAttributedStringCreate(NULL,ctStr2, attr);
+//        CTLineRef line2 = CTLineCreateWithAttributedString(attrString2);
+//        CGContextSetTextMatrix(context, CGAffineTransformIdentity);
+//        CGContextSetTextPosition(context, s, 2*s);
+//        CTLineDraw(line2, context);
+//        
+//        CFRelease(line2);
+//        CFRelease(attrString2);
+//        CFRelease(ctStr2);
+//        
+//        CFStringRef ctStr3 = CFStringCreateWithCString(nil, [sZ UTF8String], kCFStringEncodingUTF8);
+//        CFAttributedStringRef attrString3 = CFAttributedStringCreate(NULL,ctStr3, attr);
+//        CTLineRef line3 = CTLineCreateWithAttributedString(attrString3);
+//        CGContextSetTextMatrix(context, CGAffineTransformIdentity);
+//        CGContextSetTextPosition(context, s, 3*s);
+//        CTLineDraw(line3, context);
+//        
+//        CFRelease(line3);
+//        CFRelease(attrString3);
+//        CFRelease(ctStr3);
+//        
+//        // Clean up
+//        CFRelease(attr);
+//        CFRelease(ctfont);
+    }
+    /* Restore the current graphics state from the one on the top of the
+     graphics state stack, popping the graphics state stack in the process. */
+    CGContextRestoreGState(context);
+}
+
+-(CGSize)height1:(NSString *)text Font:(CGFloat)font Character:(CGFloat)character Line:(CGFloat)line Pragraph:(CGFloat)pragraph
+{
+    
+    //创建AttributeStringfdsa
+    NSMutableAttributedString *string = [[NSMutableAttributedString alloc]
+                                         initWithString:text];
+    //创建字体以及字体大小
+    CTFontRef helvetica = CTFontCreateWithName(CFSTR("Helvetica"), font, NULL);
+    CTFontRef helveticaBold = CTFontCreateWithName(CFSTR("Helvetica"), font, NULL);
+    //添加字体目标字符串从下标0开始到字符串结尾
+    [string addAttribute:(id)kCTFontAttributeName
+                   value:CFBridgingRelease(helvetica)
+                   range:NSMakeRange(0, [string length])];
+    
+    //添加字体目标字符串从下标0开始,截止到4个单位的长度
+    [string addAttribute:(id)kCTFontAttributeName
+                   value:CFBridgingRelease(helveticaBold)
+                   range:NSMakeRange(0, [string length])];
+    
+    
+    [string addAttribute:(id)kCTForegroundColorAttributeName
+                   value:(id)[UIColor whiteColor].CGColor
+                   range:NSMakeRange(0, [string length])];
+    
+    CTTextAlignment alignment = kCTJustifiedTextAlignment;//这种对齐方式会自动调整,使左右始终对齐
+    CTParagraphStyleSetting alignmentStyle;
+    alignmentStyle.spec=kCTParagraphStyleSpecifierAlignment;//指定为对齐属性
+    alignmentStyle.valueSize=sizeof(alignment);
+    alignmentStyle.value=&alignment;
+    
+    
+    //设置字体间距
+    long number = character;
+    CFNumberRef num = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt8Type, &number);
+    [string addAttribute:(id)kCTKernAttributeName value:CFBridgingRelease(num) range:NSMakeRange(0, [string length])];
+    CFRelease(num);
+    
+    
+    
+    //创建文本行间距
+    CGFloat lineSpace=line;//间距数据
+    CTParagraphStyleSetting lineSpaceStyle;
+    lineSpaceStyle.spec=kCTParagraphStyleSpecifierLineSpacing;//指定为行间距属性
+    lineSpaceStyle.valueSize=sizeof(lineSpace);
+    lineSpaceStyle.value=&lineSpace;
+    
+    //设置段落间距
+    CGFloat paragraph = pragraph;
+    CTParagraphStyleSetting paragraphStyle;
+    paragraphStyle.spec = kCTParagraphStyleSpecifierParagraphSpacing;
+    paragraphStyle.valueSize = sizeof(CGFloat);
+    paragraphStyle.value = &paragraph;
+    
+    
+    //创建样式数组
+    CTParagraphStyleSetting settings[]={
+        alignmentStyle,lineSpaceStyle,paragraphStyle
+    };
+    
+    //设置样式
+    CTParagraphStyleRef paragraphStyle1 = CTParagraphStyleCreate(settings, sizeof(settings));
+    
+    //给字符串添加样式attribute
+    [string addAttribute:(id)kCTParagraphStyleAttributeName
+                   value:(id)paragraphStyle1
+                   range:NSMakeRange(0, [string length])];
+    
+    // layout master
+    CTFramesetterRef  framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)string);
+    //计算文本绘制size
+    CGSize tmpSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0,0), NULL, CGSizeMake(300, MAXFLOAT), NULL);
+    //创建textBoxSize以设置view的frame
+    CGSize textBoxSize = CGSizeMake((int)tmpSize.width + 1, (int)tmpSize.height + 1);
+    
+
+    
+    return textBoxSize;
+    
+}
+@end

+ 13 - 0
RedAnt ERP Mobile/common/pdfCreator/pdfCreator.h

@@ -0,0 +1,13 @@
+//
+//  pdfCreator.h
+//  iSales-NPD
+//
+//  Created by Ray on 10/21/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+@interface pdfCreator : NSObject
++(NSString*)CreatePdf:(NSMutableDictionary*) template dataSource:(NSMutableDictionary*)data;
+@end

+ 174 - 0
RedAnt ERP Mobile/common/pdfCreator/pdfCreator.m

@@ -0,0 +1,174 @@
+//
+//  pdfCreator.m
+//  iSales-NPD
+//
+//  Created by Ray on 10/21/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "pdfCreator.h"
+#import "UIKit/UIDocument.h"
+
+#import "PDFPage.h"
+@implementation pdfCreator
+
+
++(void) drawPage:(CGContextRef)context template:(NSMutableDictionary*) page size:(CGRect) rect dataSource:(NSMutableDictionary*)data
+{
+    
+    PDFPage* pdfPage = [[PDFPage alloc] init:page size:rect];
+    
+    [pdfPage Draw:context dataSource:data];
+    
+    //NSMutableDictionary* header=page[@"header"] ;
+    //    double margin_left=[page[@"margin_left"] doubleValue];
+    //    double margin_left=[page[@"margin_left"] doubleValue];
+}
++(int) QueryPageCount:(CGContextRef)context template:(NSMutableDictionary*) page size:(CGRect) rect dataSource:(NSMutableDictionary*)data
+{
+    
+    PDFPage* pdfPage = [[PDFPage alloc] init:page size:rect];
+    
+    return [pdfPage QueryPageCount:context dataSource:data];
+    
+    //NSMutableDictionary* header=page[@"header"] ;
+    //    double margin_left=[page[@"margin_left"] doubleValue];
+    //    double margin_left=[page[@"margin_left"] doubleValue];
+}
+
++(int)QueryTotalPage:(CGContextRef)pdfContext template:(NSMutableDictionary*) template dataSource:(NSMutableDictionary*)data
+{
+    
+    int count=0;
+    //获取路径
+    
+//    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);//坐标
+//    
+//    NSString *saveDirectory=[paths objectAtIndex:0];
+//    
+//    NSString *saveFileName=@"myPDF.pdf";
+//    
+//    NSString *newFilePath=[saveDirectory stringByAppendingPathComponent:saveFileName];
+//    
+//    const char *filename=[newFilePath UTF8String];
+//    
+//    NSLog(@"%@",newFilePath);
+    //设置页面大小 Letter纸
+    
+    CGRect papersize=CGRectMake(0, 0, [template[@"paper"][@"width"] intValue], [template[@"paper"][@"height"] intValue]);
+    
+    //关联上下文的对象
+    
+//    CGContextRef pdfContext;
+    
+//    CFStringRef path;
+//    
+//    CFURLRef url;
+//    
+//    path=CFStringCreateWithCString(NULL, filename, kCFStringEncodingUTF8);
+//    
+//    url=CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, 0);
+//    
+//    
+//    pdfContext=CGPDFContextCreateWithURL(url, &papersize, nil);
+//    
+    
+    NSMutableDictionary* pages=template[@"pages"];
+    for(int i=0;i<[pages[@"count"] intValue];i++)
+    {
+        NSMutableDictionary* page=pages[[ NSString stringWithFormat:@"page_%d",i ] ];
+        
+        count+=[self QueryPageCount:pdfContext template:page size:papersize dataSource:data];
+    }
+    //开始画pdf
+    
+    //    NSString *temtext=[[NSString alloc]init];
+    //
+    //    const char *text=(char *)[temtext UTF8String];
+    //
+    //    int  width;
+    //
+    //    int height;
+    //
+    
+    //    [self newpage:pdfContext size:papersize];
+    
+    
+    
+//    CGContextRelease(pdfContext);
+    return count;
+    
+}
+
+
++(NSString*)CreatePdf:(NSMutableDictionary*) template dataSource:(NSMutableDictionary*)data
+{
+    
+    
+
+    //获取路径
+    
+    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);//坐标
+    
+    NSString *saveDirectory=[paths objectAtIndex:0];
+    
+    NSString *saveFileName=@"myPDF.pdf";
+    
+    NSString *newFilePath=[saveDirectory stringByAppendingPathComponent:saveFileName];
+    
+    const char *filename=[newFilePath UTF8String];
+    
+    NSLog(@"%@",newFilePath);
+    //设置页面大小 Letter纸
+    
+    CGRect papersize=CGRectMake(0, 0, [template[@"paper"][@"width"] intValue], [template[@"paper"][@"height"] intValue]);
+    
+    //关联上下文的对象
+    
+    CGContextRef pdfContext;
+    
+    CFStringRef path;
+    
+    CFURLRef url;
+    
+    path=CFStringCreateWithCString(NULL, filename, kCFStringEncodingUTF8);
+    
+    url=CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, 0);
+    
+    
+    pdfContext=CGPDFContextCreateWithURL(url, &papersize, nil);
+    
+    
+    data[@"pages"][@"totalcount"]= [NSNumber numberWithInt:[self QueryTotalPage:pdfContext template:template dataSource:data]];
+    
+    NSMutableDictionary* pages=template[@"pages"];
+    for(int i=0;i<[pages[@"count"] intValue];i++)
+    {
+        NSMutableDictionary* page=pages[[ NSString stringWithFormat:@"page_%d",i ] ];
+        
+        [self drawPage:pdfContext template:page size:papersize dataSource:data];
+    }
+    //开始画pdf
+    
+    //    NSString *temtext=[[NSString alloc]init];
+    //
+    //    const char *text=(char *)[temtext UTF8String];
+    //
+    //    int  width;
+    //
+    //    int height;
+    //
+    
+    //    [self newpage:pdfContext size:papersize];
+    
+    
+    
+    CGContextRelease(pdfContext);
+    
+    NSURL* nsurl=CFBridgingRelease(url);
+    
+    return [nsurl absoluteString];
+    
+}
+
+@end

+ 68 - 0
RedAnt ERP Mobile/iSales-NPD.xcodeproj/project.pbxproj

@@ -35,6 +35,16 @@
 		710274251CC606C4009FD219 /* UserListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 710274241CC606C4009FD219 /* UserListViewController.m */; };
 		7111E5721C76C557004763B3 /* customer_info_template_edit.json in Resources */ = {isa = PBXBuildFile; fileRef = 7111E5711C76C557004763B3 /* customer_info_template_edit.json */; };
 		71131F921CA1372300DBF6E2 /* SimplifiedBuyingProgramViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 71131F911CA1372300DBF6E2 /* SimplifiedBuyingProgramViewController.m */; };
+		712AFED71DBA050200254965 /* BasicDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFEC61DBA050200254965 /* BasicDrawable.m */; };
+		712AFED81DBA050200254965 /* GridDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFEC81DBA050200254965 /* GridDrawable.m */; };
+		712AFED91DBA050200254965 /* GroupDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFECA1DBA050200254965 /* GroupDrawable.m */; };
+		712AFEDA1DBA050200254965 /* ImageDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFECC1DBA050200254965 /* ImageDrawable.m */; };
+		712AFEDB1DBA050200254965 /* LineDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFECE1DBA050200254965 /* LineDrawable.m */; };
+		712AFEDC1DBA050200254965 /* PDFDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFED01DBA050200254965 /* PDFDrawable.m */; };
+		712AFEDD1DBA050200254965 /* PDFPage.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFED21DBA050200254965 /* PDFPage.m */; };
+		712AFEDE1DBA050200254965 /* TableDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFED41DBA050200254965 /* TableDrawable.m */; };
+		712AFEDF1DBA050200254965 /* TextDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFED61DBA050200254965 /* TextDrawable.m */; };
+		712AFEE21DBA077F00254965 /* pdfCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFEE11DBA077F00254965 /* pdfCreator.m */; };
 		712BABF31C897E3A0007466B /* CategorySearchFilterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 712BABF21C897E3A0007466B /* CategorySearchFilterViewController.m */; };
 		712C40B61C7310F4000E6831 /* CartGeneralNotesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 712C40B51C7310F4000E6831 /* CartGeneralNotesViewController.m */; };
 		712C40B91C731126000E6831 /* ItemNotesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 712C40B81C731126000E6831 /* ItemNotesViewController.m */; };
@@ -265,6 +275,26 @@
 		7111E5711C76C557004763B3 /* customer_info_template_edit.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = customer_info_template_edit.json; path = common/Functions/contact/customer_info_template_edit.json; sourceTree = SOURCE_ROOT; };
 		71131F901CA1372300DBF6E2 /* SimplifiedBuyingProgramViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SimplifiedBuyingProgramViewController.h; path = common/Functions/sidemenu/SimplifiedBuyingProgramViewController.h; sourceTree = SOURCE_ROOT; };
 		71131F911CA1372300DBF6E2 /* SimplifiedBuyingProgramViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SimplifiedBuyingProgramViewController.m; path = common/Functions/sidemenu/SimplifiedBuyingProgramViewController.m; sourceTree = SOURCE_ROOT; };
+		712AFEC51DBA050200254965 /* BasicDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BasicDrawable.h; path = common/pdfCreator/BasicDrawable.h; sourceTree = SOURCE_ROOT; };
+		712AFEC61DBA050200254965 /* BasicDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BasicDrawable.m; path = common/pdfCreator/BasicDrawable.m; sourceTree = SOURCE_ROOT; };
+		712AFEC71DBA050200254965 /* GridDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GridDrawable.h; path = common/pdfCreator/GridDrawable.h; sourceTree = SOURCE_ROOT; };
+		712AFEC81DBA050200254965 /* GridDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GridDrawable.m; path = common/pdfCreator/GridDrawable.m; sourceTree = SOURCE_ROOT; };
+		712AFEC91DBA050200254965 /* GroupDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GroupDrawable.h; path = common/pdfCreator/GroupDrawable.h; sourceTree = SOURCE_ROOT; };
+		712AFECA1DBA050200254965 /* GroupDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GroupDrawable.m; path = common/pdfCreator/GroupDrawable.m; sourceTree = SOURCE_ROOT; };
+		712AFECB1DBA050200254965 /* ImageDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ImageDrawable.h; path = common/pdfCreator/ImageDrawable.h; sourceTree = SOURCE_ROOT; };
+		712AFECC1DBA050200254965 /* ImageDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImageDrawable.m; path = common/pdfCreator/ImageDrawable.m; sourceTree = SOURCE_ROOT; };
+		712AFECD1DBA050200254965 /* LineDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LineDrawable.h; path = common/pdfCreator/LineDrawable.h; sourceTree = SOURCE_ROOT; };
+		712AFECE1DBA050200254965 /* LineDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LineDrawable.m; path = common/pdfCreator/LineDrawable.m; sourceTree = SOURCE_ROOT; };
+		712AFECF1DBA050200254965 /* PDFDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFDrawable.h; path = common/pdfCreator/PDFDrawable.h; sourceTree = SOURCE_ROOT; };
+		712AFED01DBA050200254965 /* PDFDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PDFDrawable.m; path = common/pdfCreator/PDFDrawable.m; sourceTree = SOURCE_ROOT; };
+		712AFED11DBA050200254965 /* PDFPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPage.h; path = common/pdfCreator/PDFPage.h; sourceTree = SOURCE_ROOT; };
+		712AFED21DBA050200254965 /* PDFPage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PDFPage.m; path = common/pdfCreator/PDFPage.m; sourceTree = SOURCE_ROOT; };
+		712AFED31DBA050200254965 /* TableDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TableDrawable.h; path = common/pdfCreator/TableDrawable.h; sourceTree = SOURCE_ROOT; };
+		712AFED41DBA050200254965 /* TableDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TableDrawable.m; path = common/pdfCreator/TableDrawable.m; sourceTree = SOURCE_ROOT; };
+		712AFED51DBA050200254965 /* TextDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextDrawable.h; path = common/pdfCreator/TextDrawable.h; sourceTree = SOURCE_ROOT; };
+		712AFED61DBA050200254965 /* TextDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextDrawable.m; path = common/pdfCreator/TextDrawable.m; sourceTree = SOURCE_ROOT; };
+		712AFEE01DBA077F00254965 /* pdfCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pdfCreator.h; path = common/pdfCreator/pdfCreator.h; sourceTree = SOURCE_ROOT; };
+		712AFEE11DBA077F00254965 /* pdfCreator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = pdfCreator.m; path = common/pdfCreator/pdfCreator.m; sourceTree = SOURCE_ROOT; };
 		712BABF11C897E3A0007466B /* CategorySearchFilterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CategorySearchFilterViewController.h; path = common/Functions/category/CategorySearchFilterViewController.h; sourceTree = SOURCE_ROOT; };
 		712BABF21C897E3A0007466B /* CategorySearchFilterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CategorySearchFilterViewController.m; path = common/Functions/category/CategorySearchFilterViewController.m; sourceTree = SOURCE_ROOT; };
 		712C40B41C7310F4000E6831 /* CartGeneralNotesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CartGeneralNotesViewController.h; path = common/Functions/cart/CartGeneralNotesViewController.h; sourceTree = SOURCE_ROOT; };
@@ -702,6 +732,33 @@
 			name = portfolio;
 			sourceTree = "<group>";
 		};
+		712AFEC41DBA044C00254965 /* pdfCreator */ = {
+			isa = PBXGroup;
+			children = (
+				712AFEC51DBA050200254965 /* BasicDrawable.h */,
+				712AFEC61DBA050200254965 /* BasicDrawable.m */,
+				712AFEC71DBA050200254965 /* GridDrawable.h */,
+				712AFEC81DBA050200254965 /* GridDrawable.m */,
+				712AFEC91DBA050200254965 /* GroupDrawable.h */,
+				712AFECA1DBA050200254965 /* GroupDrawable.m */,
+				712AFECB1DBA050200254965 /* ImageDrawable.h */,
+				712AFECC1DBA050200254965 /* ImageDrawable.m */,
+				712AFECD1DBA050200254965 /* LineDrawable.h */,
+				712AFECE1DBA050200254965 /* LineDrawable.m */,
+				712AFECF1DBA050200254965 /* PDFDrawable.h */,
+				712AFED01DBA050200254965 /* PDFDrawable.m */,
+				712AFED11DBA050200254965 /* PDFPage.h */,
+				712AFED21DBA050200254965 /* PDFPage.m */,
+				712AFED31DBA050200254965 /* TableDrawable.h */,
+				712AFED41DBA050200254965 /* TableDrawable.m */,
+				712AFED51DBA050200254965 /* TextDrawable.h */,
+				712AFED61DBA050200254965 /* TextDrawable.m */,
+				712AFEE01DBA077F00254965 /* pdfCreator.h */,
+				712AFEE11DBA077F00254965 /* pdfCreator.m */,
+			);
+			name = pdfCreator;
+			sourceTree = "<group>";
+		};
 		713393FE19936C980075BBAC /* Signature */ = {
 			isa = PBXGroup;
 			children = (
@@ -914,6 +971,7 @@
 		716387C71953CDB4006E65E6 /* utils */ = {
 			isa = PBXGroup;
 			children = (
+				712AFEC41DBA044C00254965 /* pdfCreator */,
 				42BED0141DAF74DF004576E0 /* JKLock */,
 				421C54FF1D81586D00CFA3B1 /* JKTimer */,
 				42E58BFF1D7E735A0092810A /* UIColor+HEX */,
@@ -1495,7 +1553,9 @@
 				7162A59D1C58733400AB630E /* OrderDetailViewController.m in Sources */,
 				7141DD3B1C5726B700F7DF59 /* DeviceInfo.m in Sources */,
 				71DF74671C575E7900F2789C /* EnumSelectorCell.m in Sources */,
+				712AFEDC1DBA050200254965 /* PDFDrawable.m in Sources */,
 				7195623C1CF57D1800C74A49 /* CategoryHeaderView.m in Sources */,
+				712AFED81DBA050200254965 /* GridDrawable.m in Sources */,
 				7162A5C11C5873BB00AB630E /* FilterCellCadedate.m in Sources */,
 				71DF748A1C57608F00F2789C /* RTLabel.m in Sources */,
 				71DF742B1C57560600F2789C /* Reachability.m in Sources */,
@@ -1515,6 +1575,7 @@
 				7141DD541C57459B00F7DF59 /* rscode.c in Sources */,
 				71DF74621C575E7900F2789C /* CommonEditorCellSignature.m in Sources */,
 				7162A5E01C5876E300AB630E /* SettingViewController.m in Sources */,
+				712AFEDB1DBA050200254965 /* LineDrawable.m in Sources */,
 				71DF748B1C57608F00F2789C /* SimpleGrid.m in Sources */,
 				42B99E131D7D032300E773CD /* SortItemViewController.m in Sources */,
 				71DF74651C575E7900F2789C /* CommonEditorViewController.m in Sources */,
@@ -1522,6 +1583,7 @@
 				71DF745B1C575E7900F2789C /* CommonEditorCellAction.m in Sources */,
 				7162A5411C58719D00AB630E /* RATreeNode.m in Sources */,
 				7162A5251C58706C00AB630E /* CategoryCellSmall.m in Sources */,
+				712AFEDA1DBA050200254965 /* ImageDrawable.m in Sources */,
 				4219B7EA1DADC48D0092B4DE /* Singleton.m in Sources */,
 				712C40B91C731126000E6831 /* ItemNotesViewController.m in Sources */,
 				7162A5AD1C58735900AB630E /* TearSheetParamViewController.m in Sources */,
@@ -1535,6 +1597,7 @@
 				426D40121DACB0990058B96B /* CategoryPriceViewController.m in Sources */,
 				426D40181DACC2250058B96B /* SetCategoryPriceController.m in Sources */,
 				7141DD621C5747CE00F7DF59 /* NSData+CommonCrypto.m in Sources */,
+				712AFED71DBA050200254965 /* BasicDrawable.m in Sources */,
 				71DF74891C57608F00F2789C /* RadioButton.m in Sources */,
 				7162A5DF1C5876E300AB630E /* ScannerSettingViewController.m in Sources */,
 				71DF74661C575E7900F2789C /* DatePickerViewController.m in Sources */,
@@ -1548,6 +1611,7 @@
 				719562421CF5828200C74A49 /* DefaultTableHeaderView.m in Sources */,
 				716AF8E11D7AA0E0001188E0 /* SelectUploadOrderViewController.m in Sources */,
 				42BED01B1DAF74DF004576E0 /* JKDotView.m in Sources */,
+				712AFEDF1DBA050200254965 /* TextDrawable.m in Sources */,
 				42F637521DB2178E00605C4B /* JKMessageBoxController.m in Sources */,
 				7162A5611C58724700AB630E /* CustomerInfoViewController.m in Sources */,
 				42B99E161D7D052A00E773CD /* SortItemCell.m in Sources */,
@@ -1581,6 +1645,7 @@
 				71D30A2D1CFC0EF8006F9477 /* DefaultImageButton.m in Sources */,
 				7162A5841C5872EF00AB630E /* HomeTableViewCellTopic.m in Sources */,
 				7162A59F1C58733400AB630E /* OrderListViewController.m in Sources */,
+				712AFEE21DBA077F00254965 /* pdfCreator.m in Sources */,
 				71BBA2401CEAEF0700C91DED /* ioapi.c in Sources */,
 				71DF74641C575E7900F2789C /* CommonEditorCellTextView.m in Sources */,
 				7162A5461C58719D00AB630E /* RATreeView+Enums.m in Sources */,
@@ -1593,10 +1658,12 @@
 				7162A54A1C58719D00AB630E /* RATreeView+UIScrollView.m in Sources */,
 				7162A55D1C58724700AB630E /* ContactListViewController.m in Sources */,
 				7162A5751C58728D00AB630E /* LineView.m in Sources */,
+				712AFEDD1DBA050200254965 /* PDFPage.m in Sources */,
 				7162A5741C58728D00AB630E /* DetailViewController.m in Sources */,
 				7162A52A1C58713200AB630E /* CategoryCellNPD.m in Sources */,
 				71DF748E1C57608F00F2789C /* UILabel+FontAppearance.m in Sources */,
 				712C40B61C7310F4000E6831 /* CartGeneralNotesViewController.m in Sources */,
+				712AFEDE1DBA050200254965 /* TableDrawable.m in Sources */,
 				7162A5CB1C58761500AB630E /* SignatureViewController.m in Sources */,
 				7162A5DD1C5876E300AB630E /* PopupNavigationController.m in Sources */,
 				7162A59E1C58733400AB630E /* OrderListTableViewCell.m in Sources */,
@@ -1656,6 +1723,7 @@
 				7162A5261C58706C00AB630E /* CategoryViewController.m in Sources */,
 				7162A50A1C586FC100AB630E /* NSTimer+Addition.m in Sources */,
 				71DF745E1C575E7900F2789C /* CommonEditorCellImg.m in Sources */,
+				712AFED91DBA050200254965 /* GroupDrawable.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};