Bläddra i källkod

161025

Add:
interface offline_request_tearsheet
func prepare_portfolio_data
func get_pdftemplate
resource group PDFResource

Modify:
pdfCreator:: ImageDrawable support scale and align.
pdfCreator:: PDFDrawable support draw bound.
Ray Zhang 9 år sedan
förälder
incheckning
1632722bd6
23 ändrade filer med 646 tillägg och 35 borttagningar
  1. BIN
      RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/UserInterfaceState.xcuserstate
  2. 230 22
      RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. 2 0
      RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.h
  4. 25 1
      RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m
  5. 2 0
      RedAnt ERP Mobile/common/RAUtils.h
  6. 42 1
      RedAnt ERP Mobile/common/RAUtils.m
  7. 1 1
      RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m
  8. 16 2
      RedAnt ERP Mobile/common/pdfCreator/ImageDrawable.m
  9. 1 1
      RedAnt ERP Mobile/common/pdfCreator/LineDrawable.h
  10. 20 0
      RedAnt ERP Mobile/common/pdfCreator/LineDrawable.m
  11. 5 1
      RedAnt ERP Mobile/common/pdfCreator/PDFDrawable.h
  12. 42 2
      RedAnt ERP Mobile/common/pdfCreator/PDFDrawable.m
  13. 2 1
      RedAnt ERP Mobile/common/pdfCreator/TextDrawable.m
  14. 3 3
      RedAnt ERP Mobile/common/pdfCreator/pdfCreator.m
  15. 16 0
      RedAnt ERP Mobile/iSales-NPD.xcodeproj/project.pbxproj
  16. 6 0
      RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/Contents.json
  17. 21 0
      RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_cover_logo.imageset/Contents.json
  18. BIN
      RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_cover_logo.imageset/NPD logo.jpg
  19. 21 0
      RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_cover_title.imageset/Contents.json
  20. BIN
      RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_cover_title.imageset/Logo NPD-5.png
  21. 21 0
      RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_logo_s.imageset/Contents.json
  22. BIN
      RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_logo_s.imageset/NPD logo(1).jpg
  23. 170 0
      RedAnt ERP Mobile/iSales-NPD/portfolio_3x2.json

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


+ 230 - 22
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -212,11 +212,11 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/Functions/offline/OLDataProvider.m"
-            timestampString = "496652981.938062"
+            timestampString = "498991957.05668"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "38"
-            endingLineNumber = "38"
+            startingLineNumber = "69"
+            endingLineNumber = "69"
             landmarkName = "+get_offline_soid:"
             landmarkType = "7">
          </BreakpointContent>
@@ -228,11 +228,11 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/Functions/offline/OLDataProvider.m"
-            timestampString = "497764322.556114"
+            timestampString = "498991957.05668"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "2091"
-            endingLineNumber = "2091"
+            startingLineNumber = "2122"
+            endingLineNumber = "2122"
             landmarkName = "+offline_createorder:"
             landmarkType = "7">
          </BreakpointContent>
@@ -244,11 +244,11 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/Functions/offline/OLDataProvider.m"
-            timestampString = "496651840.731071"
+            timestampString = "498991957.05668"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "31"
-            endingLineNumber = "31"
+            startingLineNumber = "62"
+            endingLineNumber = "62"
             landmarkName = "+get_offline_soid:"
             landmarkType = "7">
          </BreakpointContent>
@@ -451,11 +451,11 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/Functions/offline/OLDataProvider.m"
-            timestampString = "497764322.556114"
+            timestampString = "498991957.05668"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "1750"
-            endingLineNumber = "1750"
+            startingLineNumber = "1781"
+            endingLineNumber = "1781"
             landmarkName = "+offline_model:"
             landmarkType = "7">
          </BreakpointContent>
@@ -611,11 +611,11 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/Functions/offline/OLDataProvider.m"
-            timestampString = "497689866.465849"
+            timestampString = "498991957.05668"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "297"
-            endingLineNumber = "297"
+            startingLineNumber = "328"
+            endingLineNumber = "328"
             landmarkName = "+prepareWishlist:"
             landmarkType = "7">
          </BreakpointContent>
@@ -847,7 +847,7 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            shouldBeEnabled = "Yes"
+            shouldBeEnabled = "No"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/CommonEditor/CommonEditorViewController.m"
@@ -899,11 +899,11 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/pdfCreator/pdfCreator.m"
-            timestampString = "498732233.37945"
+            timestampString = "498966186.007355"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "168"
-            endingLineNumber = "168"
+            startingLineNumber = "170"
+            endingLineNumber = "170"
             landmarkName = "+CreatePdf:dataSource:"
             landmarkType = "7">
          </BreakpointContent>
@@ -915,14 +915,222 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/pdfCreator/TextDrawable.m"
-            timestampString = "498732517.200441"
+            timestampString = "498993183.388304"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "392"
-            endingLineNumber = "392"
+            startingLineNumber = "393"
+            endingLineNumber = "393"
             landmarkName = "-Draw1:dataSource:ParentRect:startX:startY:"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/CommonEditor/CommonEditorViewController.m"
+            timestampString = "498968405.555172"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "5139"
+            endingLineNumber = "5139"
+            landmarkName = "-setEnumValue:indexPath:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/Functions/offline/OLDataProvider.m"
+            timestampString = "498991957.05668"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "53"
+            endingLineNumber = "53"
+            landmarkName = "+offline_request_tearsheet:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/pdfCreator/ImageDrawable.m"
+            timestampString = "498989044.687358"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "53"
+            endingLineNumber = "53"
+            landmarkName = "-Draw:dataSource:ParentRect:startX:startY:flipHeight:range:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/pdfCreator/ImageDrawable.m"
+            timestampString = "498989205.522175"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "51"
+            endingLineNumber = "51"
+            landmarkName = "-Draw:dataSource:ParentRect:startX:startY:flipHeight:range:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/pdfCreator/ImageDrawable.m"
+            timestampString = "498989207.621631"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "48"
+            endingLineNumber = "48"
+            landmarkName = "-Draw:dataSource:ParentRect:startX:startY:flipHeight:range:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/pdfCreator/PDFDrawable.m"
+            timestampString = "498989398.014826"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "25"
+            endingLineNumber = "25"
+            landmarkName = "-setDrawableTemplate:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/pdfCreator/ImageDrawable.m"
+            timestampString = "498989689.534611"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "44"
+            endingLineNumber = "44"
+            landmarkName = "-Draw:dataSource:ParentRect:startX:startY:flipHeight:range:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/pdfCreator/PDFDrawable.m"
+            timestampString = "498989699.355648"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "71"
+            endingLineNumber = "71"
+            landmarkName = "-to_parent_rect:pos:offsetX:offsetY:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/RAUtils.m"
+            timestampString = "498990175.68414"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "151"
+            endingLineNumber = "151"
+            landmarkName = "+rectAlign:rect:hAlign:vAlign:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "../../Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGGeometry.h"
+            timestampString = "498990218.412646"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "282"
+            endingLineNumber = "282"
+            landmarkName = "CGPointMake(CGFloat x, CGFloat y)"
+            landmarkType = "9">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/pdfCreator/TextDrawable.m"
+            timestampString = "498992049.327481"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "215"
+            endingLineNumber = "215"
+            landmarkName = "-Draw:dataSource:ParentRect:startX:startY:flipHeight:range:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/pdfCreator/PDFPage.m"
+            timestampString = "498992124.445752"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "76"
+            endingLineNumber = "76"
+            landmarkName = "-QueryPageCount:dataSource:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/Functions/portfolio/PDFListViewController.m"
+            timestampString = "499048957.895788"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "498"
+            endingLineNumber = "498"
+            landmarkName = "-tableView:didSelectRowAtIndexPath:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 2 - 0
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.h

@@ -114,4 +114,6 @@
 
 + (NSData *)offline_removePDF:(NSMutableDictionary *)params;
 
++(NSData*) offline_request_tearsheet :(NSMutableDictionary *) params;
+
 @end

+ 25 - 1
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -15,6 +15,8 @@
 #import "UIProgressView+AFNetworking.h"
 #import "AFHTTPSessionManager.h"
 #import "AppDelegate.h"
+#import "pdfCreator.h"
+
 
 @interface OLDataProvider ()
 
@@ -27,7 +29,29 @@
     // not impl
     return nil;
 }
-
++(NSMutableDictionary*) prepare_portfolio_data:(NSMutableDictionary*) params
+{
+    NSMutableDictionary* data = [[NSMutableDictionary alloc]init];
+    data[@"npd_url"]=@"www.newpacificdirect.com";
+    return data;
+}
++(NSMutableDictionary*) get_pdftemplate:(NSString*) template
+{
+    NSString *path = [[NSBundle mainBundle] pathForResource:template ofType:nil];
+    NSData *data = [NSData dataWithContentsOfFile:path];
+    NSMutableDictionary *ret = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] mutableCopy];
+    return ret;
+}
++(NSData*) offline_request_tearsheet :(NSMutableDictionary *) params
+{
+    NSString* template_file=@"portfolio_3x2.json";
+    NSMutableDictionary* data = [self prepare_portfolio_data:params];
+    NSMutableDictionary* template = [self get_pdftemplate:template_file];
+    
+    NSString* file=[pdfCreator CreatePdf: template dataSource:data];
+    NSLog(file);
+    return nil;
+}
 +(NSString*) get_offline_soid:(sqlite3*)db
 {
     NSString* soid=nil;

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

@@ -44,6 +44,8 @@ typedef void (^add_to_cart_Handler)(void);
 +(NSData*) getdbfile;
 +(NSString*) getdbzip;
 + (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size;
++ (CGRect)scaleToSize:(CGRect )from to:(CGSize)to;
++ (CGRect)rectAlign:(CGRect )parent rect:(CGRect)rect hAlign:(NSString*)hAlign vAlign:(NSString*)vAlign;
 +(UIImage*)img_compress:(UIImage*)image kbsize:(float) size;
 +(NSString* )current_date;
 +(NSMutableArray*)dictionary2array:(NSDictionary*)json count_fields:(NSString*) count_fields item_mark:(NSString*) item_mark items_mark:(NSString* )items_mark;

+ 42 - 1
RedAnt ERP Mobile/common/RAUtils.m

@@ -144,7 +144,48 @@
     }
     return true;
 }
-
++ (CGRect)rectAlign:(CGRect )parent rect:(CGRect)rect hAlign:(NSString*)hAlign vAlign:(NSString*)vAlign
+{
+//    double cx=parent.origin.x+parent.size.width/2;
+//    double cy=parent.origin.y+parent.size.height/2;
+    CGPoint centerpoint= CGPointMake(parent.origin.x+parent.size.width/2,parent.origin.y+parent.size.height/2);
+    if([hAlign.lowercaseString isEqualToString:@"center"])
+    {
+        rect=CGRectMake(centerpoint.x-rect.size.width/2, rect.origin.y, rect.size.width, rect.size.height);
+    }
+    
+    if([vAlign.lowercaseString isEqualToString:@"middle"])
+    {
+        rect=CGRectMake(rect.origin.x, centerpoint.y-rect.size.height/2, rect.size.width, rect.size.height);
+    }
+    
+    return rect;
+    
+}
++ (CGRect)scaleToSize:(CGRect )from to:(CGSize)to
+{
+    if(from.size.width/from.size.height>to.width/to.height)
+    {
+        return CGRectMake(from.origin.x, from.origin.y, to.width, to.width*from.size.height/from.size.width);
+    }
+    else
+    {
+        return CGRectMake(from.origin.x, from.origin.y, to.height*from.size.width/from.size.height, to.height);
+    }
+//    // 创建一个bitmap的context
+//    // 并把它设置成为当前正在使用的context
+//    UIGraphicsBeginImageContext(size);
+//    // 绘制改变大小的图片
+//    [img drawInRect:CGRectMake(0, 0, size.width, size.height)];
+//    // 从当前context中创建一个改变大小后的图片
+//    UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
+//    // 使当前的context出堆栈
+//    UIGraphicsEndImageContext();
+//    // 返回新的改变大小后的图片
+//    
+//    //   NSData  *imageData=UIImageJPEGRepresentation(scaledImage, 1.f);
+//    return scaledImage;
+}
 + (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size{
     // 创建一个bitmap的context
     // 并把它设置成为当前正在使用的context

+ 1 - 1
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -1543,7 +1543,7 @@ repeat:
     NSData* json= nil;
     if(appDelegate.offline_mode)
     {
-        return [OLDataProvider offline_notimpl];
+        json= [OLDataProvider offline_request_tearsheet:params];
     }
     else
     {

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

@@ -7,6 +7,7 @@
 //
 
 #import "ImageDrawable.h"
+#import "RAUtils.h"
 
 @implementation ImageDrawable
 -(CGRect) Query_Rect:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
@@ -35,15 +36,28 @@
         image=[UIImage imageNamed:data[self.drawableTemplate[@"source"]]];
     }
     
+    
+    
 //    CGRect rect=[self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];//CGRectMake(self.rect.origin.x+x, self.rect.origin.y, self.rect.size.width, self.rect.size.height);
 //    rect=CGRectMake(rect.origin.x, flip_height-rect.origin.y-rect.size.height, rect.size.width, rect.size.height);
     
     CGRect parentrect = [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
-
     
-    CGRect rect = [self to_pdf_rect:p_rect pos:self.rect contextHeight:flip_height];
+    
+    
+    CGRect scalerect = [RAUtils scaleToSize:CGRectMake(0, 0, image.size.width, image.size.height) to:parentrect.size];
+    
+    
+    CGRect rect=[RAUtils rectAlign:parentrect rect:scalerect hAlign:self.hAlign vAlign:self.vAlign];
+                        
+    //image=[RAUtils scaleToSize:image size:parentrect.size];
+
+    rect= [self parent_to_pdf_rect:rect contextHeight:flip_height];
+    //CGRect rect = [self to_pdf_rect:p_rect pos:self.rect contextHeight:flip_height];
     CGContextDrawImage(context, rect, image.CGImage);
     
+    
+    [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);

+ 1 - 1
RedAnt ERP Mobile/common/pdfCreator/LineDrawable.h

@@ -9,5 +9,5 @@
 #import "BasicDrawable.h"
 
 @interface LineDrawable : BasicDrawable
-
++(NSMutableDictionary *) createlineTemplate:(double) width from:(CGPoint) from to:(CGPoint) to;
 @end

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

@@ -10,6 +10,26 @@
 
 @implementation LineDrawable
 
+
++(NSMutableDictionary *) createlineTemplate:(double) width from:(CGPoint) from to:(CGPoint) to
+{
+    NSMutableDictionary* ret=[[NSMutableDictionary alloc]init];
+//    "type": "line",
+//    "x0": 10,
+//    "y0": 10,
+//    "x1": 100,
+//    "y1": 100,
+//    "line_width": 0.02
+    ret[@"type"]=@"line" ;
+    ret[@"x0"]=[NSNumber numberWithDouble:from.x] ;
+    ret[@"y0"]=[NSNumber numberWithDouble:from.y] ;
+    ret[@"x1"]=[NSNumber numberWithDouble:to.x] ;
+    ret[@"y1"]=[NSNumber numberWithDouble:to.y] ;
+    ret[@"line_width"]=[NSNumber numberWithDouble:width] ;
+
+    return ret;
+}
+
 -(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
 {
     

+ 5 - 1
RedAnt ERP Mobile/common/pdfCreator/PDFDrawable.h

@@ -26,6 +26,8 @@
 
 @interface PDFDrawable : NSObject
 @property (nonatomic,strong) NSMutableDictionary* drawableTemplate;
+@property (nonatomic,strong) NSString* hAlign;
+@property (nonatomic,strong) NSString* vAlign;
 @property double margin_left;
 @property double margin_right;
 @property double margin_top;
@@ -41,8 +43,10 @@
 -(instancetype) init:(NSMutableDictionary *)drawableTemplate;
 -(CGRect)to_parent_rect:(CGRect)parentRect pos:(CGRect)rect offsetX:(double)x offsetY:(double)y;
 -(CGPoint)to_parent_point:(CGRect)parentRect point:(CGPoint)p offsetX:(double)x offsetY:(double)y;
-
+-(CGRect)parent_to_pdf_rect:(CGRect)rect contextHeight:(double) height;
 
 -(CGRect)to_pdf_rect:(CGRect)parentRect pos:(CGRect)rect contextHeight:(double) height;
 -(CGPoint)to_pdf_point:(CGRect)parentRect point:(CGPoint)p contextHeight:(double) height;
+
+-(void) DrawBound:(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;
 @end

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

@@ -7,7 +7,7 @@
 //
 
 #import "PDFDrawable.h"
-
+#import "LineDrawable.h"
 
 @implementation PDFDrawable
 -(instancetype) init:(NSMutableDictionary *)drawableTemplate
@@ -27,10 +27,45 @@
     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.hAlign =self.drawableTemplate[@"hAlign"];
+    self.vAlign =self.drawableTemplate[@"vAlign"];
     self.rect = CGRectMake([self.drawableTemplate[@"x"] doubleValue], [self.drawableTemplate[@"y"] doubleValue], [self.drawableTemplate[@"width"] doubleValue], [self.drawableTemplate[@"height"] doubleValue]);
  //   self.drawable_rect = CGRectMake(self.rect.origin.x+self.margin_left, self.rect.origin.y+self.margin_top, self.rect.size.width-self.margin_right, self.rect.size.height-self.margin_bottom);
+}
+-(void) DrawBound:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
+{
+    CGRect rect = [self rect];//[self to_pdf_rect:p_rect pos:self.rect contextHeight:flip_height];
+
+    NSMutableDictionary* tline4= [LineDrawable createlineTemplate:0.05 from:CGPointMake(rect.origin.x, rect.origin.y+rect.size.height) to:CGPointMake(rect.origin.x, rect.origin.y)];
+    LineDrawable* line4=nil;
+    line4= [[LineDrawable alloc] init:tline4];
+    [line4 Draw:context dataSource:data ParentRect:p_rect startX:x startY:y flipHeight:flip_height range:between_header_and_footer];
+    
+    
+    NSMutableDictionary* tline3= [LineDrawable createlineTemplate:0.05 from:CGPointMake(rect.origin.x+rect.size.width, rect.origin.y+rect.size.height) to:CGPointMake(rect.origin.x, rect.origin.y+rect.size.height)];
+    LineDrawable* line3=nil;
+    line3= [[LineDrawable alloc] init:tline3];
+    [line3 Draw:context dataSource:data ParentRect:p_rect startX:x startY:y flipHeight:flip_height range:between_header_and_footer];
+    
+    
+    
+    NSMutableDictionary* tline2= [LineDrawable createlineTemplate:0.05 from:CGPointMake(rect.origin.x+rect.size.width, rect.origin.y) to:CGPointMake(rect.origin.x+rect.size.width, rect.origin.y+rect.size.height)];
+    LineDrawable* line2=nil;
+    line2= [[LineDrawable alloc] init:tline2];
+    [line2 Draw:context dataSource:data ParentRect:p_rect startX:x startY:y flipHeight:flip_height range:between_header_and_footer];
+    
+    NSMutableDictionary* tline1= [LineDrawable createlineTemplate:0.05 from:CGPointMake(rect.origin.x, rect.origin.y) to:CGPointMake(rect.origin.x+rect.size.width, rect.origin.y)];
+        LineDrawable* line1=nil;
+    line1= [[LineDrawable alloc] init:tline1];
+    [line1 Draw:context dataSource:data ParentRect:p_rect startX:x startY:y flipHeight:flip_height range:between_header_and_footer];
+    
+    
+    
+    
+
 }
 
+
 -(CGRect)to_parent_rect:(CGRect)parentRect pos:(CGRect)rect offsetX:(double)x offsetY:(double)y
 {
     return CGRectMake(parentRect.origin.x+self.margin_left+rect.origin.x+x, parentRect.origin.y+self.margin_top+self.rect.origin.y+y/*-self.rect.size.height*/, self.rect.size.width-self.margin_left-self.margin_right, self.rect.size.height-self.margin_top-self.margin_bottom);
@@ -41,7 +76,12 @@
     pdfrect=CGRectMake(pdfrect.origin.x, height-pdfrect.origin.y-pdfrect.size.height, pdfrect.size.width, pdfrect.size.height);
     return pdfrect;
 }
-
+-(CGRect)parent_to_pdf_rect:(CGRect)rect contextHeight:(double) height
+{
+  //  CGRect pdfrect=[self to_parent_rect:parentRect pos:rect offsetX:0 offsetY:0];//CGRectMake(self.rect.origin.x+x, self.rect.origin.y, self.rect.size.width, self.rect.size.height);
+    CGRect pdfrect=CGRectMake(rect.origin.x, height-rect.origin.y-rect.size.height, rect.size.width, rect.size.height);
+    return pdfrect;
+}
 
 -(CGPoint)to_parent_point:(CGRect)parentRect point:(CGPoint)p offsetX:(double)x offsetY:(double)y
 {

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

@@ -357,7 +357,8 @@
     CGPathRelease(leftColumnPath);
     CFRelease(framesetter);
     
-    
+    [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);
     

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

@@ -112,7 +112,7 @@
     
     NSString *saveDirectory=[paths objectAtIndex:0];
     
-    NSString *saveFileName=@"myPDF.pdf";
+    NSString *saveFileName=[NSString stringWithFormat:@"%@.pdf",[[NSUUID UUID ] UUIDString] ] ;
     
     NSString *newFilePath=[saveDirectory stringByAppendingPathComponent:saveFileName];
     
@@ -165,9 +165,9 @@
     
     CGContextRelease(pdfContext);
     
-    NSURL* nsurl=CFBridgingRelease(url);
+//    NSURL* nsurl=CFBridgingRelease(url);
     
-    return [nsurl absoluteString];
+    return newFilePath;
     
 }
 

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

@@ -45,6 +45,8 @@
 		712AFEDE1DBA050200254965 /* TableDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFED41DBA050200254965 /* TableDrawable.m */; };
 		712AFEDF1DBA050200254965 /* TextDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFED61DBA050200254965 /* TextDrawable.m */; };
 		712AFEE21DBA077F00254965 /* pdfCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = 712AFEE11DBA077F00254965 /* pdfCreator.m */; };
+		712AFEE51DBDAF0300254965 /* pdfcreator.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 712AFEE41DBDAF0300254965 /* pdfcreator.xcassets */; };
+		712AFEE71DBDB48000254965 /* portfolio_3x2.json in Resources */ = {isa = PBXBuildFile; fileRef = 712AFEE61DBDB48000254965 /* portfolio_3x2.json */; };
 		712BABF31C897E3A0007466B /* CategorySearchFilterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 712BABF21C897E3A0007466B /* CategorySearchFilterViewController.m */; };
 		712C40B61C7310F4000E6831 /* CartGeneralNotesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 712C40B51C7310F4000E6831 /* CartGeneralNotesViewController.m */; };
 		712C40B91C731126000E6831 /* ItemNotesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 712C40B81C731126000E6831 /* ItemNotesViewController.m */; };
@@ -295,6 +297,8 @@
 		712AFED61DBA050200254965 /* TextDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextDrawable.m; path = common/pdfCreator/TextDrawable.m; sourceTree = SOURCE_ROOT; };
 		712AFEE01DBA077F00254965 /* pdfCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pdfCreator.h; path = common/pdfCreator/pdfCreator.h; sourceTree = SOURCE_ROOT; };
 		712AFEE11DBA077F00254965 /* pdfCreator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = pdfCreator.m; path = common/pdfCreator/pdfCreator.m; sourceTree = SOURCE_ROOT; };
+		712AFEE41DBDAF0300254965 /* pdfcreator.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = pdfcreator.xcassets; sourceTree = "<group>"; };
+		712AFEE61DBDB48000254965 /* portfolio_3x2.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = portfolio_3x2.json; sourceTree = "<group>"; };
 		712BABF11C897E3A0007466B /* CategorySearchFilterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CategorySearchFilterViewController.h; path = common/Functions/category/CategorySearchFilterViewController.h; sourceTree = SOURCE_ROOT; };
 		712BABF21C897E3A0007466B /* CategorySearchFilterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CategorySearchFilterViewController.m; path = common/Functions/category/CategorySearchFilterViewController.m; sourceTree = SOURCE_ROOT; };
 		712C40B41C7310F4000E6831 /* CartGeneralNotesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CartGeneralNotesViewController.h; path = common/Functions/cart/CartGeneralNotesViewController.h; sourceTree = SOURCE_ROOT; };
@@ -759,6 +763,15 @@
 			name = pdfCreator;
 			sourceTree = "<group>";
 		};
+		712AFEE31DBDAEA000254965 /* PDFResource */ = {
+			isa = PBXGroup;
+			children = (
+				712AFEE41DBDAF0300254965 /* pdfcreator.xcassets */,
+				712AFEE61DBDB48000254965 /* portfolio_3x2.json */,
+			);
+			name = PDFResource;
+			sourceTree = "<group>";
+		};
 		713393FE19936C980075BBAC /* Signature */ = {
 			isa = PBXGroup;
 			children = (
@@ -972,6 +985,7 @@
 			isa = PBXGroup;
 			children = (
 				712AFEC41DBA044C00254965 /* pdfCreator */,
+				712AFEE31DBDAEA000254965 /* PDFResource */,
 				42BED0141DAF74DF004576E0 /* JKLock */,
 				421C54FF1D81586D00CFA3B1 /* JKTimer */,
 				42E58BFF1D7E735A0092810A /* UIColor+HEX */,
@@ -1470,6 +1484,7 @@
 				42C9FB151D5B28FA001DCA8B /* contactAdvanceSearch.json in Resources */,
 				7161FEB51D61B24900157EE1 /* creditcardpayment.html in Resources */,
 				71777FC61C8AC97300DA2511 /* debug_category_filter.json in Resources */,
+				712AFEE71DBDB48000254965 /* portfolio_3x2.json in Resources */,
 				71DF74951C57614C00F2789C /* PhotoBorder.png in Resources */,
 				7162A55F1C58724700AB630E /* customer_info_template.json in Resources */,
 				71D46D111CE1D9EF00A081AC /* OLM.storyboard in Resources */,
@@ -1485,6 +1500,7 @@
 				7111E5721C76C557004763B3 /* customer_info_template_edit.json in Resources */,
 				7161FEB61D61B24900157EE1 /* normalpayment.html in Resources */,
 				71DF74961C57614C00F2789C /* PhotoBorder@2x.png in Resources */,
+				712AFEE51DBDAF0300254965 /* pdfcreator.xcassets in Resources */,
 				7162A55E1C58724700AB630E /* customer_advanced_search.json in Resources */,
 				7162A5A11C58733400AB630E /* offline_status_filter_cadedate.json in Resources */,
 				713F76BD1929F4A7006A7305 /* Main.storyboard in Resources */,

+ 6 - 0
RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/Contents.json

@@ -0,0 +1,6 @@
+{
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

+ 21 - 0
RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_cover_logo.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "NPD logo.jpg",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_cover_logo.imageset/NPD logo.jpg


+ 21 - 0
RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_cover_title.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "Logo NPD-5.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_cover_title.imageset/Logo NPD-5.png


+ 21 - 0
RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_logo_s.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "NPD logo(1).jpg",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_logo_s.imageset/NPD logo(1).jpg


+ 170 - 0
RedAnt ERP Mobile/iSales-NPD/portfolio_3x2.json

@@ -0,0 +1,170 @@
+{
+    "paper": {
+        "width": 792,
+        "height": 612
+    },
+    "pages": {
+        "count": 1,
+        "page_0":{
+            "name": "cover page",
+            "header": {},
+            "footer": {},
+            "margin_left": 20,
+            "margin_right": 20,
+            "margin_top": 20,
+            "margin_bottom": 20,
+            "contents": {
+                "count": 3,
+                "item_0": {
+                    "type": "img",
+                    
+                    "hAlign":"Center",
+                    "vAlign":"Middle",
+                    "source": "portfolio_cover_title",
+                    "source_type":"const",
+                    "x": 107,
+                    "y": 45,
+                    "width": 539,
+                    "height": 77
+                },
+                "item_1": {
+                    "type": "img",
+                    
+                    "hAlign":"Center",
+                    "vAlign":"Middle",
+                    "source": "portfolio_cover_logo",
+                    "source_type":"const",
+                    "x": 242,
+                    "y": 124,
+                    "width": 268,
+                    "height": 117
+                },
+                
+                "item_2": {
+                    "type": "text",
+                    "source": "npd_url",
+                    "source_type": "data",
+                    "font": "Kalinga",
+                    "size": "14",
+                    "x": 287,
+                    "y": 511.56,
+                    "width": 179,
+                    "height": 34
+                }
+            }
+        },
+        "page_1": {
+            "name": "cover page",
+            "header": {},
+            "footer": {},
+            "margin_left": 15,
+            "margin_right": 15,
+            "margin_top": 15,
+            "margin_bottom": 15,
+            "contents": {
+                "count": 1,
+                "item_1": {
+                    "type": "grid",
+                    "data_source": "table1_data",
+                    "cell": {
+                        "direction": "V",
+                        "duplicate": 0,
+                        "data_source": "row0",
+                        "repeat": "horizontal",
+                        "type": "group",
+                        "x": 10,
+                        "y": 10,
+                        "width": 100,
+                        "height": 200,
+                        "items": {
+                            "count": 3,
+                            "item_1": {
+                                "type": "line",
+                                "x0": 10,
+                                "y0": 10,
+                                "x1": 100,
+                                "y1": 100,
+                                "line_width": 0.02
+                            },
+                            "item_0": {
+                                "type": "img",
+                                "source": "image0",
+                                "source_type": "data",
+                                "x": 10,
+                                "y": 10,
+                                "width": 100,
+                                "height": 100
+                            },
+                            "item_2": {
+                                "type": "text",
+                                "source": "text0",
+                                "source_type": "data",
+                                "font": "font name",
+                                "size": "15",
+                                "x": 10,
+                                "y": 10,
+                                "width": 100,
+                                "height": 100
+                            }
+                        }
+                    },
+                    "x": 10,
+                    "y": 10,
+                    "width": 530,
+                    "height": 760
+                },
+                "item_0": {
+                    "type": "table",
+                    "data_source": "table1_data",
+                    "rows": {
+                        "count": 1,
+                        "row_0": {
+                            "data_source": "row0",
+                            "repeat": "horizontal",
+                            "type": "group",
+                            "x": 10,
+                            "y": 10,
+                            "width": 100,
+                            "height": 200,
+                            "items": {
+                                "count": 3,
+                                "item_1": {
+                                    "type": "line",
+                                    "x0": 10,
+                                    "y0": 10,
+                                    "x1": 100,
+                                    "y1": 100,
+                                    "line_width": 0.02
+                                },
+                                "item_0": {
+                                    "type": "img",
+                                    "source": "image0",
+                                    "source_type": "data",
+                                    "x": 10,
+                                    "y": 10,
+                                    "width": 100,
+                                    "height": 100
+                                },
+                                "item_2": {
+                                    "type": "text",
+                                    "source": "text0",
+                                    "source_type": "data",
+                                    "font": "font name",
+                                    "size": "15",
+                                    "x": 10,
+                                    "y": 10,
+                                    "width": 100,
+                                    "height": 100
+                                }
+                            }
+                        }
+                    },
+                    "x": 10,
+                    "y": 10,
+                    "width": 100,
+                    "height": -1
+                }
+            }
+        }
+    }
+}