Skip to content

Commit 0a15712

Browse files
committed
Added support for NSData instead of file path
1 parent 7c6485a commit 0a15712

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

NDHTMLtoPDF.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ typedef void (^NDHTMLtoPDFCompletionBlock)(NDHTMLtoPDF* htmlToPDF);
1818
@protocol NDHTMLtoPDFDelegate <NSObject>
1919

2020
@optional
21+
- (void)HTMLtoPDFDidSucceed:(NDHTMLtoPDF*)htmlToPDF withData:(NSData*)data;
2122
- (void)HTMLtoPDFDidSucceed:(NDHTMLtoPDF*)htmlToPDF;
2223
- (void)HTMLtoPDFDidFail:(NDHTMLtoPDF*)htmlToPDF;
2324
@end

NDHTMLtoPDF.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,19 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView
175175
[render setValue:[NSValue valueWithCGRect:printableRect] forKey:@"printableRect"];
176176

177177
NSData *pdfData = [render printToPDF];
178-
179-
[pdfData writeToFile: self.PDFpath atomically: YES];
178+
179+
if (self.PDFpath) {
180+
[pdfData writeToFile: self.PDFpath atomically: YES];
181+
}
180182

181183
[self terminateWebTask];
182184

183185
if (self.delegate && [self.delegate respondsToSelector:@selector(HTMLtoPDFDidSucceed:)])
184186
[self.delegate HTMLtoPDFDidSucceed:self];
185-
187+
188+
if (self.delegate && [self.delegate respondsToSelector:@selector(HTMLtoPDFDidSucceed:withData:)])
189+
[self.delegate HTMLtoPDFDidSucceed:self withData:pdfData];
190+
186191
if(self.successBlock) {
187192
self.successBlock(self);
188193
}

0 commit comments

Comments
 (0)