Ver código fonte

eSign

修复iOS 11 兼容性问题
Ray Zhang 8 anos atrás
pai
commit
a3db663c91
28 arquivos alterados com 1656 adições e 66 exclusões
  1. 5 0
      Ants Contract/AntsContract.xcworkspace/xcuserdata/Ray.xcuserdatad/IDEFindNavigatorScopes.plist
  2. BIN
      Ants Contract/AntsContract.xcworkspace/xcuserdata/Ray.xcuserdatad/UserInterfaceState.xcuserstate
  3. 18 0
      Ants Contract/AntsContract.xcworkspace/xcuserdata/Ray.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  4. 8 8
      Ants Contract/AntsContract/AntsContract.xcodeproj/project.pbxproj
  5. 26 5
      Ants Contract/AntsContract/AntsContract/Base.lproj/Main.storyboard
  6. 30 24
      Ants Contract/Granite Expo eSign/Granite Expo eSign.xcodeproj/project.pbxproj
  7. 4 4
      Ants Contract/Granite Expo eSign/Granite Expo eSign/DocumentTemplateViewController.m
  8. 4 4
      Ants Contract/Granite Expo eSign/Granite Expo eSign/TemplateViewController.h
  9. 1 1
      Ants Contract/Granite Expo eSign/Granite Expo eSign/TemplateViewController.m
  10. 13 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/dbgPageVC.h
  11. 37 0
      Ants Contract/Granite Expo eSign/Granite Expo eSign/dbgPageVC.m
  12. 2 2
      Ants Contract/common/AddExtDocumentViewController.m
  13. 2 2
      Ants Contract/common/DocumentListViewController.m
  14. 8 3
      Ants Contract/common/DocumentPageViewController.m
  15. 2 2
      Ants Contract/common/ExtDocumentsViewController.m
  16. 4 4
      Ants Contract/common/PageViewController.h
  17. 1 0
      Ants Contract/common/PageViewController.m
  18. 2 2
      Ants Contract/common/PendingDocumentsViewController.m
  19. 14 0
      Ants Contract/common/RAPDFPageView.h
  20. 136 0
      Ants Contract/common/RAPDFPageView.m
  21. 13 0
      Ants Contract/common/RAPDFScrollView.h
  22. 21 0
      Ants Contract/common/RAPDFScrollView.m
  23. 2 2
      Ants Contract/common/RootViewController.m
  24. 45 0
      RedAnt ERP Mobile/common/Functions/PDF+Web/RAPDFViewController.h
  25. 942 0
      RedAnt ERP Mobile/common/Functions/PDF+Web/RAPDFViewController.m
  26. 3 3
      RedAnt ERP Mobile/common/PDFUtils.m
  27. 37 0
      RedAnt ERP Mobile/common/pdfCreator/RAPDFPage.h
  28. 276 0
      RedAnt ERP Mobile/common/pdfCreator/RAPDFPage.m

+ 5 - 0
Ants Contract/AntsContract.xcworkspace/xcuserdata/Ray.xcuserdatad/IDEFindNavigatorScopes.plist

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<array/>
+</plist>

BIN
Ants Contract/AntsContract.xcworkspace/xcuserdata/Ray.xcuserdatad/UserInterfaceState.xcuserstate


+ 18 - 0
Ants Contract/AntsContract.xcworkspace/xcuserdata/Ray.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -2,4 +2,22 @@
 <Bucket
    type = "0"
    version = "2.0">
+   <Breakpoints>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "Granite Expo eSign/Granite Expo eSign/DocumentTemplateViewController.m"
+            timestampString = "528084993.952433"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "496"
+            endingLineNumber = "496"
+            landmarkName = "-onSaveClicked:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+   </Breakpoints>
 </Bucket>

+ 8 - 8
Ants Contract/AntsContract/AntsContract.xcodeproj/project.pbxproj

@@ -7,7 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		7128C12C1E11163800FF635B /* PDFViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C12B1E11163800FF635B /* PDFViewController.m */; };
+		7128C12C1E11163800FF635B /* RAPDFViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C12B1E11163800FF635B /* RAPDFViewController.m */; };
 		713E83B71E037C2000C4F12A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 713E83B61E037C2000C4F12A /* main.m */; };
 		713E83BA1E037C2000C4F12A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 713E83B91E037C2000C4F12A /* AppDelegate.m */; };
 		713E83BD1E037C2000C4F12A /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 713E83BC1E037C2000C4F12A /* RootViewController.m */; };
@@ -40,7 +40,7 @@
 		71D01ADF1E08CC81006620CE /* signature.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71D01ADE1E08CC81006620CE /* signature.storyboard */; };
 		71D01AE31E08F5D2006620CE /* TouchImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 71D01AE21E08F5D2006620CE /* TouchImageView.m */; };
 		71D01AEC1E09215E006620CE /* PDFDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 71D01AE91E09215E006620CE /* PDFDrawable.m */; };
-		71D01AED1E09215E006620CE /* PDFPage.m in Sources */ = {isa = PBXBuildFile; fileRef = 71D01AEB1E09215E006620CE /* PDFPage.m */; };
+		71D01AED1E09215E006620CE /* RAPDFPage.m in Sources */ = {isa = PBXBuildFile; fileRef = 71D01AEB1E09215E006620CE /* RAPDFPage.m */; };
 		71D01AF81E092304006620CE /* BasicDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 71D01AEF1E092304006620CE /* BasicDrawable.m */; };
 		71D01AF91E092304006620CE /* GridDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 71D01AF11E092304006620CE /* GridDrawable.m */; };
 		71D01AFA1E092304006620CE /* GroupDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 71D01AF31E092304006620CE /* GroupDrawable.m */; };
@@ -56,7 +56,7 @@
 
 /* Begin PBXFileReference section */
 		7128C12A1E11163800FF635B /* PDFViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFViewController.h; path = "../../../RedAnt ERP Mobile/common/Functions/PDF+Web/PDFViewController.h"; sourceTree = "<group>"; };
-		7128C12B1E11163800FF635B /* PDFViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PDFViewController.m; path = "../../../RedAnt ERP Mobile/common/Functions/PDF+Web/PDFViewController.m"; sourceTree = "<group>"; };
+		7128C12B1E11163800FF635B /* RAPDFViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RAPDFViewController.m; path = "../../../RedAnt ERP Mobile/common/Functions/PDF+Web/RAPDFViewController.m"; sourceTree = "<group>"; };
 		713E83B21E037C2000C4F12A /* AntsContract.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AntsContract.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		713E83B61E037C2000C4F12A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
 		713E83B81E037C2000C4F12A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -116,7 +116,7 @@
 		71D01AE81E09215E006620CE /* PDFDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFDrawable.h; path = "../../../RedAnt ERP Mobile/common/pdfCreator/PDFDrawable.h"; sourceTree = "<group>"; };
 		71D01AE91E09215E006620CE /* PDFDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PDFDrawable.m; path = "../../../RedAnt ERP Mobile/common/pdfCreator/PDFDrawable.m"; sourceTree = "<group>"; };
 		71D01AEA1E09215E006620CE /* PDFPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPage.h; path = "../../../RedAnt ERP Mobile/common/pdfCreator/PDFPage.h"; sourceTree = "<group>"; };
-		71D01AEB1E09215E006620CE /* PDFPage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PDFPage.m; path = "../../../RedAnt ERP Mobile/common/pdfCreator/PDFPage.m"; sourceTree = "<group>"; };
+		71D01AEB1E09215E006620CE /* RAPDFPage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RAPDFPage.m; path = "../../../RedAnt ERP Mobile/common/pdfCreator/RAPDFPage.m"; sourceTree = "<group>"; };
 		71D01AEE1E092304006620CE /* BasicDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BasicDrawable.h; path = "../../../RedAnt ERP Mobile/common/pdfCreator/BasicDrawable.h"; sourceTree = "<group>"; };
 		71D01AEF1E092304006620CE /* BasicDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BasicDrawable.m; path = "../../../RedAnt ERP Mobile/common/pdfCreator/BasicDrawable.m"; sourceTree = "<group>"; };
 		71D01AF01E092304006620CE /* GridDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GridDrawable.h; path = "../../../RedAnt ERP Mobile/common/pdfCreator/GridDrawable.h"; sourceTree = "<group>"; };
@@ -157,7 +157,7 @@
 			isa = PBXGroup;
 			children = (
 				7128C12A1E11163800FF635B /* PDFViewController.h */,
-				7128C12B1E11163800FF635B /* PDFViewController.m */,
+				7128C12B1E11163800FF635B /* RAPDFViewController.m */,
 			);
 			name = Preview;
 			sourceTree = "<group>";
@@ -302,7 +302,7 @@
 				71D01AE81E09215E006620CE /* PDFDrawable.h */,
 				71D01AE91E09215E006620CE /* PDFDrawable.m */,
 				71D01AEA1E09215E006620CE /* PDFPage.h */,
-				71D01AEB1E09215E006620CE /* PDFPage.m */,
+				71D01AEB1E09215E006620CE /* RAPDFPage.m */,
 				71D01AEE1E092304006620CE /* BasicDrawable.h */,
 				71D01AEF1E092304006620CE /* BasicDrawable.m */,
 				71D01AF01E092304006620CE /* GridDrawable.h */,
@@ -421,7 +421,7 @@
 				715671591E10BDF6006324A0 /* LoginViewController.m in Sources */,
 				71D01B241E0A2069006620CE /* PDFUtils.m in Sources */,
 				71D01B071E0928C2006620CE /* TextDrawable.m in Sources */,
-				7128C12C1E11163800FF635B /* PDFViewController.m in Sources */,
+				7128C12C1E11163800FF635B /* RAPDFViewController.m in Sources */,
 				715671391E10A48E006324A0 /* ACNetwork.m in Sources */,
 				71D01AEC1E09215E006620CE /* PDFDrawable.m in Sources */,
 				71D01B231E0A2069006620CE /* ImageUtils.m in Sources */,
@@ -444,7 +444,7 @@
 				71D01AE31E08F5D2006620CE /* TouchImageView.m in Sources */,
 				713E83BA1E037C2000C4F12A /* AppDelegate.m in Sources */,
 				71D01AFA1E092304006620CE /* GroupDrawable.m in Sources */,
-				71D01AED1E09215E006620CE /* PDFPage.m in Sources */,
+				71D01AED1E09215E006620CE /* RAPDFPage.m in Sources */,
 				7156713C1E10AF67006324A0 /* RAUtils.m in Sources */,
 				715671671E10BE28006324A0 /* NSData+CommonCrypto.m in Sources */,
 				7156714C1E10B031006324A0 /* unzip.c in Sources */,

+ 26 - 5
Ants Contract/AntsContract/AntsContract/Base.lproj/Main.storyboard

@@ -180,7 +180,7 @@
         <!--Page View Controller-->
         <scene sceneID="9YD-lb-QfP">
             <objects>
-                <viewController storyboardIdentifier="PageViewController" id="e1o-QP-z2F" customClass="PageViewController" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="PageViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="e1o-QP-z2F" customClass="PageViewController" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="BEc-Ba-Mzk">
                         <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -193,7 +193,7 @@
                                         <rect key="frame" x="0.0" y="0.0" width="768" height="960"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
-                                            <view contentMode="scaleToFill" id="8Hw-OZ-rsH" customClass="PDFPageView">
+                                            <view contentMode="scaleToFill" id="8Hw-OZ-rsH" customClass="RAPDFPageView">
                                                 <rect key="frame" x="0.0" y="0.0" width="768" height="960"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
@@ -228,7 +228,7 @@
         <!--Template View Controller-->
         <scene sceneID="J7i-eF-9Sx">
             <objects>
-                <viewController storyboardIdentifier="TemplateViewController" id="VeE-j2-f2V" customClass="TemplateViewController" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="TemplateViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="VeE-j2-f2V" customClass="TemplateViewController" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="DPe-e8-0nn">
                         <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -241,7 +241,7 @@
                                         <rect key="frame" x="0.0" y="0.0" width="768" height="960"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
-                                            <view contentMode="scaleToFill" id="vhq-zu-ya0" customClass="PDFPageView">
+                                            <view contentMode="scaleToFill" id="vhq-zu-ya0" customClass="RAPDFPageView">
                                                 <rect key="frame" x="0.0" y="0.0" width="768" height="960"/>
                                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
@@ -457,10 +457,31 @@
             </objects>
             <point key="canvasLocation" x="288" y="864"/>
         </scene>
+        <!--Dbg PageVC-->
+        <scene sceneID="mJi-uN-O6k">
+            <objects>
+                <viewController storyboardIdentifier="dbgPageVC" useStoryboardIdentifierAsRestorationIdentifier="YES" id="cKk-pN-bnV" customClass="dbgPageVC" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="HPf-DD-UPd">
+                        <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <view contentMode="scaleToFill" misplaced="YES" id="L1y-AJ-Fc7" customClass="RAPDFPageView">
+                                <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                            </view>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                    </view>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="PxV-cV-qwl" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="1527" y="-2425"/>
+        </scene>
         <!--PDFViewController-->
         <scene sceneID="l66-ES-CkZ">
             <objects>
-                <viewController storyboardIdentifier="PDFViewController" title="PDFViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="RFL-cn-4ui" customClass="PDFViewController" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="PDFViewController" title="PDFViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="RFL-cn-4ui" customClass="RAPDFViewController" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="tem-U2-psf">
                         <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
                         <autoresizingMask key="autoresizingMask"/>

+ 30 - 24
Ants Contract/Granite Expo eSign/Granite Expo eSign.xcodeproj/project.pbxproj

@@ -21,11 +21,10 @@
 		7128C27C1E12500B00FF635B /* SignatureViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C2751E12500B00FF635B /* SignatureViewController.m */; };
 		7128C27D1E12500B00FF635B /* signature.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7128C2761E12500B00FF635B /* signature.storyboard */; };
 		7128C28E1E12501B00FF635B /* TouchImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C2811E12501B00FF635B /* TouchImageView.m */; };
-		7128C2981E12504300FF635B /* PDFViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C2971E12504300FF635B /* PDFViewController.m */; };
+		7128C2981E12504300FF635B /* RAPDFViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C2971E12504300FF635B /* RAPDFViewController.m */; };
 		7128C2AF1E1250CA00FF635B /* TableDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C29C1E1250CA00FF635B /* TableDrawable.m */; };
 		7128C2B01E1250CA00FF635B /* TextDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C29E1E1250CA00FF635B /* TextDrawable.m */; };
 		7128C2B11E1250CA00FF635B /* PDFDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C2A01E1250CA00FF635B /* PDFDrawable.m */; };
-		7128C2B21E1250CA00FF635B /* PDFPage.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C2A21E1250CA00FF635B /* PDFPage.m */; };
 		7128C2B31E1250CA00FF635B /* BasicDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C2A41E1250CA00FF635B /* BasicDrawable.m */; };
 		7128C2B41E1250CA00FF635B /* GridDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C2A61E1250CA00FF635B /* GridDrawable.m */; };
 		7128C2B51E1250CA00FF635B /* GroupDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C2A81E1250CA00FF635B /* GroupDrawable.m */; };
@@ -55,10 +54,12 @@
 		7128C3411E12542000FF635B /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C3401E12542000FF635B /* LoginViewController.m */; };
 		7128C3461E12545C00FF635B /* CheckSelectorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C3431E12545C00FF635B /* CheckSelectorViewController.m */; };
 		7128C3471E12545C00FF635B /* DocumentPageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C3451E12545C00FF635B /* DocumentPageViewController.m */; };
-		7128C3531E12548C00FF635B /* PDFPageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C34B1E12548C00FF635B /* PDFPageView.m */; };
-		7128C3541E12548C00FF635B /* PDFScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C34D1E12548C00FF635B /* PDFScrollView.m */; };
+		7128C3531E12548C00FF635B /* RAPDFPageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C34B1E12548C00FF635B /* RAPDFPageView.m */; };
+		7128C3541E12548C00FF635B /* RAPDFScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C34D1E12548C00FF635B /* RAPDFScrollView.m */; };
 		7128C3551E12548C00FF635B /* SignatureListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C34F1E12548C00FF635B /* SignatureListViewController.m */; };
 		7128C3561E12548C00FF635B /* SignatureTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 7128C3511E12548C00FF635B /* SignatureTableViewCell.m */; };
+		713B97B11F79E0CB002B86BF /* dbgPageVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 713B97B01F79E0CA002B86BF /* dbgPageVC.m */; };
+		713B97B31F79E649002B86BF /* RAPDFPage.m in Sources */ = {isa = PBXBuildFile; fileRef = 713B97B21F79E649002B86BF /* RAPDFPage.m */; };
 		714A9AEC1E9CA92000371995 /* PendingDocumentsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 714A9AEB1E9CA92000371995 /* PendingDocumentsViewController.m */; };
 		714A9AEF1E9CADA100371995 /* PendingDocumentsTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 714A9AEE1E9CADA100371995 /* PendingDocumentsTableViewCell.m */; };
 		714B37041E70F2BF00E99B90 /* ScannerControllerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 714B36FF1E70F2BF00E99B90 /* ScannerControllerView.m */; };
@@ -104,16 +105,15 @@
 		7128C2761E12500B00FF635B /* signature.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = signature.storyboard; path = "../../../RedAnt ERP Mobile/common/Functions/signature/signature.storyboard"; sourceTree = "<group>"; };
 		7128C2801E12501B00FF635B /* TouchImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TouchImageView.h; path = "../../../RedAnt ERP Mobile/common/customUI/TouchImageView.h"; sourceTree = "<group>"; };
 		7128C2811E12501B00FF635B /* TouchImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TouchImageView.m; path = "../../../RedAnt ERP Mobile/common/customUI/TouchImageView.m"; sourceTree = "<group>"; };
-		7128C2961E12504300FF635B /* PDFViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFViewController.h; path = "../../../RedAnt ERP Mobile/common/Functions/PDF+Web/PDFViewController.h"; sourceTree = "<group>"; };
-		7128C2971E12504300FF635B /* PDFViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PDFViewController.m; path = "../../../RedAnt ERP Mobile/common/Functions/PDF+Web/PDFViewController.m"; sourceTree = "<group>"; };
+		7128C2961E12504300FF635B /* RAPDFViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RAPDFViewController.h; path = "../../../RedAnt ERP Mobile/common/Functions/PDF+Web/RAPDFViewController.h"; sourceTree = "<group>"; };
+		7128C2971E12504300FF635B /* RAPDFViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RAPDFViewController.m; path = "../../../RedAnt ERP Mobile/common/Functions/PDF+Web/RAPDFViewController.m"; sourceTree = "<group>"; };
 		7128C29B1E1250CA00FF635B /* TableDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TableDrawable.h; path = "../../../RedAnt ERP Mobile/common/pdfCreator/TableDrawable.h"; sourceTree = "<group>"; };
 		7128C29C1E1250CA00FF635B /* TableDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TableDrawable.m; path = "../../../RedAnt ERP Mobile/common/pdfCreator/TableDrawable.m"; sourceTree = "<group>"; };
 		7128C29D1E1250CA00FF635B /* TextDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextDrawable.h; path = "../../../RedAnt ERP Mobile/common/pdfCreator/TextDrawable.h"; sourceTree = "<group>"; };
 		7128C29E1E1250CA00FF635B /* TextDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextDrawable.m; path = "../../../RedAnt ERP Mobile/common/pdfCreator/TextDrawable.m"; sourceTree = "<group>"; };
 		7128C29F1E1250CA00FF635B /* PDFDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFDrawable.h; path = "../../../RedAnt ERP Mobile/common/pdfCreator/PDFDrawable.h"; sourceTree = "<group>"; };
 		7128C2A01E1250CA00FF635B /* PDFDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PDFDrawable.m; path = "../../../RedAnt ERP Mobile/common/pdfCreator/PDFDrawable.m"; sourceTree = "<group>"; };
-		7128C2A11E1250CA00FF635B /* PDFPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPage.h; path = "../../../RedAnt ERP Mobile/common/pdfCreator/PDFPage.h"; sourceTree = "<group>"; };
-		7128C2A21E1250CA00FF635B /* PDFPage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PDFPage.m; path = "../../../RedAnt ERP Mobile/common/pdfCreator/PDFPage.m"; sourceTree = "<group>"; };
+		7128C2A11E1250CA00FF635B /* RAPDFPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RAPDFPage.h; path = "../../../RedAnt ERP Mobile/common/pdfCreator/RAPDFPage.h"; sourceTree = "<group>"; };
 		7128C2A31E1250CA00FF635B /* BasicDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BasicDrawable.h; path = "../../../RedAnt ERP Mobile/common/pdfCreator/BasicDrawable.h"; sourceTree = "<group>"; };
 		7128C2A41E1250CA00FF635B /* BasicDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BasicDrawable.m; path = "../../../RedAnt ERP Mobile/common/pdfCreator/BasicDrawable.m"; sourceTree = "<group>"; };
 		7128C2A51E1250CA00FF635B /* GridDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GridDrawable.h; path = "../../../RedAnt ERP Mobile/common/pdfCreator/GridDrawable.h"; sourceTree = "<group>"; };
@@ -173,14 +173,17 @@
 		7128C3431E12545C00FF635B /* CheckSelectorViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CheckSelectorViewController.m; path = ../../common/CheckSelectorViewController.m; sourceTree = "<group>"; };
 		7128C3441E12545C00FF635B /* DocumentPageViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DocumentPageViewController.h; path = ../../common/DocumentPageViewController.h; sourceTree = "<group>"; };
 		7128C3451E12545C00FF635B /* DocumentPageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DocumentPageViewController.m; path = ../../common/DocumentPageViewController.m; sourceTree = "<group>"; };
-		7128C34A1E12548C00FF635B /* PDFPageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPageView.h; path = ../../common/PDFPageView.h; sourceTree = "<group>"; };
-		7128C34B1E12548C00FF635B /* PDFPageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PDFPageView.m; path = ../../common/PDFPageView.m; sourceTree = "<group>"; };
-		7128C34C1E12548C00FF635B /* PDFScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFScrollView.h; path = ../../common/PDFScrollView.h; sourceTree = "<group>"; };
-		7128C34D1E12548C00FF635B /* PDFScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PDFScrollView.m; path = ../../common/PDFScrollView.m; sourceTree = "<group>"; };
+		7128C34A1E12548C00FF635B /* RAPDFPageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RAPDFPageView.h; path = ../../common/RAPDFPageView.h; sourceTree = "<group>"; };
+		7128C34B1E12548C00FF635B /* RAPDFPageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RAPDFPageView.m; path = ../../common/RAPDFPageView.m; sourceTree = "<group>"; };
+		7128C34C1E12548C00FF635B /* RAPDFScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RAPDFScrollView.h; path = ../../common/RAPDFScrollView.h; sourceTree = "<group>"; };
+		7128C34D1E12548C00FF635B /* RAPDFScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RAPDFScrollView.m; path = ../../common/RAPDFScrollView.m; sourceTree = "<group>"; };
 		7128C34E1E12548C00FF635B /* SignatureListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SignatureListViewController.h; path = ../../common/SignatureListViewController.h; sourceTree = "<group>"; };
 		7128C34F1E12548C00FF635B /* SignatureListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SignatureListViewController.m; path = ../../common/SignatureListViewController.m; sourceTree = "<group>"; };
 		7128C3501E12548C00FF635B /* SignatureTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SignatureTableViewCell.h; path = ../../common/SignatureTableViewCell.h; sourceTree = "<group>"; };
 		7128C3511E12548C00FF635B /* SignatureTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SignatureTableViewCell.m; path = ../../common/SignatureTableViewCell.m; sourceTree = "<group>"; };
+		713B97AF1F79E0CA002B86BF /* dbgPageVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = dbgPageVC.h; sourceTree = "<group>"; };
+		713B97B01F79E0CA002B86BF /* dbgPageVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = dbgPageVC.m; sourceTree = "<group>"; };
+		713B97B21F79E649002B86BF /* RAPDFPage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = RAPDFPage.m; path = "../../../RedAnt ERP Mobile/common/pdfCreator/RAPDFPage.m"; sourceTree = "<group>"; };
 		714A9AEA1E9CA91F00371995 /* PendingDocumentsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PendingDocumentsViewController.h; path = ../../common/PendingDocumentsViewController.h; sourceTree = "<group>"; };
 		714A9AEB1E9CA92000371995 /* PendingDocumentsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PendingDocumentsViewController.m; path = ../../common/PendingDocumentsViewController.m; sourceTree = "<group>"; };
 		714A9AED1E9CADA100371995 /* PendingDocumentsTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PendingDocumentsTableViewCell.h; path = ../../common/PendingDocumentsTableViewCell.h; sourceTree = "<group>"; };
@@ -265,6 +268,8 @@
 				7128C29A1E12506200FF635B /* pdfedit */,
 				7128C2711E124FFE00FF635B /* signature */,
 				7128C2671E124FF200FF635B /* Main.storyboard */,
+				713B97AF1F79E0CA002B86BF /* dbgPageVC.h */,
+				713B97B01F79E0CA002B86BF /* dbgPageVC.m */,
 				7128C2691E124FF200FF635B /* LaunchScreen.storyboard */,
 				7128C24F1E124F4500FF635B /* Info.plist */,
 				71F8D0321EC057A2002003DB /* RANetworkTaskDelegate.h */,
@@ -328,8 +333,8 @@
 		7128C2951E12503000FF635B /* preview */ = {
 			isa = PBXGroup;
 			children = (
-				7128C2961E12504300FF635B /* PDFViewController.h */,
-				7128C2971E12504300FF635B /* PDFViewController.m */,
+				7128C2961E12504300FF635B /* RAPDFViewController.h */,
+				7128C2971E12504300FF635B /* RAPDFViewController.m */,
 			);
 			name = preview;
 			sourceTree = "<group>";
@@ -343,8 +348,8 @@
 				7128C29E1E1250CA00FF635B /* TextDrawable.m */,
 				7128C29F1E1250CA00FF635B /* PDFDrawable.h */,
 				7128C2A01E1250CA00FF635B /* PDFDrawable.m */,
-				7128C2A11E1250CA00FF635B /* PDFPage.h */,
-				7128C2A21E1250CA00FF635B /* PDFPage.m */,
+				7128C2A11E1250CA00FF635B /* RAPDFPage.h */,
+				713B97B21F79E649002B86BF /* RAPDFPage.m */,
 				7128C2A31E1250CA00FF635B /* BasicDrawable.h */,
 				7128C2A41E1250CA00FF635B /* BasicDrawable.m */,
 				7128C2A51E1250CA00FF635B /* GridDrawable.h */,
@@ -376,10 +381,10 @@
 				7108773B1F79DACE00C18B95 /* PageViewController.m */,
 				71CDA0911F75EEBF0079F8E6 /* TemplateViewController.h */,
 				71CDA0921F75EEBF0079F8E6 /* TemplateViewController.m */,
-				7128C34A1E12548C00FF635B /* PDFPageView.h */,
-				7128C34B1E12548C00FF635B /* PDFPageView.m */,
-				7128C34C1E12548C00FF635B /* PDFScrollView.h */,
-				7128C34D1E12548C00FF635B /* PDFScrollView.m */,
+				7128C34A1E12548C00FF635B /* RAPDFPageView.h */,
+				7128C34B1E12548C00FF635B /* RAPDFPageView.m */,
+				7128C34C1E12548C00FF635B /* RAPDFScrollView.h */,
+				7128C34D1E12548C00FF635B /* RAPDFScrollView.m */,
 			);
 			name = pdfedit;
 			sourceTree = "<group>";
@@ -559,7 +564,7 @@
 				7115D42A1E14DE0A00EF4E4C /* DocListTableViewCell.m in Sources */,
 				7128C2B11E1250CA00FF635B /* PDFDrawable.m in Sources */,
 				7128C2E71E12511B00FF635B /* AESCrypt.m in Sources */,
-				7128C2B21E1250CA00FF635B /* PDFPage.m in Sources */,
+				713B97B31F79E649002B86BF /* RAPDFPage.m in Sources */,
 				71F8D0341EC057A2002003DB /* RANetworkTaskDelegate.m in Sources */,
 				7115D4271E13B70C00EF4E4C /* DocumentListViewController.m in Sources */,
 				7128C33A1E12540F00FF635B /* ACNetwork.m in Sources */,
@@ -572,8 +577,9 @@
 				7128C2B31E1250CA00FF635B /* BasicDrawable.m in Sources */,
 				7128C2C71E1250FC00FF635B /* PDFUtils.m in Sources */,
 				717243441E1CCCEC00800678 /* CustomIOSAlertView.m in Sources */,
-				7128C3541E12548C00FF635B /* PDFScrollView.m in Sources */,
+				7128C3541E12548C00FF635B /* RAPDFScrollView.m in Sources */,
 				7128C3411E12542000FF635B /* LoginViewController.m in Sources */,
+				713B97B11F79E0CB002B86BF /* dbgPageVC.m in Sources */,
 				7128C3461E12545C00FF635B /* CheckSelectorViewController.m in Sources */,
 				7128C2B81E1250CA00FF635B /* LineDrawable.m in Sources */,
 				7128C2DB1E12510900FF635B /* zip.c in Sources */,
@@ -590,7 +596,7 @@
 				7115D4561E1606F700EF4E4C /* GEContractFilterViewController.m in Sources */,
 				7128C2DA1E12510900FF635B /* unzip.c in Sources */,
 				71CDA0901F75EE400079F8E6 /* DocumentTemplateViewController.m in Sources */,
-				7128C2981E12504300FF635B /* PDFViewController.m in Sources */,
+				7128C2981E12504300FF635B /* RAPDFViewController.m in Sources */,
 				7128C2CB1E1250FC00FF635B /* RAUtils.m in Sources */,
 				7128C2C81E1250FC00FF635B /* TextUtils.m in Sources */,
 				7128C33B1E12540F00FF635B /* AppDelegate.m in Sources */,
@@ -604,7 +610,7 @@
 				7128C2EA1E12511B00FF635B /* NSData+CommonCrypto.m in Sources */,
 				7128C2B01E1250CA00FF635B /* TextDrawable.m in Sources */,
 				71BBFC371E6419D4008668A7 /* ExtDocumentsViewController.m in Sources */,
-				7128C3531E12548C00FF635B /* PDFPageView.m in Sources */,
+				7128C3531E12548C00FF635B /* RAPDFPageView.m in Sources */,
 				7128C33E1E12541800FF635B /* RootViewController.m in Sources */,
 				7128C2E91E12511B00FF635B /* NSData+Base64.m in Sources */,
 				714B37051E70F2BF00E99B90 /* ScannerViewController.m in Sources */,

+ 4 - 4
Ants Contract/Granite Expo eSign/Granite Expo eSign/DocumentTemplateViewController.m

@@ -18,14 +18,14 @@
 #import "AppDelegate.h"
 #import "ACNetwork.h"
 #import "RAUtils.h"
-#import "PDFViewController.h"
+//#import "RAPDFViewController.h"
 #import "config.h"
 #import "AESCrypt.h"
 #import "CustomIOSAlertView.h"
 
 #import "ImageUtils.h"
 
-#import "PDFPage.h"
+#import "RAPDFPage.h"
 
 #import "TextDrawable.h"
 #import "ImageDrawable.h"
@@ -494,7 +494,7 @@
     // save contro json
 
     NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
-    path = [path stringByAppendingPathComponent:@"template"];
+    path = [path stringByAppendingPathComponent:@"template.json"];
     
     [self.controlTemplate writeToFile:path atomically:NO];
     
@@ -929,7 +929,7 @@
 
 - (TemplateViewController *)viewControllerAtIndex:(NSUInteger)index
 {
-    //Return the PDFViewController for the given index.
+    //Return the RAPDFViewController for the given index.
     if ((self.total_page == 0 )|| (index > self.total_page) ) {
         return nil;
     }

+ 4 - 4
Ants Contract/Granite Expo eSign/Granite Expo eSign/TemplateViewController.h

@@ -7,8 +7,8 @@
 //
 
 #import <UIKit/UIKit.h>
-#import "PDFPageView.h"
-#import "PDFScrollView.h"
+#import "RAPDFPageView.h"
+#import "RAPDFScrollView.h"
 //#import "EditControlView.h"
 #import "TouchImageView.h"
 
@@ -23,11 +23,11 @@
 
 @interface TemplateViewController : UIViewController<UITextViewDelegate,TouchImageViewDelegate>
 
-@property (strong, nonatomic) IBOutlet PDFPageView *pdfPageView;
+@property (strong, nonatomic) IBOutlet RAPDFPageView *pdfPageView;
 @property (strong, nonatomic) IBOutlet UIView *editControlView;
 @property size_t pageIndex;
 @property CGPDFPageRef pageRef;
-@property (strong, nonatomic) IBOutlet PDFScrollView *pdfScrollView;
+@property (strong, nonatomic) IBOutlet RAPDFScrollView *pdfScrollView;
 @property (nonatomic , copy) void (^blk_Fill)(NSString* file,NSString* subtype, bool fillFullDoc);
 
 

+ 1 - 1
Ants Contract/Granite Expo eSign/Granite Expo eSign/TemplateViewController.m

@@ -712,7 +712,7 @@ typedef enum {
     if(DEBUG_PDFSIG)
     {
         btn.backgroundColor = [UIColor lightGrayColor];
-        
+        btn.alpha = 0.5;
         [btn setTitle:template[@"title"] forState:UIControlStateNormal];
         //        marker_bg = [UIColor redColor];
         

+ 13 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/dbgPageVC.h

@@ -0,0 +1,13 @@
+//
+//  dbgPageVC.h
+//  Granite Expo eSign
+//
+//  Created by Ray on 26/09/2017.
+//  Copyright © 2017 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface dbgPageVC : UIViewController
+
+@end

+ 37 - 0
Ants Contract/Granite Expo eSign/Granite Expo eSign/dbgPageVC.m

@@ -0,0 +1,37 @@
+//
+//  dbgPageVC.m
+//  Granite Expo eSign
+//
+//  Created by Ray on 26/09/2017.
+//  Copyright © 2017 United Software Applications, Inc. All rights reserved.
+//
+
+#import "dbgPageVC.h"
+
+@interface dbgPageVC ()
+
+@end
+
+@implementation dbgPageVC
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+/*
+#pragma mark - Navigation
+
+// In a storyboard-based application, you will often want to do a little preparation before navigation
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+    // Get the new view controller using [segue destinationViewController].
+    // Pass the selected object to the new view controller.
+}
+*/
+
+@end

+ 2 - 2
Ants Contract/common/AddExtDocumentViewController.m

@@ -15,7 +15,7 @@
 
 #import "ACNetwork.h"
 
-#import "PDFViewController.h"
+#import "RAPDFViewController.h"
 #import "ScannerViewController.h"
 
 
@@ -398,7 +398,7 @@
     
     
     
-    PDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
+    RAPDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
     ViewController.url = url;
     ViewController.canSave = false;
     ViewController.isLocalfile=isLocalFile;

+ 2 - 2
Ants Contract/common/DocumentListViewController.m

@@ -11,7 +11,7 @@
 #import "DocListTableViewCell.h"
 #import "RAUtils.h"
 #import "GEContractFilterViewController.h"
-#import "PDFViewController.h"
+#import "RAPDFViewController.h"
 #import "AppDelegate.h"
 #import "ExtDocumentsViewController.h"
 #import "DocnotesViewController.h"
@@ -177,7 +177,7 @@
     
     bool isLocalFile= islocalfile;//[self.content_data[indexPath.row] valueForKey:@"isLocalFile"];
     
-    PDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
+    RAPDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
     ViewController.url = url;
     ViewController.canSave = false;
     ViewController.isLocalfile=isLocalFile;

+ 8 - 3
Ants Contract/common/DocumentPageViewController.m

@@ -13,18 +13,20 @@
 #import "PDFUtils.h"
 #import "ACNetwork.h"
 
+#import "dbgPageVC.h"
+
 //#import "AFHTTPSessionManager.h"
 #import "AppDelegate.h"
 #import "ACNetwork.h"
 #import "RAUtils.h"
-#import "PDFViewController.h"
+//#import "PDFViewController.h"
 #import "config.h"
 #import "AESCrypt.h"
 #import "CustomIOSAlertView.h"
 
 #import "ImageUtils.h"
 
-#import "PDFPage.h"
+//#import "RAPDFPage.h"
 
 #import "TextDrawable.h"
 #import "ImageDrawable.h"
@@ -211,6 +213,9 @@
     
     
 
+//    dbgPageVC* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"dbgPageVC"];
+    
+    
     [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
     
     self.pageViewController.dataSource = self;
@@ -905,7 +910,7 @@
 
 - (PageViewController *)viewControllerAtIndex:(NSUInteger)index
 {
-    //Return the PDFViewController for the given index.
+    //Return the RAPDFViewController for the given index.
     if ((self.total_page == 0 )|| (index > self.total_page) ) {
         return nil;
     }

+ 2 - 2
Ants Contract/common/ExtDocumentsViewController.m

@@ -7,7 +7,7 @@
 //
 
 #import "ExtDocumentsViewController.h"
-#import "PDFViewController.h"
+#import "RAPDFViewController.h"
 #import "AddExtDocumentViewController.h"
 
 
@@ -549,7 +549,7 @@
     
     
     
-    PDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
+    RAPDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
     ViewController.url = url;
     ViewController.canSave = false;
     ViewController.isLocalfile=isLocalFile;

+ 4 - 4
Ants Contract/common/PageViewController.h

@@ -7,18 +7,18 @@
 //
 
 #import <UIKit/UIKit.h>
-#import "PDFPageView.h"
-#import "PDFScrollView.h"
+#import "RAPDFPageView.h"
+#import "RAPDFScrollView.h"
 //#import "EditControlView.h"
 #import "TouchImageView.h"
 
 @interface PageViewController : UIViewController<UITextViewDelegate,TouchImageViewDelegate>
 
-@property (strong, nonatomic) IBOutlet PDFPageView *pdfPageView;
+@property (strong, nonatomic) IBOutlet RAPDFPageView *pdfPageView;
 @property (strong, nonatomic) IBOutlet UIView *editControlView;
 @property size_t pageIndex;
 @property CGPDFPageRef pageRef;
-@property (strong, nonatomic) IBOutlet PDFScrollView *pdfScrollView;
+@property (strong, nonatomic) IBOutlet RAPDFScrollView *pdfScrollView;
 @property (nonatomic , copy) void (^blk_Fill)(NSString* file,NSString* subtype, bool fillFullDoc);
 
 

+ 1 - 0
Ants Contract/common/PageViewController.m

@@ -703,6 +703,7 @@ typedef enum {
     if(DEBUG_PDFSIG)
     {
         btn.backgroundColor = [UIColor lightGrayColor];
+        btn.alpha=0.5;
 
         [btn setTitle:template[@"title"] forState:UIControlStateNormal];
 //        marker_bg = [UIColor redColor];

+ 2 - 2
Ants Contract/common/PendingDocumentsViewController.m

@@ -11,7 +11,7 @@
 #import "PendingDocumentsTableViewCell.h"
 #import "RAUtils.h"
 #import "GEContractFilterViewController.h"
-#import "PDFViewController.h"
+#import "RAPDFViewController.h"
 #import "AppDelegate.h"
 #import "ExtDocumentsViewController.h"
 #import "DocnotesViewController.h"
@@ -159,7 +159,7 @@
     
     bool isLocalFile= false;//[self.content_data[indexPath.row] valueForKey:@"isLocalFile"];
     
-    PDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
+    RAPDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
     ViewController.url = url;
     ViewController.canSave = false;
     ViewController.isLocalfile=isLocalFile;

+ 14 - 0
Ants Contract/common/RAPDFPageView.h

@@ -0,0 +1,14 @@
+//
+//  RAPDFPageView.h
+//  AntsContract
+//
+//  Created by Ray on 12/16/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface RAPDFPageView : UIView
+@property size_t pageIndex;
+@property CGPDFPageRef pageRef;
+@end

+ 136 - 0
Ants Contract/common/RAPDFPageView.m

@@ -0,0 +1,136 @@
+//
+//  RAPDFPageView.m
+//  AntsContract
+//
+//  Created by Ray on 12/16/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "RAPDFPageView.h"
+
+@implementation RAPDFPageView
+
+
+// Only override drawRect: if you perform custom drawing.
+// An empty implementation adversely affects performance during animation.
+- (void)drawRect:(CGRect)rect {
+    // Drawing code
+    
+            //CGPDFDocumentRef document = [self OpenPDF:@"GEIC - Home Improvement Contract 2016.pdf"];
+    
+    
+    
+
+
+    
+        CGContextRef context = UIGraphicsGetCurrentContext();
+    
+    [self MyDisplayPDFPage:context index:self.pageIndex ];//file:@"GEIC - Home Improvement Contract 2016.pdf"];
+}
+
+
+
+-(void) MyDisplayPDFPage:(CGContextRef) myContext index:(size_t)pageNumber //file:(NSString*) filename//(,  , const char *filename)
+{
+    
+//    double vwidth=self.frame.size.width;
+//    double vheight = self.frame.size.height;
+    
+    
+    {
+    CGPDFPageRef page = self.pageRef;
+
+    CGContextSaveGState (myContext);
+    
+//                CGRect mediabox= CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
+        
+//                CGContextTranslateCTM(myContext, 0, mediabox.size.height);
+//                CGContextScaleCTM(myContext, 1, -1);
+
+     //   CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFMediaBox, self.frame, 0, true);
+
+        
+        CGRect mediabox= CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
+        double scalex = self.frame.size.width/mediabox.size.width;
+        double scaley = self.frame.size.height/mediabox.size.height;
+        
+        double scale = scalex<scaley?scalex:scaley;
+        
+        CGAffineTransform translate_transform = CGAffineTransformMakeTranslation ( (self.frame.size.width-mediabox.size.width*scale)/2, 0 );
+        
+        CGAffineTransform scale_transform=CGAffineTransformScale ( translate_transform, scale, scale );
+        
+        CGContextConcatCTM(myContext, scale_transform);
+        
+
+        CGContextScaleCTM(myContext, 1, -1);
+        CGContextTranslateCTM(myContext, 0, -self.frame.size.height/scale_transform.a);
+        
+
+    CGContextDrawPDFPage (myContext, page);
+    CGContextRestoreGState (myContext);
+    }
+    
+    
+    
+    
+    
+//    CGPDFPageRef page = self.pageRef;
+//
+//    CGContextSaveGState (myContext);
+//    
+//    CGRect mediabox= CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
+//    
+//    CGContextTranslateCTM(myContext, 0, mediabox.size.height);
+//    // Reverse the Y axis to grow from bottom to top.
+//    CGContextScaleCTM(myContext, 1, -1);
+//    
+//    CGContextDrawPDFPage (myContext, page);
+//    CGContextRestoreGState (myContext);
+//    return ;
+    
+//    {
+//        
+//        // CGPDFDocumentRef document;
+//        CGPDFPageRef page = self.pageRef;
+//
+//        CGContextSaveGState (myContext);
+//        
+//        
+//        CGRect mediabox= CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
+//        
+//        CGContextTranslateCTM(myContext, 0, mediabox.size.height);
+//        CGContextScaleCTM(myContext, 1, -1);
+//        
+//        CGContextDrawPDFPage (myContext, page);
+//        CGContextRestoreGState (myContext);
+//    }
+    
+    
+    
+    
+    
+ /*
+   // CGPDFDocumentRef document;
+    CGPDFPageRef page = self.pageRef;
+ //   document = [self OpenPDF:filename];                                   // 1 创建PDFDocument对象
+  //  page = CGPDFDocumentGetPage (document, pageNumber);           // 2 获取指定页的PDF文档
+    
+    
+//    CGAffineTransform m;
+//    m = CGPDFPageGetDrawingTransform (page, kCGPDFMediaBox, self.bounds, -180, true);
+    CGContextSaveGState (myContext);
+    
+    CGContextTranslateCTM(myContext, 80, self.frame.size.height);
+    CGContextScaleCTM(myContext, 1, -1);
+    
+ //   CGContextConcatCTM (myContext, m);
+  //  CGContextClipToRect (myContext,CGPDFPageGetBoxRect (page, kCGPDFCropBox));
+    CGContextDrawPDFPage (myContext, page);
+    CGContextRestoreGState (myContext);
+    */
+    
+  //  CGContextDrawPDFPage (myContext, page);                                       // 3 将PDF绘制到图形上下文中
+//    CGPDFDocumentRelease (document);
+}
+@end

+ 13 - 0
Ants Contract/common/RAPDFScrollView.h

@@ -0,0 +1,13 @@
+//
+//  RAPDFScrollView.h
+//  AntsContract
+//
+//  Created by Ray on 12/19/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface RAPDFScrollView : UIScrollView
+
+@end

+ 21 - 0
Ants Contract/common/RAPDFScrollView.m

@@ -0,0 +1,21 @@
+//
+//  RAPDFScrollView.m
+//  AntsContract
+//
+//  Created by Ray on 12/19/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "RAPDFScrollView.h"
+
+@implementation RAPDFScrollView
+
+/*
+// Only override drawRect: if you perform custom drawing.
+// An empty implementation adversely affects performance during animation.
+- (void)drawRect:(CGRect)rect {
+    // Drawing code
+}
+*/
+
+@end

+ 2 - 2
Ants Contract/common/RootViewController.m

@@ -12,7 +12,7 @@
 
 #import "AppDelegate.h"
 #import "RAUtils.h"
-#import "PDFViewController.h"
+#import "RAPDFViewController.h"
 #import "DocumentListViewController.h"
 #import "PendingDocumentsViewController.h"
 
@@ -636,7 +636,7 @@
     
     bool isLocalFile= true;//[self.content_data[indexPath.row] valueForKey:@"isLocalFile"];
     
-    PDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
+    RAPDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
     ViewController.url = url;
     ViewController.canSave = false;
     ViewController.isLocalfile=isLocalFile;

+ 45 - 0
RedAnt ERP Mobile/common/Functions/PDF+Web/RAPDFViewController.h

@@ -0,0 +1,45 @@
+//
+//  RAPDFViewController.h
+//  RedAnt ERP Mobile
+//
+//  Created by Ray on 14-8-7.
+//  Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <MessageUI/MessageUI.h>
+@interface RAPDFViewController : UIViewController<UIDocumentInteractionControllerDelegate,MFMailComposeViewControllerDelegate,UIPrintInteractionControllerDelegate>
+@property (strong, nonatomic) IBOutlet UIWebView *webView;
+@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *mum;
+@property (strong,nonatomic) NSString* url; //pdf 路径,可以是网络路径或文件路径
+@property (strong,nonatomic) NSString* filename; // 保存为文件时指定的名称
+@property (strong,nonatomic) NSData* content;
+@property bool isLocalfile;
+@property (strong, nonatomic) IBOutlet UIBarButtonItem *BB_action;
+@property (strong,nonatomic) UIDocumentInteractionController* fileInteractionController;
+@property (nonatomic , copy) void (^onLoadSuccess)(NSString* url );
+@property (nonatomic,copy) NSString *cachePath; //指定的保存路径
+
+@property (nonatomic , copy) void (^onSavePDF)(NSString* name,NSString* file );
+@property (strong,nonatomic) NSString* mail_subject;
+@property (strong,nonatomic) NSString* mail_content;
+@property (strong,nonatomic) NSArray* mail_to;
+@property (strong,nonatomic) NSString* save_name; // save 按钮默认保存名
+@property (strong,nonatomic) NSString* save_note;
+
+@property (strong, nonatomic)  UIBarButtonItem *btnshare;
+@property (strong, nonatomic)  UIBarButtonItem *btnPrint;
+@property (strong, nonatomic)  UIBarButtonItem *btnemail;
+@property (strong, nonatomic)  UIBarButtonItem *btnsave;
+
+
+@property bool autoPrint;
+@property bool hidenavi;
+
+@property bool canSave;
+
+@property bool defaultStyle;
+
+
+@property (strong,nonatomic) NSString* attachment_name; //email 按钮附件名称(已废弃)
+@end

+ 942 - 0
RedAnt ERP Mobile/common/Functions/PDF+Web/RAPDFViewController.m

@@ -0,0 +1,942 @@
+//
+//  RAPDFViewController.m
+//  RedAnt ERP Mobile
+//
+//  Created by Ray on 14-8-7.
+//  Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "RAPDFViewController.h"
+#import "RAUtils.h"
+#import "const.h"
+#import "AppDelegate.h"
+#import "PDFUtils.h"
+#import "TextUtils.h"
+
+
+@interface RAPDFViewController ()
+
+@end
+
+@implementation RAPDFViewController
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+    if (self) {
+        // Custom initialization
+    }
+    return self;
+}
+
+- (void)setFilename:(NSString *)filename {
+    _filename = [TextUtils legalFilename:filename];
+}
+
+- (void)viewDidLoad
+{
+    
+    NSLog(@"pdf viewer loaded");
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    UIRefreshControl *ref = [[UIRefreshControl alloc]init];
+    ref.tag = 200 ;
+    ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"drag to refresh"];
+    ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
+    //    ref.hidden = true;
+    [ref addTarget:self action:@selector(changeCell) forControlEvents:UIControlEventValueChanged];
+    [self.webView.scrollView addSubview:ref];
+    
+    
+    self.webView.dataDetectorTypes=UIDataDetectorTypeAll;
+    
+    
+  
+    
+
+   // self.btnsave.tintColor = UIColorFromRGB(0x996633);
+    
+    if(self.defaultStyle)
+    {
+
+        self.btnshare =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
+                                                                     target:self
+                                                                     action:@selector( onActionClick:)];
+
+        
+        
+        self.btnPrint =[[UIBarButtonItem alloc] initWithTitle:@"Print"
+                                                                    style:UIBarButtonItemStylePlain
+                                                                    target:self
+                                                                    action:@selector( onPrintClick:)];
+        
+        NSMutableArray * items = [[NSMutableArray alloc]init];
+        [items addObject:self.btnshare];
+        [items addObject:self.btnPrint];
+
+        self.navigationItem.rightBarButtonItems =items;
+        
+        
+       if (self.navigationController.viewControllers[0]==self )
+       {
+           UIBarButtonItem *closeButton =nil;
+           
+           
+           
+           closeButton=[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                        style:UIBarButtonItemStylePlain
+                                                       target:self
+                                                       action:@selector( onCloseClick:)];
+           //[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCloseClick:)];
+           //    closeButton.title = @"Close";
+           
+           self.navigationItem.leftBarButtonItem = closeButton;
+       }
+
+        
+    }
+    else
+    {
+        UIBarButtonItem *closeButton =nil;
+        
+        
+        
+        closeButton=[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                     style:UIBarButtonItemStylePlain
+                                                    target:self
+                                                    action:@selector( onBackClick:)];
+        //[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCloseClick:)];
+        //    closeButton.title = @"Close";
+        
+        self.navigationItem.leftBarButtonItem = closeButton;
+        
+        
+        
+        
+        self.btnshare = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"share"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                         style:UIBarButtonItemStylePlain
+                                                        target:self
+                                                        action:@selector(onActionClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onOpenOrderClick:)];
+        
+        // self.btnshare.tintColor = UIColorFromRGB(0x996633);
+        
+        self.btnemail =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"mail"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                        style:UIBarButtonItemStylePlain
+                                                       target:self
+                                                       action:@selector(onEmailClick:)];// [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Commit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCommitOrderClick:)];
+        
+        //  self.btnemail.tintColor = UIColorFromRGB(0x996633);
+        
+        // self.btnSend = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Email", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onSendMailClick:)];
+        
+        
+        
+        self.btnsave = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"save"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                        style:UIBarButtonItemStylePlain
+                                                       target:self
+                                                       action:@selector(onSaveClick:)];        
+        UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
+        fixedItem.width = 20.0f;
+        NSMutableArray * items = [[NSMutableArray alloc]init];
+        [items addObject:self.btnshare];
+        [items addObject:fixedItem];
+        [items addObject:self.btnemail];
+        
+        if(self.canSave)
+        {
+            [items addObject:fixedItem];
+            [items addObject:self.btnsave];
+        }
+        self.navigationItem.rightBarButtonItems=items;
+        
+        self.btnshare.enabled =false;
+        
+        
+        self.btnemail.enabled =false;
+        self.btnsave.enabled =false;
+        
+    }
+
+    
+//   self.url=@"http://192.168.1.3:8080/npd/test.pdf";
+//    NSURL* url = [NSURL URLWithString:self.url];
+//    
+//    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:self.url]        cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:2000];
+//    
+//    
+//    [self.webView loadRequest:request];
+    
+    
+    [self loadcontent];
+}
+- (void)onBackClick:(UIButton *)sender {
+    
+    
+    [self.navigationController popViewControllerAnimated:FALSE];
+}
+- (void)onCloseClick:(UIButton *)sender {
+    
+    [self dismissViewControllerAnimated:false completion:nil];
+    //[self.navigationController popViewControllerAnimated:FALSE];
+}
+-(void)ReloadData
+{
+    
+    //    Count ++ ;
+    //    [mytabelview reloadData];
+    UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
+    
+    [reF endRefreshing];
+    [self loadcontent];
+
+    
+}
+
+- (void)copyTmpLocalFile:(NSString *)localPath {
+    
+    NSString *path = NSTemporaryDirectory();
+    NSString *filePath = [path stringByAppendingPathComponent:self.filename];
+    NSFileManager *fileManager = [NSFileManager defaultManager];
+    if ([fileManager fileExistsAtPath:filePath]) { // 文件存在就不会拷贝
+        [fileManager removeItemAtPath:filePath error:nil];
+    }
+    [fileManager copyItemAtPath:localPath toPath:filePath error:nil];
+    self.url = filePath;
+}
+
+-(void) loadcontent
+{
+    
+    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Loading..."];
+    self.mum.hidden=false;
+    
+    if(self.isLocalfile)
+    {
+        /*
+        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+        NSString *cachefolder = [paths objectAtIndex:0];
+        NSString *pdfFolder = [cachefolder stringByAppendingPathComponent:@"pdf_cache"];
+        self.url = [pdfFolder stringByAppendingPathComponent:self.url];
+        */
+        
+        self.content= [NSData dataWithContentsOfFile:self.url];
+        
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+        
+        if (self.filename.length <= 0) {
+            self.filename=[self.url lastPathComponent];
+        } else {
+            [self copyTmpLocalFile:self.url];
+        }
+        
+        self.btnshare.enabled =true;
+        
+        
+        self.btnemail.enabled =true;
+        self.btnsave.enabled =true;
+        
+//        if(self.onLoadSuccess)
+//        self.onLoadSuccess(self.url);
+//        
+//        if(self.autoPrint)
+//        [self startAirPrintWithData:self.content];
+        
+//        NSLog(@"put file to webview");
+//        [self.webView loadData:self.content MIMEType:@"application/pdf" textEncodingName:nil baseURL:nil];
+        
+        NSURL *url = [NSURL fileURLWithPath:self.url];
+        NSURLRequest *request = [NSURLRequest requestWithURL:url];
+        [self.webView loadRequest:request];
+        
+    }
+    else
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        
+        
+        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:self.url]        cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60*5];
+        
+        //设置请求方式为get
+        
+        [request setHTTPMethod:@"GET"];
+        
+        //添加用户会话id
+        
+        [request addValue:@"text/html" forHTTPHeaderField:@"Content-Type"];
+        
+        //连接发送请求
+        
+        
+        NSHTTPURLResponse* urlResponse = nil;
+        
+        NSError *error = nil;
+        
+        self.content= [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
+        
+        if(self.filename.length<=0)
+            self.filename = [urlResponse suggestedFilename];
+        
+        
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+            
+            [[self navigationController] setNavigationBarHidden:self.hidenavi animated:NO];
+            self.navigationItem.title = self.save_name;
+            UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
+          //  self.content=nil;
+            if(self.content!=nil&&self.content.length>0)
+            {
+                [reF removeFromSuperview];
+                
+                
+               // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+                NSString *path = NSTemporaryDirectory();
+                NSString *filePath = [path stringByAppendingPathComponent:self.filename];
+                //    NSError *error = nil;
+                //    BOOL bo = [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
+                //    NSAssert(bo,@"创建目录失败");
+                if (self.cachePath.length) {
+                    filePath = self.cachePath;
+                }
+                
+                [self.content writeToFile:filePath atomically:YES];
+                
+                self.url = filePath;
+                self.isLocalfile = true;
+
+                
+                self.btnshare.enabled =true;
+                
+                
+                self.btnemail.enabled =true;
+                self.btnsave.enabled =true;
+                
+                
+                
+                NSURL *url = [NSURL fileURLWithPath:filePath];
+                NSURLRequest *request = [NSURLRequest requestWithURL:url];
+                [self.webView loadRequest:request];
+                
+                
+
+                
+                
+                
+ //               int a=0;
+            }
+            else
+            {
+                [RAUtils message_alert:nil  title:@"Open PDF Failed" controller:self];
+                
+                if(self.autoPrint)
+                    [self.navigationController popViewControllerAnimated:true];
+//                self.content = [self.url dataUsingEncoding:NSUTF8StringEncoding];
+            }
+            
+            ;
+//            DebugLog(@"%@",[[NSString alloc] initWithData:self.content encoding:NSASCIIStringEncoding]);
+            //
+            
+//            DebugLog(urlResponse.MIMEType);
+            
+//            [self.webView loadData:self.content MIMEType:urlResponse.MIMEType textEncodingName:nil baseURL:nil];
+            
+            
+            
+            
+        });
+    });
+    
+    
+    
+    
+}
+-(void)changeCell
+{
+    UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
+    reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"refreshing"];
+    if ([self respondsToSelector:@selector(ReloadData)])
+    [self performSelector:@selector(ReloadData) withObject:nil afterDelay:1];
+//    DebugLog(@"refresh!!!!!!!!");
+    
+}
+- (void)didReceiveMemoryWarning
+{
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+-(void) viewWillAppear:(BOOL)animated
+{
+    
+    
+    [super viewWillAppear:animated];
+  
+    [[self navigationController] setNavigationBarHidden:self.hidenavi animated:NO];
+}
+- (IBAction)onPrintClick:(id)sender {
+    
+    
+  //  UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"preparing print..."];
+    
+    UIPrintInteractionController* airPrinterController=[UIPrintInteractionController sharedPrintController];
+    UIPrintInfo *printInfo = [UIPrintInfo printInfo];
+    printInfo.outputType = UIPrintInfoOutputGeneral;
+    
+    printInfo.orientation = UIPrintInfoOrientationPortrait;
+    printInfo.jobName = @"CoolVisitAirPrint";
+    airPrinterController.printInfo = printInfo;
+    airPrinterController.printingItem = self.content;
+    airPrinterController.delegate = self;
+    
+    
+    airPrinterController.showsNumberOfCopies=true;
+    airPrinterController.showsPageRange = true;
+    airPrinterController.showsPaperSelectionForLoadedPapers=true;
+    
+    
+    [airPrinterController presentFromBarButtonItem:self.btnPrint
+                                      animated:YES
+                             completionHandler:
+     ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {
+     }
+     ];
+    
+    
+//    
+//    void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
+//        if(completed && error)
+//            DebugLog(@"Printing failed due to error in domain %@ with error code %lu. Localized description: %@, and failure reason: %@", error.domain, (long)error.code, error.localizedDescription, error.localizedFailureReason);
+//    };
+//    
+//    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//    
+//    UIPrinter *airPrinter = [UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL] ];///*self.printer;*/
+//    
+//    
+//    
+//    
+//    [[UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL]] contactPrinter:^(BOOL available)
+//     {
+//         [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//         
+//         if (available&& appDelegate.printerURL.length>0)
+//         {
+//             
+//             
+//             [airPrinterController printToPrinter:airPrinter completionHandler:completionHandler];
+//             DebugLog(@"AIRPRINTER AVAILABLE");
+//         }
+//         else
+//         {
+//             
+//                          [airPrinterController presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
+//             
+//             
+//             
+//                           //        [printPicker presentAnimated:YES completionHandler:
+//                           ^(UIPrintInteractionController *printerController, BOOL userDidSelect, NSError *error)
+//                           {
+//                               if (userDidSelect)
+//                               {
+//                                   NSString* sid= printerController.printInfo.printerID;
+//                                   UIPrintPaper*paper=  printerController.printPaper;
+//             
+//                               }
+//                           }];
+//             
+//             
+//             DebugLog(@"AIRPRINTER NOT AVAILABLE");
+//             
+//             
+//             
+////             if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
+////             {
+////                 UIPrinterPickerController *printPicker = [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:nil];
+////                 //   [printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:yes completionHandler:
+////                 
+////                 
+////                 
+////                 [ printPicker presentFromBarButtonItem:self.btnPrint animated:YES completionHandler:
+////                  
+////                  
+////                  // [printPicker presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
+////                  
+////                  
+////                  
+////                  //        [printPicker presentAnimated:YES completionHandler:
+////                  ^(UIPrinterPickerController *printerPicker, BOOL userDidSelect, NSError *error)
+////                  {
+////                      if (userDidSelect)
+////                      {
+////                          //User selected the item in the UIPrinterPickerController and got the printer details.
+////                          
+////                          [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:printerPicker.selectedPrinter];
+////                          
+////                          //Here you will get the printer and printer details.ie,
+////                          // printerPicker.selectedPrinter, printerPicker.selectedPrinter.displayName, printerPicker.selectedPrinter.URL etc. So you can display the printer name in your label text or button title.
+////                          
+////                          
+////                          
+////                          
+////                          appDelegate.printerURL =printerPicker.selectedPrinter.URL.absoluteString;
+////                          
+////                          [self startAirPrintWithData:self.content];
+////                          
+////                      }
+////                      else
+////                      {
+////                          
+////                          
+////                          //                          AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+////                          //                          if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
+////                          //                          {
+////                          //
+////                          //                              [((MainViewController*)appDelegate.main_vc) Loginout:false];
+////                          //                          }
+////                          //                          [self prepareReturn:nil];
+////                          
+////                          //[self.navigationController popViewControllerAnimated:true];
+////                      }
+////                  }];
+////             }
+//         }
+//     }];
+//    
+    
+    
+}
+- (IBAction)onActionClick:(id)sender {
+   
+    //NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+    
+//    NSString *filePath = nil;
+//    if(!self.isLocalfile)
+//    {
+//    NSString *path = NSTemporaryDirectory();
+//    NSString* filename =self.filename;
+//    
+//   filePath= [path stringByAppendingPathComponent:filename];
+//    
+//    }
+//    else
+//        filePath = self.url;
+
+    
+    
+  
+    
+
+    [self openFile:self.url];
+}
+- (IBAction)onSaveClick:(id)sender {
+    
+    //UIAlertControllerStyle两种类型UIAlertControllerStyleAlert类似UIAlertView
+    //UIAlertControllerStyleActionSheet类似UIActionSheet
+    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Save pdf" message:nil preferredStyle:UIAlertControllerStyleAlert];
+    //block代码块取代了delegate
+  
+    
+    [alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
+        textField.text = self.save_name;
+       
+        
+    }];
+    
+    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Save" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
+        
+        UITextField *name = alertControl.textFields.firstObject;
+        if(name.text.length==0)
+        {
+        [RAUtils message_alert:@"Cannot save without name. Save canceled." title:@"Name is missing" controller:self];
+        }
+        else
+        {
+            self.save_name = name.text;
+                            self.btnsave.enabled =false;
+          //  NSMutableDictionary * info =
+            if(self.onSavePDF)
+                self.onSavePDF(self.save_name,self.filename);
+        }
+    }];
+
+    UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+        DebugLog(@"Cancel");
+    }];
+    [alertControl addAction:actionOne];
+
+    [alertControl addAction:alertthree];
+    
+    //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+
+    
+    [self presentViewController:alertControl animated:YES completion:nil];
+    
+    
+    
+    
+}
+
+- (IBAction)onEmailClick:(id)sender {
+    //NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+//    NSString *path = NSTemporaryDirectory();
+    NSString* filename =self.filename;
+    
+//    NSString *filePath = [path stringByAppendingPathComponent:filename];
+
+    NSString *filePath = self.url;
+
+    
+    
+    
+    
+    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
+    
+    if(mc==nil)
+    {
+        //[RAUtils message_alert:@"You must create an email account first."  title:@"Send Email" controller:self];
+        return;
+    }
+    mc.mailComposeDelegate = self;
+    [mc setSubject:self.mail_subject];
+    
+    
+    [mc setToRecipients:self.mail_to];
+    
+    
+    if(self.mail_content==nil)
+        self.mail_content=@"";
+    
+    NSString* htmlbody = [NSString stringWithFormat:@"<html><p>%@</p></html>",self.mail_content];
+    
+    [mc setMessageBody:htmlbody
+                isHTML:YES];
+    
+
+    
+    NSData *data = [NSData dataWithContentsOfFile:filePath];
+    
+//    if(self.attachment_name.length>0)
+//        filename = self.attachment_name;
+    [mc addAttachmentData:data mimeType:@"application/pdf" fileName:filename];
+    [self presentModalViewController:mc animated:YES];
+    
+    return;
+}
+
+
+-(void)openFile: (NSString *) file_url  {
+    
+    NSURL *file_URL = [NSURL fileURLWithPath:file_url];
+    
+    if (file_URL != nil) {
+        if (self.fileInteractionController == nil) {
+            //_fileInteractionController = [[UIDocumentInteractionController alloc] init];
+            
+            
+            _fileInteractionController = [UIDocumentInteractionController interactionControllerWithURL:file_URL];
+            _fileInteractionController.delegate = self;
+            //  [_fileInteractionController retain];//不适用ARC,记得RETAIN 使用ARC注释这一行
+        }
+        else
+        {
+            self.fileInteractionController.URL = file_URL;
+        }
+        
+        // [self.fileInteractionController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES];
+        
+        
+        [self.fileInteractionController setName:self.mail_subject];
+        
+//        [self.fileInteractionController setAnnotation:<#(id _Nullable)#>;
+        
+        [self.fileInteractionController presentOptionsMenuFromBarButtonItem:self.btnshare animated:YES];
+       // [self.fileInteractionController presentOptionsMenuFromRect:self.view.frame inView:self.view animated:YES];
+        //        [self.fileInteractionController  presentPreviewAnimated:YES];
+        
+    }
+}
+//- (void) sendEmail:(NSString *)to cc:(NSString*)cc subject:(NSString*)subject body:(NSString*)body
+//{
+//    NSString* str = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@",
+//                     to, cc, subject, body];
+//    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+//    
+//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
+//    
+//    
+//}
+
+#pragma mark methods for the UIDocumentInteractionControllerDelegate
+
+- (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller
+{
+//    if (controller == self.fileInteractionController) {
+//        self.fileInteractionController = nil;
+//    }
+}
+
+- (void)previewDocumentWithURL:(NSURL*)url
+{
+    UIDocumentInteractionController* preview = [UIDocumentInteractionController interactionControllerWithURL:url];
+    preview.delegate = self;
+    [preview presentPreviewAnimated:YES];
+    
+}
+
+- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
+{
+    
+}
+
+- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller{
+    return self;
+}
+
+- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller{
+    return self.view.frame;
+}
+
+- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller{
+    return self.view;
+}
+- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(nullable NSString *)application	 // bundle ID
+{
+    
+}
+
+
+#pragma mark - web view delegate
+- (void)webViewDidFinishLoad:(UIWebView *)webView
+{
+    self.mum.hidden=true;
+    
+    
+    if(self.onLoadSuccess)
+        self.onLoadSuccess(self.url);
+    
+    if(self.autoPrint)
+        [self startAirPrintWithData:self.content];
+    
+}
+- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
+{
+    
+}
+#pragma mark -MFMailComposeViewControllerDelegate delegate
+
+- (void)mailComposeController:(MFMailComposeViewController*)controller
+          didFinishWithResult:(MFMailComposeResult)result
+                        error:(NSError*)error {
+    switch (result)
+    {
+        case MFMailComposeResultCancelled:
+            DebugLog(@"Mail send canceled...");
+            break;
+        case MFMailComposeResultSaved:
+            DebugLog(@"Mail saved...");
+            break;
+        case MFMailComposeResultSent:
+            DebugLog(@"Mail sent...");
+            break;
+        case MFMailComposeResultFailed:
+            DebugLog(@"Mail send errored: %@...", [error localizedDescription]);
+            break;
+        default:
+            break;
+    }
+    [self dismissModalViewControllerAnimated:YES];
+}
+/*
+#pragma mark - Navigation
+
+ In a storyboard-based application, you will often want to do a little preparation before navigation
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
+{
+     Get the new view controller using [segue destinationViewController].
+     Pass the selected object to the new view controller.
+}
+*/
+- (void)startAirPrintWithData:(id )data
+{
+
+
+    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"preparing print..."];
+
+    UIPrintInteractionController* airPrinterController=[UIPrintInteractionController sharedPrintController];
+    UIPrintInfo *printInfo = [UIPrintInfo printInfo];
+    printInfo.outputType = UIPrintInfoOutputGeneral;
+    printInfo.orientation = UIPrintInfoOrientationPortrait;
+    printInfo.jobName = @"CoolVisitAirPrint";
+    airPrinterController.printInfo = printInfo;
+    airPrinterController.printingItem = data;
+    airPrinterController.delegate = self;
+
+
+    airPrinterController.showsNumberOfCopies=true;
+    airPrinterController.showsPageRange = true;
+    airPrinterController.showsPaperSelectionForLoadedPapers=true;
+
+    void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
+        if(completed && error)
+            DebugLog(@"Printing failed due to error in domain %@ with error code %lu. Localized description: %@, and failure reason: %@", error.domain, (long)error.code, error.localizedDescription, error.localizedFailureReason);
+    };
+
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+
+    UIPrinter *airPrinter = [UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL] ];///*self.printer;*/
+
+
+
+
+    [[UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL]] contactPrinter:^(BOOL available)
+     {
+         [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+         
+         if (available&& appDelegate.printerURL.length>0)
+         {
+             
+
+             [airPrinterController printToPrinter:airPrinter completionHandler:completionHandler];
+             DebugLog(@"AIRPRINTER AVAILABLE");
+         }
+         else
+         {
+
+             //             [airPrinterController presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
+             //
+             //
+             //
+             //              //        [printPicker presentAnimated:YES completionHandler:
+             //              ^(UIPrintInteractionController *printerController, BOOL userDidSelect, NSError *error)
+             //              {
+             //                  if (userDidSelect)
+             //                  {
+             //                      NSString* sid= printerController.printInfo.printerID;
+             //                      UIPrintPaper*paper=  printerController.printPaper;
+             //
+             //                  }
+             //              }];
+
+
+             DebugLog(@"AIRPRINTER NOT AVAILABLE");
+
+
+
+             if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
+             {
+                 UIPrinterPickerController *printPicker = [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:nil];
+              //   [printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:yes completionHandler:
+
+
+
+                [ printPicker presentFromBarButtonItem:self.btnshare animated:YES completionHandler:
+
+
+                // [printPicker presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
+
+
+
+                  //        [printPicker presentAnimated:YES completionHandler:
+                  ^(UIPrinterPickerController *printerPicker, BOOL userDidSelect, NSError *error)
+                  {
+                      if (userDidSelect)
+                      {
+                          //User selected the item in the UIPrinterPickerController and got the printer details.
+
+                          [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:printerPicker.selectedPrinter];
+
+                          //Here you will get the printer and printer details.ie,
+                          // printerPicker.selectedPrinter, printerPicker.selectedPrinter.displayName, printerPicker.selectedPrinter.URL etc. So you can display the printer name in your label text or button title.
+
+
+
+
+                          appDelegate.printerURL =printerPicker.selectedPrinter.URL.absoluteString;
+
+                          [self startAirPrintWithData:data];
+
+                      }
+                      else
+                      {
+
+
+//                          AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                          if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
+//                          {
+//
+//                              [((MainViewController*)appDelegate.main_vc) Loginout:false];
+//                          }
+//                          [self prepareReturn:nil];
+
+                          //[self.navigationController popViewControllerAnimated:true];
+                      }
+                  }];
+             }
+         }
+     }];
+
+
+
+}
+
+#pragma mark - UIPrintInteractionControllerDelegate
+- (UIPrintPaper *)printInteractionController:(UIPrintInteractionController *)printInteractionController choosePaper:(NSArray<UIPrintPaper *> *)paperList
+{
+
+    ;
+
+    //    (int) width = 29700
+    //    Printing description of (*( (int *)0x7caa3a40)):
+    //    (int) height = 42000
+    //设置纸张大小
+
+    CGSize paperSize=[PDFUtils QueryPDFSizeFromData:self.content];
+    for(UIPrintPaper* paper in paperList)
+    {
+        if (CGSizeEqualToSize(paper.paperSize, paperSize))
+            return paper;
+
+    }
+    
+    UIPrintPaper * pp=[[UIPrintPaper alloc] init];
+    
+//    CGSize paperSize = CGSizeMake(612, 792);
+    UIPrintPaper * p=[UIPrintPaper bestPaperForPageSize:paperSize withPapersFromArray:paperList];
+    return p;
+}
+- (void)printInteractionControllerWillPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
+{
+
+}
+- (void)printInteractionControllerDidPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
+{
+
+}
+- (void)printInteractionControllerWillDismissPrinterOptions:(UIPrintInteractionController *)printInteractionController
+{
+
+}
+- (void)printInteractionControllerDidDismissPrinterOptions:(UIPrintInteractionController *)printInteractionController
+{
+
+}
+
+- (void)printInteractionControllerWillStartJob:(UIPrintInteractionController *)printInteractionController
+{
+
+}
+- (void)printInteractionControllerDidFinishJob:(UIPrintInteractionController *)printInteractionController
+{
+
+//    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//    if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
+//    {
+//
+//        [((MainViewController*)appDelegate.main_vc) Loginout:false];
+//    }
+//
+//    [self prepareReturn:nil];
+
+    if(self.autoPrint)
+    [self.navigationController popViewControllerAnimated:true];
+}
+@end

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

@@ -7,7 +7,7 @@
 //
 
 #import "PDFUtils.h"
-#import "PDFPage.h"
+#import "RAPDFPage.h"
 #import "ImageDrawable.h"
 #import "TextDrawable.h"
 #import "RectDrawable.h"
@@ -342,7 +342,7 @@ isnew:(bool)isNewDocument
         
         CGContextBeginPage(pdfContext, &papersize);
         
-        PDFPage* pdfPage = [[PDFPage alloc] init:nil size:papersize];
+        RAPDFPage* pdfPage = [[RAPDFPage alloc] init:nil size:papersize];
         
         [pdfPage DirectDraw:pdfContext page:page];
         
@@ -612,7 +612,7 @@ isnew:(bool)isNewDocument
 //        
 //        CGContextBeginPage(pdfContext, &papersize);
 //        
-//        PDFPage* pdfPage = [[PDFPage alloc] init:nil size:papersize];
+//        RAPDFPage* pdfPage = [[RAPDFPage alloc] init:nil size:papersize];
 //        
 //        [pdfPage DirectDraw:pdfContext page:page];
 //        

+ 37 - 0
RedAnt ERP Mobile/common/pdfCreator/RAPDFPage.h

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

+ 276 - 0
RedAnt ERP Mobile/common/pdfCreator/RAPDFPage.m

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