Open Isuru-Nanayakkara opened 9 years ago
@Isuru-Nanayakkara did you get to fix it?
@vinbhai4u Nope, I had to resort to saving via a HTML string.
@Isuru-Nanayakkara even that doesn't work for me,
generateBNHtmlPDF(){ let pdfKit = BNHtmlPdfKit() pdfKit.delegate = self let toFile = Path.documentsDir["file.pdf"].path_string let htmlString = Path.documentsDir["BSM.html"].readString() pdfKit.saveHtmlAsPdf(htmlString, toFile: toFile) print("open " + toFile) }
is there something wrong?
i also can not generate pdf from an webView, follow the code, i add the save method in the - (void)saveWebViewAsPdf:(UIWebView )webView toFile:(NSString )file; And it work now. i am not sure if this is correct ,but the doc has no use case on this .
-(void)saveWebViewAsPdf:(UIWebView )webView toFile:(NSString )file { [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(_timeout) object:nil]; self.outputFile = file; webView.delegate = self; self.webView = webView; //add for test [self _savePdf]; }
Hey, I have solved the issue while generating pdf file from webview --saveWebViewAsPdf(webView, toFile: pdfPath.absoluteString) and now delegates are being called properly with the path of saved pdf file.
Actually I have done my changes after forking the project. Infact I have make a test project for this but unfortunately I don't know how to push my changes.
I tried this first in a Swift project. I added the library via CocoaPods.
Here's the code.
When the save button is tapped, the PDF isn't generated. Nor any of the
BNHtmlPdfKitDelegate
methods get called.However other methods like
saveUrlAsPdf
andsaveHtmlAsPdf
do work. I tested this in Xcode 7.1 with iOS 8.4 and iOS 9.1 simulators.I've uploaded a demo project too.
Later I tested this in a Objective-C project as well. And it didn't work either. So I guess this isn't a language issue.