Explorar el Código

161125
fix create pdf memory leak.

Ray Zhang hace 9 años
padre
commit
0ec02a9039

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


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 4 - 2345
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist


+ 1 - 1
RedAnt ERP Mobile/common/AES/NSString+Base64.h

@@ -7,7 +7,7 @@
 //
 
 #import <Foundation/NSString.h>
-
+#import<Foundation/Foundation.h>
 @interface NSString (Base64Additions)
 
 + (NSString *)base64StringFromData:(NSData *)data length:(NSUInteger)length;

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m


+ 2 - 0
RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m

@@ -396,6 +396,8 @@
                                             @"order_code" : self.order_code,
                                             } mutableCopy];
             NSData *dicData = [OLDataProvider  offline_request_salesorder:params];
+            if(dicData==nil)
+                return;
             NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:dicData options:NSJSONReadingMutableContainers error:nil];
             if ([dic[@"result"] integerValue] == RESULT_TRUE) {
                 NSString *path = dic[@"pdf_path"];

+ 1 - 0
RedAnt ERP Mobile/common/RAUtils.h

@@ -7,6 +7,7 @@
 //
 
 #import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
 //typedef  struct {
 //    
 //    NSString* id;

+ 16 - 2
RedAnt ERP Mobile/common/RAUtils.m

@@ -227,6 +227,7 @@
 
 +(UIImage*)generateBarCode:(NSString*)barCodeStr width:(CGFloat)width height:(CGFloat)height
 {
+    //return nil;
     // 生成二维码图片
     CIImage *barcodeImage;
     NSData *data = [barCodeStr dataUsingEncoding:NSISOLatin1StringEncoding allowLossyConversion:false];
@@ -242,7 +243,12 @@
     CIContext *context = [CIContext contextWithOptions:nil];
     CGImageRef cgImage = [context createCGImage:transformedImage fromRect:[transformedImage extent]];
     
-    return [UIImage imageWithCGImage:cgImage];
+    UIImage* ret = [UIImage imageWithCGImage:cgImage];
+    
+
+    CGImageRelease(cgImage);
+    
+    return ret;
     
 }
 
@@ -262,7 +268,15 @@
         CGFloat scaleY = height / barcodeImage.extent.size.height;
         CIImage *transformedImage = [barcodeImage imageByApplyingTransform:CGAffineTransformScale(CGAffineTransformIdentity, scaleX, scaleY)];
         
-        return [UIImage imageWithCIImage:transformedImage];
+        CIContext *context = [CIContext contextWithOptions:nil];
+        CGImageRef cgImage = [context createCGImage:transformedImage fromRect:[transformedImage extent]];
+        
+        UIImage* ret = [UIImage imageWithCGImage:cgImage];
+        
+        
+        CGImageRelease(cgImage);
+        
+        return ret;
         
     }
 }

+ 117 - 11
RedAnt ERP Mobile/common/pdfCreator/TableDrawable.m

@@ -32,18 +32,31 @@
 }
 -(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
 {
+    /*
+    bool header_repeat = [self.drawableTemplate[@"header_repeat"] boolValue];
+    bool drawheader = true;
+    
+    
     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];
+/*
+    
     float dy=y;
+    
+    
+    
+    dy= [self QueryHeader:context dataSource:data ParentRect:p_rect startX:x startY:y flipHeight:flip_height range:between_header_and_footer dy:dy];
+
     for(int i=0;i<count;i++)
+        
     {
         NSMutableDictionary * rowjson =rows[ [NSString stringWithFormat:@"row_%d",i ] ];
         PDFDrawable* drawable_obj= [[GroupDrawable alloc] init:rowjson];
@@ -51,30 +64,123 @@
         NSMutableDictionary* rows_data = table_data[rowjson[@"data_source"]];
         int row_data_count=[rows_data[@"count"] intValue];
         
-        for(int j=0;j<row_data_count;j++)
+        int j=0;
+        while(true)
+            //        for(int j=0;j<row_data_count;j++)
         {
             
+            if(i!=count-1&& j==row_data_count)
+                break;
             
+            if(drawheader)
+            {
+                
+                drawheader = false;
+            }
             
             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(row_rect.size.width>parentrect.size.width||row_rect.size.height>parentrect.size.height)
             {
-                //越界,新起一页
-                if (self.delegate && [self.delegate respondsToSelector:@selector(outofPage:)]) {
-                    [self.delegate addPageCount:context];
-                    dy=0;
+                // cell 比 table 还要大,模板有错,直接返回。
+                return parentrect;
+            }
+            
+            if(dy+row_rect.size.height> between_header_and_footer.location+between_header_and_footer.length )
+            {
+                if(j<row_data_count)
+                {
+                    //越界,新起一页
+                    if (self.delegate && [self.delegate respondsToSelector:@selector(outofPage:)]) {
+                        [self.delegate outofPage:context];
+                        dy=y;
+                        if(header_repeat)
+                        {
+                            dy= [self QueryHeader:context dataSource:data ParentRect:p_rect startX:x startY:y flipHeight:flip_height range:between_header_and_footer dy:dy];
+                            
+                            //                            drawheader=true;
+                        }
+                        //  dx=0;
+                    }
                 }
+                else
+                {
+                    break;
+                    //    goto finish_draw;
+                }
+                
+                
             }
-         //   [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);
+            
+            [drawable_obj Draw:context dataSource:row_data ParentRect:(CGRect)pdfrect startX:0 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;
+            }
+            
+            //            }
+            j++;
         }
         
     }
-    
+    //finish_draw:*/
+   // [self DrawBound:context dataSource:data ParentRect:p_rect startX:x startY:y flipHeight:flip_height range:between_header_and_footer];
     return parentrect;
 }
+-(float) QueryHeader:(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 dy:(double) dy
+{
+    // draw table header
+    
+    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];
+    NSMutableDictionary * headerjson =rows[@"header"];
+    PDFDrawable* header_drawable_obj= [[GroupDrawable alloc] init:headerjson];
+    header_drawable_obj.delegate = self.delegate;
+    NSMutableDictionary* header_data = table_data[headerjson[@"data_source"]];
+    //    int row_data_count=[header_data[@"count"] intValue];
+    NSMutableDictionary * row_data =header_data[ [NSString stringWithFormat:@"item_%d",0 ] ];
+    CGRect row_rect= [header_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 比 table 还要大,模板有错,直接返回。
+        return 0;
+    }
+    
+    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=y;
+            //  dx=0;
+        }
+    }
+    
+  //  [header_drawable_obj Draw:context dataSource:row_data ParentRect:(CGRect)pdfrect startX:0 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;
+    }
+    return dy;
+}
 -(float) DrawHeader:(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 dy:(double) dy
 {
     // draw table header

+ 118 - 106
RedAnt ERP Mobile/common/pdfCreator/TextDrawable.m

@@ -17,7 +17,7 @@
     
     [super setDrawableTemplate:drawableTemplate];
     
-
+    
     
     NSString* align= drawableTemplate[@"textAlignment"];
     if(align.length==0 || [align.lowercaseString isEqualToString:@"left"])
@@ -46,23 +46,23 @@
         unsigned long color = strtoul([colorvalue UTF8String],0,16);
         self.textColor= UIColorFromRGB(color);
     }
-   else
-   {
-       self.textColor= [UIColor blackColor];
-
-   }
+    else
+    {
+        self.textColor= [UIColor blackColor];
+        
+    }
     
     
-//    kCTTextAlignmentJustified CT_ENUM_AVAILABLE(10_8, 6_0) = 3,
-//    kCTTextAlignmentNatural   CT_ENUM_AVAILABLE(10_8, 6_0) = 4,
-
+    //    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]);
+    //    _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]);
 }
 
 
@@ -75,10 +75,10 @@
 -(CTFontRef)CreateFont:(NSString*)name  size:(double)size bold:(bool)bold
 {
     
-    if(name==nil)
+    if(name.length==0)
     {
         name=@"Helvetica";
-//        name=@"DejaVu Sans";
+        //        name=@"DejaVu Sans";
     }
     if(size==0)
     {
@@ -98,23 +98,26 @@
      (NSString *)kCTFontSizeAttribute,
      nil];
     // Create a descriptor.
+    CFDictionaryRef cffontAttributes =(__bridge CFDictionaryRef)fontAttributes;
     CTFontDescriptorRef descriptor =
-    CTFontDescriptorCreateWithAttributes((CFDictionaryRef)fontAttributes);
+    CTFontDescriptorCreateWithAttributes(cffontAttributes);
+    
+ //      CFBridgingRelease(cffontAttributes);
     
     // Create a font using the descriptor.
     CTFontRef font = CTFontCreateWithFontDescriptor(descriptor, 0.0, NULL);
-    CFRelease(descriptor);
-
+    CFBridgingRelease(descriptor);
+    
     return font;
-
-//    if(bold)
-//    {
-//        CTFontRef font=CTFontCreateWithName((__bridge CFStringRef)name, size, NULL);
-//        CTFontRef font_bold =CTFontCreateCopyWithSymbolicTraits(font, 0.0, NULL, kCTFontBoldTrait, kCTFontBoldTrait);
-//        CFBridgingRelease(font);
-//        return font_bold;
-//    }
-//    return CTFontCreateWithName((__bridge CFStringRef)name, size, NULL);
+    
+    //    if(bold)
+    //    {
+    //        CTFontRef font=CTFontCreateWithName((__bridge CFStringRef)name, size, NULL);
+    //        CTFontRef font_bold =CTFontCreateCopyWithSymbolicTraits(font, 0.0, NULL, kCTFontBoldTrait, kCTFontBoldTrait);
+    //        CFBridgingRelease(font);
+    //        return font_bold;
+    //    }
+    //    return CTFontCreateWithName((__bridge CFStringRef)name, size, NULL);
 }
 //-(NSString*) QueryFontName:(NSString*)font
 //{
@@ -130,21 +133,21 @@
 //}
 -(NSMutableAttributedString*) richtext2attributedstring:(NSMutableAttributedString*)string font:(NSString*)font  size:(double)size bold:(bool)bold
 {
-//    UILabel* uilabel=[[UILabel alloc]init];
-//    uilabel.font=[UIFont fontWithName:font size:size];
-//    NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[self.text dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
-//    uilabel.attributedText = attrStr;
-//    NSLog(@"%@", attrStr);
-//    NSLog(@"%@", uilabel.attributedText);
+    //    UILabel* uilabel=[[UILabel alloc]init];
+    //    uilabel.font=[UIFont fontWithName:font size:size];
+    //    NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[self.text dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
+    //    uilabel.attributedText = attrStr;
+    //    NSLog(@"%@", attrStr);
+    //    NSLog(@"%@", uilabel.attributedText);
     
     CTFontRef ctfont = [self CreateFont:font size:size bold:bold];//CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);b
     
-    CTFontRef ctfont_bold = [self CreateFont:font size:size bold:true];//CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);
+    //CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);
     //    CTFontRef helveticaBold = CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);
     //字体,把helvetica 样式加到整个,string上
-        [string addAttribute:(id)kCTFontAttributeName
-                       value:CFBridgingRelease(ctfont)
-                       range:NSMakeRange(0, [string length])];
+    [string addAttribute:(id)kCTFontAttributeName
+                   value:CFBridgingRelease(ctfont)
+                   range:NSMakeRange(0, [string length])];
     
     //颜色,此处为黑色,你可以自己改颜色,[UIColor redColor]
     [string addAttribute:(id)kCTForegroundColorAttributeName
@@ -154,17 +157,18 @@
     
     if(!bold)
     {
+        CTFontRef ctfont_bold = [self CreateFont:font size:size bold:true];
         NSString* newstring= nil;
-     //   NSString *content =  string.string ;
+        //   NSString *content =  string.string ;
         NSString *pattern = @"\\<b\\>([\\s\\S]*?)\\<\\/b\\>";
-//        NSArray* matches=[RAUtils expression_varable:content regex:pattern];
-//        if (matches) {
-//            for (NSTextCheckingResult *match in matches) {
-//                for (int i = 0; i < match.numberOfRanges; ++i) {
-//                    NSLog(@"%d-> %@",i, [content substringWithRange:[match rangeAtIndex:i]]);
-//                }
-//            }
-//        }
+        //        NSArray* matches=[RAUtils expression_varable:content regex:pattern];
+        //        if (matches) {
+        //            for (NSTextCheckingResult *match in matches) {
+        //                for (int i = 0; i < match.numberOfRanges; ++i) {
+        //                    NSLog(@"%d-> %@",i, [content substringWithRange:[match rangeAtIndex:i]]);
+        //                }
+        //            }
+        //        }
         NSTextCheckingResult * match=[RAUtils expression_findfistMatch:string.string regex:pattern];
         
         while(match)
@@ -180,10 +184,10 @@
                 [string addAttribute:(id)kCTFontAttributeName
                                value:(__bridge id _Nonnull)(ctfont_bold)
                                range:[match rangeAtIndex:i+1]];
-
+                
                 [string replaceCharactersInRange:NSMakeRange([match rangeAtIndex:i+1].location+[match rangeAtIndex:i+1].length, [match rangeAtIndex:i].location+[match rangeAtIndex:i].length-([match rangeAtIndex:i+1].location+[match rangeAtIndex:i+1].length)) withString:@""];
                 [string replaceCharactersInRange:NSMakeRange([match rangeAtIndex:i].location, [match rangeAtIndex:i+1].location-[match rangeAtIndex:i].location) withString:@""];
-
+                
                 NSLog(@"string after replace: %@",string.string);
                 //newstring=[newstring stringByReplacingOccurrencesOfString:[content substringWithRange:[match rangeAtIndex:i]] withString:[content substringWithRange:[match rangeAtIndex:i+1]]];
                 match=[RAUtils expression_findfistMatch:string.string regex:pattern];
@@ -224,14 +228,13 @@
     
     
     
-    
     NSString * source=self.drawableTemplate[@"source_type"];
     if(source==nil)
         source=@"const";
     if([source isEqualToString:@"const"])
     {
         self.text=self.drawableTemplate[@"text"];
-      //  self.text=[self.text stringByReplacingOccurrencesOfString:@"\r\n" withString:@"<br>"];
+        //  self.text=[self.text stringByReplacingOccurrencesOfString:@"\r\n" withString:@"<br>"];
         
     }
     else if([source isEqualToString:@"data"])
@@ -241,13 +244,13 @@
             NSString *content =  data[self.drawableTemplate[@"source"]];
             NSString *pattern = @"\\$\\.\\{([\\s\\S]*?)\\}\\.\\$";
             NSArray* matches=[RAUtils expression_varable:content regex:pattern];
-//            if (matches) {
-//                for (NSTextCheckingResult *match in matches) {
-//                    for (int i = 0; i < match.numberOfRanges; ++i) {
-//                        NSLog(@"%d-> %@",i, [content substringWithRange:[match rangeAtIndex:i]]);
-//                    }
-//                }  
-//            }
+            //            if (matches) {
+            //                for (NSTextCheckingResult *match in matches) {
+            //                    for (int i = 0; i < match.numberOfRanges; ++i) {
+            //                        NSLog(@"%d-> %@",i, [content substringWithRange:[match rangeAtIndex:i]]);
+            //                    }
+            //                }
+            //            }
             if (matches)
             {
                 self.text=content;
@@ -260,14 +263,14 @@
                         
                         self.text=[self.text stringByReplacingOccurrencesOfString:[content substringWithRange:[match rangeAtIndex:i]] withString:[NSString stringWithFormat:@"%@",data[[content substringWithRange:[match rangeAtIndex:i+1]]]]];
                     }
-                }  
+                }
             }
             //self.text=content;
             
         }
         else
         {
-        self.text=data[self.drawableTemplate[@"source"]];
+            self.text=data[self.drawableTemplate[@"source"]];
         }
     }
     
@@ -275,6 +278,9 @@
         self.text=@"";
     
     
+    
+    
+    
     if([self.text isEqualToString:@"www.newpacificdirect.com"])
     {
         int debug=0;
@@ -285,39 +291,39 @@
     bool italic = [self.drawableTemplate[@"italic"] boolValue];
     NSString* font=self.drawableTemplate[@"font"];
     
-//    [super flipContext:context ContextHeight:flip_height];
-   // super flipContext:context ContextHeight:<#(double)#>
-            CGFloat fontsize = [self.drawableTemplate[@"size"] doubleValue];
+    //    [super flipContext:context ContextHeight:flip_height];
+    // super flipContext:context ContextHeight:<#(double)#>
+    CGFloat fontsize = [self.drawableTemplate[@"size"] doubleValue];
     
     //NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[title dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
     //创建AttributeStringfdsa
     
     NSMutableAttributedString *string = nil;
-//    if([self.drawableTemplate[@"ishtml"] boolValue])
-//    {
-//        string=[[[NSAttributedString alloc] initWithData:[self.text dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil] mutableCopy];
-//        
-//    }
-//    else
+    //    if([self.drawableTemplate[@"ishtml"] boolValue])
+    //    {
+    //        string=[[[NSAttributedString alloc] initWithData:[self.text dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil] mutableCopy];
+    //
+    //    }
+    //    else
     {
         string=[[NSMutableAttributedString alloc] initWithString:self.text];
         //创建字体以及字体大小
-//        CTFontRef ctfont = [self CreateFont:font size:fontsize bold:bold];//CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);
-//        //    CTFontRef helveticaBold = CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);
-//        //字体,把helvetica 样式加到整个,string上
-//        [string addAttribute:(id)kCTFontAttributeName
-//                       value:CFBridgingRelease(ctfont)
-//                       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])];
+        //        CTFontRef ctfont = [self CreateFont:font size:fontsize bold:bold];//CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);
+        //        //    CTFontRef helveticaBold = CTFontCreateWithName(CFSTR("Helvetica"), fontsize, NULL);
+        //        //字体,把helvetica 样式加到整个,string上
+        //        [string addAttribute:(id)kCTFontAttributeName
+        //                       value:CFBridgingRelease(ctfont)
+        //                       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])];
         
         string = [self richtext2attributedstring:string font:font size:fontsize bold:bold];
         
@@ -326,7 +332,7 @@
         long number = self.characterSpace;
         CFNumberRef num = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt8Type, &number);
         [string addAttribute:(id)kCTKernAttributeName value:CFBridgingRelease(num) range:NSMakeRange(0, [string length])];
-        CFRelease(num);
+        //CFRelease(num);
         
         
         //创建文本对齐方式
@@ -371,17 +377,19 @@
         
         //给字符串添加样式attribute
         [string addAttribute:(id)kCTParagraphStyleAttributeName
-                       value:(id)paragraphStyle1
+                       value:CFBridgingRelease(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]}];
- 
+    //     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
@@ -389,8 +397,8 @@
     //创建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];
+    //   self.frame = CGRectMake(0, 0, textBoxSize.width , textBoxSize.height);
+    //    [string release];
     
     //- (void)drawRect:(CGRect)rect;代码
     
@@ -413,10 +421,10 @@
     //    CGRect rect=[RAUtils rectAlign:parentrect rect:scalerect hAlign:self.hAlign vAlign:self.vAlign];
     rect=[RAUtils rectVAlign:parentrect rect:rect vAlign:self.vAlign];
     
-   // CGRect pdfrect = [self to_pdf_rect:p_rect pos:self.rect contextHeight:flip_height];
+    // CGRect pdfrect = [self to_pdf_rect:p_rect pos:self.rect contextHeight:flip_height];
     
     rect= [self parent_to_pdf_rect:rect contextHeight:flip_height];
-  //  pdfrect=CGRectMake(pdfrect.origin.x, flip_height-pdfrect.origin.y, pdfrect.size.width, pdfrect.size.height);
+    //  pdfrect=CGRectMake(pdfrect.origin.x, flip_height-pdfrect.origin.y, pdfrect.size.width, pdfrect.size.height);
     CGPathAddRect(leftColumnPath, NULL,
                   rect);
     
@@ -426,32 +434,36 @@
     
     //    NSLog(@"textBoxSize1  == %f,%f",self.frame.size.width,self.frame.size.height);
     // flip the coordinate system
-//    CGContextRef context = UIGraphicsGetCurrentContext();
+    //    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));
+    //    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);
+    //   CGContextTranslateCTM(context, 0, self.rect.size.height);
+    //   CGContextScaleCTM(context, 1.0, -1.0);
     
     // draw
     CTFrameDraw(leftFrame, context);
     
+    
+    CFRelease(leftFrame);
     // cleanup
     
     CGPathRelease(leftColumnPath);
     CFRelease(framesetter);
     
+    
+    //    return self.rect;
     [self DrawBound:context dataSource:data ParentRect:p_rect startX:x startY:y flipHeight:flip_height range:between_header_and_footer];
-
+    
     return parentrect;
-//    return CGPointMake(parentrect.origin.x+parentrect.size.width, parentrect.origin.y+parentrect.size.height);
+    //    return CGPointMake(parentrect.origin.x+parentrect.size.width, parentrect.origin.y+parentrect.size.height);
     
-//    [super restoreFlip:context ContextHeight:flip_height];
+    //    [super restoreFlip:context ContextHeight:flip_height];
 }
 
 

+ 2 - 2
RedAnt ERP Mobile/common/pdfCreator/pdfCreator.m

@@ -133,10 +133,10 @@
     
     url=CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, 0);
     
-    
+    CFBridgingRelease(path);
     pdfContext=CGPDFContextCreateWithURL(url, &papersize, nil);
     
-    
+    CFBridgingRelease(url);
     data[@"TOTAL_PAGE"]= [NSNumber numberWithInt:[self QueryTotalPage:pdfContext template:template dataSource:data]];
     
     NSMutableDictionary* pages=template[@"pages"];

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

@@ -175,6 +175,7 @@
 		718716291C433DA400F25860 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 718716281C433DA400F25860 /* AVFoundation.framework */; };
 		7187162C1C43428100F25860 /* libScanApiCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 718716221C433D5000F25860 /* libScanApiCore.a */; };
 		718B91831C75638100265FFF /* TouchImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 718B91821C75638100265FFF /* TouchImageView.m */; };
+		718E71091DE7CEA20035D1FF /* so.json in Resources */ = {isa = PBXBuildFile; fileRef = 718E71081DE7CEA20035D1FF /* so.json */; };
 		7195623C1CF57D1800C74A49 /* CategoryHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7195623B1CF57D1800C74A49 /* CategoryHeaderView.m */; };
 		719562421CF5828200C74A49 /* DefaultTableHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 719562411CF5828200C74A49 /* DefaultTableHeaderView.m */; };
 		71BBA2271CEAC16000C91DED /* ZipArchive.mm in Sources */ = {isa = PBXBuildFile; fileRef = 71BBA2221CEAC16000C91DED /* ZipArchive.mm */; };
@@ -541,6 +542,7 @@
 		7187162A1C43406300F25860 /* libScanApiCore.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libScanApiCore.a; path = "../../../ios_samples/ScanApiSDK-10.2.227/lib/libScanApiCore.a"; sourceTree = "<group>"; };
 		718B91811C75638100265FFF /* TouchImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TouchImageView.h; path = common/customUI/TouchImageView.h; sourceTree = SOURCE_ROOT; };
 		718B91821C75638100265FFF /* TouchImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TouchImageView.m; path = common/customUI/TouchImageView.m; sourceTree = SOURCE_ROOT; };
+		718E71081DE7CEA20035D1FF /* so.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = so.json; sourceTree = "<group>"; };
 		7195623A1CF57D1800C74A49 /* CategoryHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CategoryHeaderView.h; path = common/Functions/category/CategoryHeaderView.h; sourceTree = SOURCE_ROOT; };
 		7195623B1CF57D1800C74A49 /* CategoryHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CategoryHeaderView.m; path = common/Functions/category/CategoryHeaderView.m; sourceTree = SOURCE_ROOT; };
 		719562401CF5828200C74A49 /* DefaultTableHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DefaultTableHeaderView.h; path = common/customUI/DefaultTableHeaderView.h; sourceTree = SOURCE_ROOT; };
@@ -911,6 +913,7 @@
 			children = (
 				712AFEE61DBDB48000254965 /* portfolio_3x2.json */,
 				71073AE51DD41DD8001BC653 /* so_thumb.json */,
+				718E71081DE7CEA20035D1FF /* so.json */,
 				71D5016B1DC32C3300971FBB /* portfolio_2x3.json */,
 			);
 			name = template;
@@ -1535,6 +1538,7 @@
 				423B49EF1DAC8071004181C2 /* CUL.storyboard in Resources */,
 				42C2E8BC1DB49D02006C0495 /* TearSheet.json in Resources */,
 				42B3C9BB1D642C880053985C /* order_info.html in Resources */,
+				718E71091DE7CEA20035D1FF /* so.json in Resources */,
 				42A225331D6E7D1D00235B62 /* placeOrderTemplate.json in Resources */,
 				7141DD3D1C5726B700F7DF59 /* softScanBeep.wav in Resources */,
 				7141DD341C57269B00F7DF59 /* include in Resources */,

+ 1206 - 105
RedAnt ERP Mobile/iSales-NPD/so.json

@@ -12,14 +12,27 @@
                 "x": 0,
                 "y": 0,
                 "width": 572,
-                "height": 266,
+                "height": 310,
                 "items": {
-                    "count": 2,
+                    "count": 27,
+                    "item_26": {
+                        "type": "text",
+                        "source": "warehouse_name",
+                        "source_type": "data",
+                        "textAlignment": "Left",
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": false,
+                        "x": 355,
+                        "y": 134,
+                        "width": 137,
+                        "height": 15
+                    },
                     "item_0": {
                         "type": "img",
                         "hAlign": "Left",
                         "vAlign": "Middle",
-                        "source": "portfolio_logo_s",
+                        "source": "salesorder_logo",
                         "source_type": "const",
                         "x": 0,
                         "y": 0,
@@ -37,148 +50,1236 @@
                         "y": 5,
                         "width": 240,
                         "height": 22
-                    }
-                }
-            },
-            "footer": {
-                "type": "group",
-                "x": 0,
-                "y": 734,
-                "width": 572,
-                "height": 18,
-                "items": {
-                    "count": 2,
-                    "item_0": {
+                    },
+                    "item_2": {
                         "type": "text",
-                        "source": "create_time",
+                        "source": "order_type",
                         "source_type": "data",
                         "textAlignment": "Left",
                         "vAlign": "Middle",
-                        "x": 5,
-                        "y": 2,
-                        "width": 119,
-                        "height": 14
+                        "size": "24",
+                        "bold": true,
+                        "x": 290,
+                        "y": 42,
+                        "width": 282,
+                        "height": 42
                     },
-                    "item_1": {
+                    "item_3": {
                         "type": "text",
-                        "source": "PAGE_INDEX",
+                        "text": "SO No.",
+                        "source_type": "const",
+                        "textAlignment": "Center",
+                        "draw_bound": true,
+                        "line_width": [
+                                       1,
+                                       1,
+                                       0,
+                                       0
+                                       ],
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": true,
+                        "x": 373,
+                        "y": 84,
+                        "width": 99,
+                        "height": 20
+                    },
+                    "item_4": {
+                        "type": "text",
+                        "text": "DATE",
+                        "draw_bound": true,
+                        "line_width": [
+                                       1,
+                                       1,
+                                       0,
+                                       1
+                                       ],
+                        "source_type": "const",
+                        "textAlignment": "Center",
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": true,
+                        "x": 291,
+                        "y": 84,
+                        "width": 82,
+                        "height": 20
+                    },
+                    "item_5": {
+                        "type": "text",
+                        "text": "T:",
+                        "source_type": "const",
+                        "textAlignment": "Left",
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": true,
+                        "x": 0,
+                        "y": 97,
+                        "width": 22,
+                        "height": 20
+                    },
+                    "item_6": {
+                        "type": "text",
+                        "text": "F:",
+                        "source_type": "const",
+                        "textAlignment": "Left",
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": true,
+                        "x": 126,
+                        "y": 97,
+                        "width": 24,
+                        "height": 20
+                    },
+                    "item_7": {
+                        "type": "text",
+                        "text": "E:",
+                        "source_type": "const",
+                        "textAlignment": "Left",
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": true,
+                        "x": 0,
+                        "y": 117,
+                        "width": 22,
+                        "height": 20
+                    },
+                    "item_8": {
+                        "type": "text",
+                        "text": "VENDOR No.",
+                        "source_type": "const",
+                        "textAlignment": "Center",
+                        "draw_bound": true,
+                        "line_width": [
+                                       1,
+                                       1,
+                                       0,
+                                       0
+                                       ],
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": true,
+                        "x": 472,
+                        "y": 84,
+                        "width": 99,
+                        "height": 20
+                    },
+                    "item_9": {
+                        "type": "text",
+                        "source": "so_id",
                         "source_type": "data",
-                        "source_isexpression": true,
-                        "textAlignment": "Right",
+                        "textAlignment": "Center",
+                        "vAlign": "Middle",
+                        "draw_bound": true,
+                        "line_width": [
+                                       1,
+                                       1,
+                                       1,
+                                       0
+                                       ],
+                        "size": "10",
+                        "bold": false,
+                        "x": 373,
+                        "y": 104,
+                        "width": 99,
+                        "height": 28
+                    },
+                    "item_10": {
+                        "type": "text",
+                        "source": "create_date",
+                        "source_type": "data",
+                        "textAlignment": "Center",
+                        "draw_bound": true,
+                        "line_width": [
+                                       1,
+                                       1,
+                                       1,
+                                       1
+                                       ],
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": false,
+                        "x": 291,
+                        "y": 104,
+                        "width": 82,
+                        "height": 28
+                    },
+                    "item_11": {
+                        "type": "text",
+                        "source": "shipfrom_addr",
+                        "source_type": "data",
+                        "textAlignment": "left",
                         "vAlign": "Middle",
-                        "x": 468,
-                        "y": 2,
+                        "size": "10",
+                        "bold": false,
+                        "x": 0,
+                        "y": 72,
+                        "width": 250,
+                        "height": 25
+                    },
+                    "item_12": {
+                        "type": "text",
+                        "source": "shipfrom_phone",
+                        "source_type": "data",
+                        "textAlignment": "left",
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": false,
+                        "x": 22,
+                        "y": 97,
                         "width": 104,
-                        "height": 14
-                    }
-                }
-            },
-            "margin_left": 20,
-            "margin_right": 20,
-            "margin_top": 20,
-            "margin_bottom": 20,
-            "contents": {
-                "count": 0,
-                "item_0": {
-                    "type": "grid",
-                    "data_source": "grid0",
-                    "cell": {
-                        "direction": "H",
-                        "duplicate": 0,
-                        "data_source": "cell0",
+                        "height": 20
+                    },
+                    "item_13": {
+                        "type": "text",
+                        "source": "shipfrom_fax",
+                        "source_type": "data",
+                        "textAlignment": "left",
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": false,
+                        "x": 150,
+                        "y": 97,
+                        "width": 100,
+                        "height": 20
+                    },
+                    "item_14": {
+                        "type": "text",
+                        "source": "shipfrom_email",
+                        "source_type": "data",
+                        "textAlignment": "left",
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": false,
+                        "x": 22,
+                        "y": 117,
+                        "width": 228,
+                        "height": 20
+                    },
+                    "item_15": {
+                        "type": "text",
+                        "source": "company",
+                        "source_type": "data",
+                        "textAlignment": "left",
+                        "vAlign": "Middle",
+                        "size": "12",
+                        "bold": true,
+                        "x": 0,
+                        "y": 52,
+                        "width": 250,
+                        "height": 20
+                    },
+                    "item_16": {
+                        "type": "text",
+                        "source": "so_id",
+                        "source_type": "data",
+                        "textAlignment": "center",
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": true,
+                        "x": 331,
+                        "y": 27,
+                        "width": 240,
+                        "height": 15
+                    },
+                    "item_17": {
+                        "type": "text",
+                        "text": "Location:",
+                        "margin_left": 2,
+                        "source_type": "const",
+                        "textAlignment": "left",
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": true,
+                        "x": 290,
+                        "y": 134,
+                        "width": 64,
+                        "height": 15
+                    },
+                    "item_18": {
+                        "type": "text",
+                        "text": "SHIP TO",
+                        "source_type": "const",
+                        "textAlignment": "left",
+                        "margin_left": 4,
+                        "draw_bound": true,
+                        "line_width": [
+                                       1,
+                                       1,
+                                       0,
+                                       1
+                                       ],
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": true,
+                        "x": 275,
+                        "y": 152,
+                        "width": 296,
+                        "height": 20
+                    },
+                    "item_19": {
+                        "type": "text",
+                        "source": "vendor_no",
+                        "source_type": "data",
+                        "textAlignment": "center",
+                        "draw_bound": true,
+                        "line_width": [
+                                       1,
+                                       1,
+                                       1,
+                                       0
+                                       ],
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": false,
+                        "x": 472,
+                        "y": 104,
+                        "width": 99,
+                        "height": 28
+                    },
+                    "item_20": {
+                        "type": "text",
+                        "text": "BILL TO",
+                        "source_type": "const",
+                        "textAlignment": "left",
+                        "margin_left": 4,
+                        "draw_bound": true,
+                        "line_width": [
+                                       1,
+                                       1,
+                                       0,
+                                       1
+                                       ],
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": true,
+                        "x": 0,
+                        "y": 152,
+                        "width": 275,
+                        "height": 20
+                    },
+                    "item_21": {
+                        "type": "text",
+                        "source": "bill_to_name",
+                        "source_type": "data",
+                        "textAlignment": "left",
+                        "margin_left": 4,
+                        "draw_bound": true,
+                        "line_width": [
+                                       1,
+                                       1,
+                                       0,
+                                       1
+                                       ],
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": false,
+                        "x": 0,
+                        "y": 172,
+                        "width": 275,
+                        "height": 20
+                    },
+                    "item_22": {
+                        "type": "text",
+                        "source": "ship_to_name",
+                        "source_type": "data",
+                        "textAlignment": "left",
+                        "margin_left": 4,
+                        "draw_bound": true,
+                        "line_width": [
+                                       1,
+                                       1,
+                                       0,
+                                       0
+                                       ],
+                        "vAlign": "Middle",
+                        "size": "10",
+                        "bold": false,
+                        "x": 275,
+                        "y": 172,
+                        "width": 296,
+                        "height": 20
+                    },
+                    "item_23": {
+                        "type": "text",
+                        "source": "bill_to_ext",
+                        "source_type": "data",
+                        "textAlignment": "left",
+                        "margin_left": 4,
+                        "vAlign": "top",
+                        "draw_bound": true,
+                        "line_width": [
+                                       0,
+                                       1,
+                                       1,
+                                       1
+                                       ],
+                        "size": "10",
+                        "bold": false,
+                        "x": 0,
+                        "y": 192,
+                        "width": 275,
+                        "height": 70
+                    },
+                    "item_24": {
+                        "type": "text",
+                        "source": "ship_to_ext",
+                        "source_type": "data",
+                        "textAlignment": "left",
+                        "margin_left": 4,
+                        "draw_bound": true,
+                        "line_width": [
+                                       0,
+                                       1,
+                                       1,
+                                       0
+                                       ],
+                        "vAlign": "top",
+                        "size": "10",
+                        "bold": false,
+                        "x": 275,
+                        "y": 192,
+                        "width": 296,
+                        "height": 70
+                    },
+                    "item_25": {
                         "type": "group",
                         "x": 0,
-                        "y": 0,
-                        "width": 286,
-                        "height": 231,
+                        "y": 270,
+                        "width": 572,
+                        "height": 42,
                         "items": {
-                            "count": 7,
-                            "item_1": {
-                                "type": "img",
-                                "source": "img_qr",
-                                "source_type": "data",
-                                "source_path_type": "local",
-                                "hAlign": "Center",
-                                "vAlign": "Middle",
-                                "x": 20,
-                                "y": 20,
-                                "width": 51,
-                                "height": 51
-                            },
+                            "count": 12,
                             "item_0": {
-                                "type": "img",
-                                "source": "img",
-                                "source_type": "data",
-                                "hAlign": "Center",
+                                "type": "text",
+                                "text": "CARRIER",
+                                "bold":true,
+                                "source_type": "const",
+                                "textAlignment": "CENTER",
+                                "draw_bound": true,
+                                "line_width": [
+                                               1,
+                                               1,
+                                               1,
+                                               0
+                                               ],
                                 "vAlign": "Middle",
-                                "x": 101,
+                                "x": 375,
                                 "y": 0,
-                                "width": 93,
-                                "height": 101
+                                "width": 90,
+                                "height": 21
                             },
-                            "item_2": {
+                            "item_1": {
                                 "type": "text",
-                                "source": "special_price",
+                                "source": "carrier",
                                 "source_type": "data",
-                                "size": "10",
-                                "bold": true,
-                                "color": "0xff0000",
-                                "x": 195,
-                                "y": 87,
+                                "draw_bound": true,
+                                "line_width": [
+                                               0,
+                                               1,
+                                               1,
+                                               0
+                                               ],
+                                "source_isexpression": false,
+                                "textAlignment": "center",
+                                "vAlign": "Middle",
+                                "x": 375,
+                                "y": 21,
                                 "width": 90,
                                 "height": 20
                             },
+                            "item_2": {
+                                "type": "text",
+                                "text": "PO No.",
+                                "source_type": "const",
+                                "textAlignment": "CENTER",
+                                "draw_bound": true,
+                                "bold":true,
+                                "line_width": [
+                                               1,
+                                               1,
+                                               1,
+                                               1
+                                               ],
+                                "vAlign": "Middle",
+                                "x": 0,
+                                "y": 0,
+                                "width": 149,
+                                "height": 21
+                            },
                             "item_3": {
                                 "type": "text",
-                                "source": "name",
+                                "source": "po_no",
                                 "source_type": "data",
-                                "size": "12",
-                                "bold": true,
-                                "x": 4,
-                                "y": 103,
-                                "width": 188,
-                                "height": 23
+                                "draw_bound": true,
+                                "line_width": [
+                                               0,
+                                               1,
+                                               1,
+                                               1
+                                               ],
+                                "source_isexpression": false,
+                                "textAlignment": "center",
+                                "vAlign": "Middle",
+                                "x": 0,
+                                "y": 21,
+                                "width": 149,
+                                "height": 20
                             },
                             "item_4": {
                                 "type": "text",
-                                "source": "description",
-                                "source_type": "data",
-                                "size": "9",
-                                "bold": true,
-                                "x": 4,
-                                "y": 126,
-                                "width": 282,
-                                "height": 31
+                                "text": "TERMS",
+                                "source_type": "const",
+                                "bold":true,
+                                "textAlignment": "CENTER",
+                                "draw_bound": true,
+                                "line_width": [
+                                               1,
+                                               1,
+                                               1,
+                                               0
+                                               ],
+                                "vAlign": "Middle",
+                                "x": 150,
+                                "y": 0,
+                                "width": 67,
+                                "height": 21
                             },
                             "item_5": {
                                 "type": "text",
-                                "source": "price",
+                                "source": "terms",
                                 "source_type": "data",
-                                "size": "10",
-                                "bold": true,
-                                "x": 195,
-                                "y": 106,
-                                "width": 90,
+                                "source_isexpression": false,
+                                "draw_bound": true,
+                                "line_width": [
+                                               0,
+                                               1,
+                                               1,
+                                               0
+                                               ],
+                                "textAlignment": "CENTER",
+                                "vAlign": "Middle",
+                                "x": 150,
+                                "y": 21,
+                                "width": 67,
                                 "height": 20
                             },
                             "item_6": {
                                 "type": "text",
-                                "source": "detail",
+                                "text": "REP",
+                                "bold":true,
+                                "source_type": "const",
+                                "textAlignment": "CENTER",
+                                "draw_bound": true,
+                                "line_width": [
+                                               1,
+                                               1,
+                                               1,
+                                               0
+                                               ],
+                                "vAlign": "Middle",
+                                "x": 217,
+                                "y": 0,
+                                "width": 68,
+                                "height": 21
+                            },
+                            "item_7": {
+                                "type": "text",
+                                "source": "rep",
                                 "source_type": "data",
-                                "ishtml": true,
-                                "size": "8",
-                                "bold": false,
-                                "x": 4,
-                                "y": 157,
-                                "width": 282,
-                                "height": 72
+                                "draw_bound": true,
+                                "line_width": [
+                                               0,
+                                               1,
+                                               1,
+                                               0
+                                               ],
+                                "source_isexpression": false,
+                                "textAlignment": "CENTER",
+                                "vAlign": "Middle",
+                                "x": 217,
+                                "y": 21,
+                                "width": 68,
+                                "height": 20
+                            },
+                            "item_8": {
+                                "type": "text",
+                                "text": "EST. SCHEDULE",
+                                "bold":true,
+                                "source_type": "const",
+                                "draw_bound": true,
+                                "line_width": [
+                                               1,
+                                               1,
+                                               1,
+                                               0
+                                               ],
+                                "textAlignment": "CENTER",
+                                "vAlign": "Middle",
+                                "x": 285,
+                                "y": 0,
+                                "width": 90,
+                                "height": 21
+                            },
+                            "item_9": {
+                                "type": "text",
+                                "source": "e_schdule",
+                                "source_type": "data",
+                                "draw_bound": true,
+                                "line_width": [
+                                               0,
+                                               1,
+                                               1,
+                                               0
+                                               ],
+                                "source_isexpression": false,
+                                "textAlignment": "CENTER",
+                                "vAlign": "Middle",
+                                "x": 285,
+                                "y": 21,
+                                "width": 90,
+                                "height": 20
+                            },
+                            "item_10": {
+                                "type": "text",
+                                "text": "sales_terms",
+                                "bold":true,
+                                "draw_bound": true,
+                                "line_width": [
+                                               1,
+                                               1,
+                                               1,
+                                               0
+                                               ],
+                                "source_type": "data",
+                                "textAlignment": "CENTER",
+                                "vAlign": "Middle",
+                                "x": 465,
+                                "y": 0,
+                                "width": 107,
+                                "height": 21
+                            },
+                            "item_11": {
+                                "type": "text",
+                                "source": "port_destination",
+                                "source_type": "data",
+                                "draw_bound": true,
+                                "line_width": [
+                                               0,
+                                               1,
+                                               1,
+                                               0
+                                               ],
+                                "source_isexpression": false,
+                                "textAlignment": "CENTER",
+                                "vAlign": "Middle",
+                                "x": 465,
+                                "y": 21,
+                                "width": 107,
+                                "height": 20
                             }
                         }
+                    }
+                }
+            },
+            "footer": {
+                "type": "group",
+                "x": 0,
+                "y": 612,
+                "width": 572,
+                "height": 140,
+                
+                "items": {
+                    "count": 8,
+                    "item_0": {
+                        "type": "text",
+                        "source": "print_date",
+                        "source_type": "data",
+                        "textAlignment": "Left",
+                        "vAlign": "Middle",
+                        "size": "9",
+                        "x": 237,
+                        "y": 119,
+                        "width": 109,
+                        "height": 20
                     },
+                    "item_1": {
+                        "type": "text",
+                        "text": "Printed Date:",
+                        "source_type": "const",
+                        "source_isexpression": true,
+                        "textAlignment": "Right",
+                        "vAlign": "Middle",
+                        "size": "9",
+                        "bold": true,
+                        "x": 165,
+                        "y": 119,
+                        "width": 70,
+                        "height": 20
+                    },
+                    "item_2": {
+                        "type": "text",
+                        "source": "PAGE_INDEX",
+                        "source_type": "data",
+                        "source_isexpression": true,
+                        "textAlignment": "Right",
+                        "vAlign": "Middle",
+                        "size": "9",
+                        "x": 490,
+                        "y": 119,
+                        "width": 56,
+                        "height": 20
+                    },
+                    "item_3": {
+                        "type": "text",
+                        "source": "print_by",
+                        "source_type": "data",
+                        "source_isexpression": true,
+                        "textAlignment": "left",
+                        "vAlign": "Middle",
+                        "margin_left": 2,
+                        "size": "9",
+                        "x": 410,
+                        "y": 119,
+                        "width": 81,
+                        "height": 20
+                    },
+                    "item_4": {
+                        "type": "text",
+                        "source": "print_status",
+                        "source_type": "data",
+                        "source_isexpression": true,
+                        "textAlignment": "left",
+                        "margin_left": 2,
+                        "vAlign": "Middle",
+                        "size": "9",
+                        "x": 96,
+                        "y": 119,
+                        "width": 70,
+                        "height": 20
+                    },
+                    "item_5": {
+                        "type": "text",
+                        "text": "Printed on Status: ",
+                        "source_type": "const",
+                        "source_isexpression": true,
+                        "textAlignment": "Right",
+                        "vAlign": "Middle",
+                        "size": "9",
+                        "bold": true,
+                        "x": 0,
+                        "y": 119,
+                        "width": 97,
+                        "height": 20
+                    },
+                    "item_6": {
+                        "type": "text",
+                        "text": "Printed By: ",
+                        "source_type": "const",
+                        "source_isexpression": true,
+                        "textAlignment": "Right",
+                        "vAlign": "Middle",
+                        "size": "9",
+                        "bold": true,
+                        "x": 345,
+                        "y": 119,
+                        "width": 66,
+                        "height": 20
+                    },
+                    "item_7": {
+                        "type": "group",
+                        "x": 0,
+                        "y": 0,
+                        "width": 571,
+                        "height": 120,
+                        "draw_bound": true,
+                        "line_width": [
+                                       0,
+                                       1,
+                                       1,
+                                       1
+                                       ],
+                        "items": {
+                            "count": 5,
+                            "item_0": {
+                                "type": "table",
+                                "data_source": "table_fee",
+                                "x": 391,
+                                "y": 0,
+                                "width": 180,
+                                "height": 120,
+                                "draw_bound": true,
+                                "line_width": [
+                                               0,
+                                               0,
+                                               0,
+                                               1
+                                               ],
+                                "rows": {
+                                    "count": 1,
+                                    "row_0": {
+                                        "data_source": "row0",
+                                        "repeat": "horizontal",
+                                        "type": "group",
+                                        "x": 0,
+                                        "y": 0,
+                                        "width": 180,
+                                        "height": 20,
+                                        "items": {
+                                            "count": 2,
+                                            "item_0": {
+                                                "type": "text",
+                                                "source": "name",
+                                                "source_type": "data",
+                                                "textAlignment": "Right",
+                                                "vAlign": "Middle",
+                                                "size": "10",
+                                                "bold": true,
+                                                "x": 0,
+                                                "y": 0,
+                                                "width": 120,
+                                                "height": 20
+                                            },
+                                            "item_1": {
+                                                "type": "text",
+                                                "source": "value",
+                                                "source_type": "data",
+                                                "textAlignment": "RIGHT",
+                                                "vAlign": "Middle",
+                                                "margin_left": 2,
+                                                "size": "10",
+                                                "bold": false,
+                                                "x": 120,
+                                                "y": 0,
+                                                "width": 60,
+                                                "height": 20
+                                            }
+                                        }
+                                    }
+                                }
+                            },
+                            "item_1": {
+                                "type": "text",
+                                "text": "Customer Signature",
+                                "source_type": "const",
+                                "source_isexpression": true,
+                                "textAlignment": "Right",
+                                "size": "9",
+                                "bold": true,
+                                "vAlign": "Middle",
+                                "x": 107,
+                                "y": 97,
+                                "width": 143,
+                                "height": 22
+                            },
+                            "item_2": {
+                                "type": "img",
+                                "hAlign": "center",
+                                "vAlign": "Middle",
+                                "source": "customer_sign",
+                                "source_type": "data",
+                                "x": 249,
+                                "y": 81,
+                                "width": 110,
+                                "height": 38
+                            },
+                            "item_3": {
+                                "type": "group",
+                                "x": 3,
+                                "y": 1,
+                                "width": 386,
+                                "height": 77
+                            },
+                            "item_4": {
+                                "type": "text",
+                                "text": "I have reviewed and give approval for the above order to be processed.",
+                                "source_type": "const",
+                                "source_isexpression": true,
+                                "draw_bound": true,
+                                "line_width": [
+                                               1,
+                                               0,
+                                               0,
+                                               0
+                                               ],
+                                "textAlignment": "left",
+                                "size": "8",
+                                "vAlign": "Middle",
+                                "x": 0,
+                                "y": 82,
+                                "width": 391,
+                                "height": 15
+                            }
+                        }
+                    }
+                }
+            },
+            "margin_left": 20,
+            "margin_right": 20,
+            "margin_top": 20,
+            "margin_bottom": 20,
+            "contents": {
+                "count": 1,
+                "item_0": {
+                    "type": "table",
+                    "data_source": "table_model",
                     "x": 0,
-                    "y": 0,
-                    "width": 752,
-                    "height": 491
+                    "y": 5,
+                    "width": 571,
+                    "height": 297,
+                    "header_repeat": true,
+                    "draw_bound": true,
+                    "line_width": [
+                                   1,
+                                   1,
+                                   1,
+                                   1
+                                   ],
+                    "rows": {
+                        "count": 1,
+                        "header": {
+                            "data_source": "row0",
+                            "type": "group",
+                            "x": 0,
+                            "y": 0,
+                            "width": 571,
+                            "height": 21,
+                            "items": {
+                                "count": 7,
+                                "item_0": {
+                                    "type": "text",
+                                    "text": "LN#",
+                                    "source_type": "const",
+                                    "source_isexpression": false,
+                                    "textAlignment": "CENTER",
+                                    "draw_bound": true,
+                                    "bold":true,
+                                    "line_width": [
+                                                   1,
+                                                   1,
+                                                   1,
+                                                   1
+                                                   ],
+                                    "size": "10",
+                                    "vAlign": "Middle",
+                                    "x": 0,
+                                    "y": 0,
+                                    "width": 30,
+                                    "height": 21
+                                },
+                                "item_1": {
+                                    "type": "text",
+                                    "text": "MODEL",
+                                    "bold":true,
+                                    "source_type": "const",
+                                    "source_isexpression": false,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   1,
+                                                   1,
+                                                   1,
+                                                   0
+                                                   ],
+                                    "textAlignment": "CENTER",
+                                    "size": "10",
+                                    "vAlign": "Middle",
+                                    "x": 30,
+                                    "y": 0,
+                                    "width": 122,
+                                    "height": 21
+                                },
+                                "item_2": {
+                                    "type": "text",
+                                    "text": "SKU#/DESCRIPTION",
+                                    "bold":true,
+                                    "source_type": "const",
+                                    "source_isexpression": false,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   1,
+                                                   1,
+                                                   1,
+                                                   0
+                                                   ],
+                                    "textAlignment": "CENTER",
+                                    "size": "10",
+                                    "vAlign": "Middle",
+                                    "x": 152,
+                                    "y": 0,
+                                    "width": 135,
+                                    "height": 21
+                                },
+                                "item_3": {
+                                    "type": "text",
+                                    "text": "QTY",
+                                    "bold":true,
+                                    "source_type": "const",
+                                    "source_isexpression": false,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   1,
+                                                   1,
+                                                   1,
+                                                   0
+                                                   ],
+                                    "textAlignment": "CENTER",
+                                    "size": "10",
+                                    "vAlign": "Middle",
+                                    "x": 287,
+                                    "y": 0,
+                                    "width": 40,
+                                    "height": 21
+                                },
+                                "item_4": {
+                                    "type": "text",
+                                    "text": "CUST REF.",
+                                    "bold":true,
+                                    "source_type": "const",
+                                    "source_isexpression": false,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   1,
+                                                   1,
+                                                   1,
+                                                   0
+                                                   ],
+                                    "textAlignment": "CENTER",
+                                    "size": "10",
+                                    "vAlign": "Middle",
+                                    "x": 327,
+                                    "y": 0,
+                                    "width": 84,
+                                    "height": 21
+                                },
+                                "item_5": {
+                                    "type": "text",
+                                    "text": "UNIT PRICE",
+                                    "bold":true,
+                                    "source_type": "const",
+                                    "source_isexpression": false,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   1,
+                                                   1,
+                                                   1,
+                                                   0
+                                                   ],
+                                    "textAlignment": "CENTER",
+                                    "size": "10",
+                                    "vAlign": "Middle",
+                                    "x": 411,
+                                    "y": 0,
+                                    "width": 80,
+                                    "height": 21
+                                },
+                                "item_6": {
+                                    "type": "text",
+                                    "text": "AMOUNT",
+                                    "bold":true,
+                                    "source_type": "const",
+                                    "source_isexpression": false,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   1,
+                                                   1,
+                                                   1,
+                                                   0
+                                                   ],
+                                    "textAlignment": "CENTER",
+                                    "size": "10",
+                                    "vAlign": "Middle",
+                                    "x": 491,
+                                    "y": 0,
+                                    "width": 80,
+                                    "height": 21
+                                }
+                            }
+                        },
+                        "row_0": {
+                            "data_source": "row1",
+                            "repeat": "horizontal",
+                            "type": "group",
+                            "x": 0,
+                            "y": 0,
+                            "width": 571,
+                            "height": 69,
+                            "items": {
+                                "count": 7,
+                                "item_0": {
+                                    "type": "text",
+                                    "source": "ln#",
+                                    "source_type": "data",
+                                    "margin_left":2,
+                                    "margin_top":2,
+                                    "source_isexpression": false,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   0,
+                                                   1,
+                                                   0,
+                                                   1
+                                                   ],
+                                    "textAlignment": "left",
+                                    "size": "8",
+                                    "vAlign": "top",
+                                    "x": 0,
+                                    "y": 0,
+                                    "width": 30,
+                                    "height": 69
+                                },
+                                "item_1": {
+                                    "type": "group",
+                                    "x": 30,
+                                    "y": 0,
+                                    "width": 122,
+                                    "height": 69,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   0,
+                                                   1,
+                                                   0,
+                                                   0
+                                                   ],
+                                    "items": {
+                                        "count": 2,
+                                        "item_0": {
+                                            "type": "img",
+                                            "source": "img_url",
+                                            "source_type": "data",
+                                            "hAlign": "Center",
+                                            "vAlign": "Middle",
+                                            "x": 5,
+                                            "y": 5,
+                                            "width": 45,
+                                            "height": 45
+                                        },
+                                        "item_1": {
+                                            "type": "text",
+                                            "source": "model",
+                                            "source_type": "data",
+                                            "source_isexpression": false,
+                                            "textAlignment": "left",
+                                            "size": "10",
+                                            "vAlign": "top",
+                                            "x": 60,
+                                            "y": 10,
+                                            "width": 62,
+                                            "height": 50
+                                        }
+                                    }
+                                },
+                                "item_2": {
+                                    "type": "text",
+                                    "source": "description",
+                                    "source_type": "data",
+                                    "source_isexpression": false,
+                                    "margin_left":2,
+                                    "margin_top":2,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   0,
+                                                   1,
+                                                   0,
+                                                   0
+                                                   ],
+                                    "textAlignment": "left",
+                                    "size": "8",
+                                    "vAlign": "top",
+                                    "x": 152,
+                                    "y": 0,
+                                    "width": 135,
+                                    "height": 69
+                                },
+                                "item_3": {
+                                    "type": "text",
+                                    "source": "count",
+                                    "source_type": "data",
+                                    "margin_left":2,
+                                    "margin_top":2,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   0,
+                                                   1,
+                                                   0,
+                                                   0
+                                                   ],
+                                    "source_isexpression": false,
+                                    "textAlignment": "CENTER",
+                                    "size": "10",
+                                    "vAlign": "top",
+                                    "x": 287,
+                                    "y": 0,
+                                    "width": 40,
+                                    "height": 69
+                                },
+                                "item_4": {
+                                    "type": "text",
+                                    "text": "",
+                                    "source_type": "const",
+                                    "margin_left":2,
+                                    "margin_top":2,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   0,
+                                                   1,
+                                                   0,
+                                                   0
+                                                   ],
+                                    "source_isexpression": false,
+                                    "textAlignment": "CENTER",
+                                    "size": "10",
+                                    "vAlign": "top",
+                                    "x": 327,
+                                    "y": 0,
+                                    "width": 84,
+                                    "height": 69
+                                },
+                                "item_5": {
+                                    "type": "text",
+                                    "source": "unit_price",
+                                    "source_type": "data",
+                                    "margin_left":2,
+                                    "margin_top":2,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   0,
+                                                   1,
+                                                   0,
+                                                   0
+                                                   ],
+                                    "source_isexpression": false,
+                                    "textAlignment": "CENTER",
+                                    "size": "10",
+                                    "vAlign": "top",
+                                    "x": 411,
+                                    "y": 0,
+                                    "width": 80,
+                                    "height": 69
+                                },
+                                "item_6": {
+                                    "type": "text",
+                                    "source": "amount",
+                                    "source_type": "data",
+                                    "margin_left":2,
+                                    "margin_top":2,
+                                    "draw_bound": true,
+                                    "line_width": [
+                                                   0,
+                                                   1,
+                                                   0,
+                                                   0
+                                                   ],
+                                    "source_isexpression": false,
+                                    "textAlignment": "CENTER",
+                                    "size": "10",
+                                    "vAlign": "top",
+                                    "x": 491,
+                                    "y": 0,
+                                    "width": 80,
+                                    "height": 69
+                                }
+                            }
+                        }
+                    }
                 }
             }
         }

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio