|
@@ -14,7 +14,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
@implementation PDFUtils
|
|
@implementation PDFUtils
|
|
|
-+(NSString*) addSignature :(UIImage*) img to:(NSMutableDictionary*)signatureData
|
|
|
|
|
|
|
++(NSString*) addSignature :(UIImage*) img to:(NSMutableDictionary*)signatureData subType:(NSString*)subtype
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
@@ -22,14 +22,20 @@
|
|
|
{
|
|
{
|
|
|
NSString* newfile=[self saveTempSignature:UIImagePNGRepresentation(img)];
|
|
NSString* newfile=[self saveTempSignature:UIImagePNGRepresentation(img)];
|
|
|
|
|
|
|
|
- int newidx = [signatureData[@"count"] intValue];
|
|
|
|
|
|
|
+ int newidx = [signatureData[subtype][@"count"] intValue];
|
|
|
|
|
|
|
|
// [@"file"]= newfile;
|
|
// [@"file"]= newfile;
|
|
|
|
|
|
|
|
NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
|
|
item[@"file"]=newfile;
|
|
item[@"file"]=newfile;
|
|
|
- signatureData[[NSString stringWithFormat:@"item_%d",newidx]] = item;
|
|
|
|
|
- signatureData[@"count"]=[NSNumber numberWithInt:newidx+1];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* subjson =signatureData[subtype];
|
|
|
|
|
+ if(subjson==nil)
|
|
|
|
|
+ subjson = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+ subjson[[NSString stringWithFormat:@"item_%d",newidx]] = item;
|
|
|
|
|
+ subjson[@"count"]=[NSNumber numberWithInt:newidx+1];
|
|
|
|
|
+
|
|
|
|
|
+ signatureData[subtype]=subjson;
|
|
|
|
|
|
|
|
return newfile;
|
|
return newfile;
|
|
|
|
|
|
|
@@ -226,14 +232,17 @@
|
|
|
[NSDictionary dictionaryWithObjectsAndKeys:
|
|
[NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
@"usai2010", (NSString *)kCGPDFContextOwnerPassword,
|
|
@"usai2010", (NSString *)kCGPDFContextOwnerPassword,
|
|
|
kCFBooleanTrue, (NSString *)kCGPDFContextAllowsPrinting,
|
|
kCFBooleanTrue, (NSString *)kCGPDFContextAllowsPrinting,
|
|
|
- kCFBooleanTrue, (NSString *)kCGPDFContextAllowsCopying,
|
|
|
|
|
|
|
+ kCFBooleanFalse, (NSString *)kCGPDFContextAllowsCopying,
|
|
|
nil];
|
|
nil];
|
|
|
// Create a descriptor.
|
|
// Create a descriptor.
|
|
|
- CFDictionaryRef cfpdfAttributes =(__bridge CFDictionaryRef)PDFAttributes;
|
|
|
|
|
|
|
+ CFDictionaryRef cfpdfAttributes =(__bridge CFDictionaryRef)(PDFAttributes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ // CFBridgingRelease(cfpdfAttributes);
|
|
|
|
|
+ pdfContext=CGPDFContextCreateWithURL(url, &docsize,cfpdfAttributes);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- pdfContext=CGPDFContextCreateWithURL(url, &docsize, cfpdfAttributes);
|
|
|
|
|
size_t page_count=CGPDFDocumentGetNumberOfPages(document);
|
|
size_t page_count=CGPDFDocumentGetNumberOfPages(document);
|
|
|
for(int i=1;i<=page_count;i++)
|
|
for(int i=1;i<=page_count;i++)
|
|
|
{
|
|
{
|
|
@@ -342,6 +351,7 @@
|
|
|
}
|
|
}
|
|
|
CGContextRelease(pdfContext);
|
|
CGContextRelease(pdfContext);
|
|
|
CFBridgingRelease(url);
|
|
CFBridgingRelease(url);
|
|
|
|
|
+ // CFRelease(cfpdfAttributes);
|
|
|
// //开始画pdf
|
|
// //开始画pdf
|
|
|
//
|
|
//
|
|
|
// // NSString *temtext=[[NSString alloc]init];
|
|
// // NSString *temtext=[[NSString alloc]init];
|