Skip to content

Commit

Permalink
Fix ios webview url
Browse files Browse the repository at this point in the history
  • Loading branch information
lucashsilva committed Sep 15, 2020
1 parent 5eb764e commit 63843da
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/ios/PDFGenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ - (void)htmlToPDF:(CDVInvokedUrlCommand*)command
NSString* type = [command argumentAtIndex:2 withDefault:@"A4"];
NSString* _landscape = [command argumentAtIndex:3 withDefault:@"portrait"];
NSString* option = [command argumentAtIndex:4 withDefault:@"base64"];
NSString* bUrl = [command argumentAtIndex:6 withDefault:NULL];
NSString* bUrl = [command argumentAtIndex:6 withDefault:NULL];


BNPageSize pageSize;
BOOL landscape = NO;
NSURL *baseUrl = nil;
NSURL *baseUrl = nil;

if ([type isEqualToString:@"A3"]) {
pageSize = BNPageSizeA3;
Expand All @@ -119,13 +119,13 @@ - (void)htmlToPDF:(CDVInvokedUrlCommand*)command
landscape = YES;
}

if (bUrl != NULL) {
if ([bUrl isEqualToString:@"BUNDLE"]) {
baseUrl = [[NSBundle mainBundle] bundleURL];
} else {
baseUrl = [[NSURL alloc] initWithString:bUrl];
}
}
if (bUrl != NULL) {
if ([bUrl isEqualToString:@"BUNDLE"]) {
baseUrl = [[NSBundle mainBundle] bundleURL];
} else {
baseUrl = [[NSURL alloc] initWithString:bUrl];
}
}

if (url != NULL)
self.htmlPdfKit = [BNHtmlPdfKit saveUrlAsPdf:[NSURL URLWithString:url]
Expand All @@ -135,12 +135,12 @@ - (void)htmlToPDF:(CDVInvokedUrlCommand*)command
failure:[self GetErrorHandler:command]];

if (data != NULL){
NSURL *base = [[NSURL alloc] initWithString:[[self.webViewEngine.URL absoluteString] stringByDeletingLastPathComponent]];
NSURL *base = [[NSBundle mainBundle] bundleURL];

self.htmlPdfKit = [BNHtmlPdfKit saveHTMLAsPdf:data
pageSize:pageSize
isLandscape:landscape
baseUrl:base
baseUrl:base
success:[self GetPDFHandler:command setOptions:option]
failure:[self GetErrorHandler:command]];

Expand Down

2 comments on commit 63843da

@danielrf121
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi.

Does this commit refer to the error?
"'NSInvalidArgumentException', reason: '*** - [NSURL initWithString: relativeToURL:]: nil string parameter'"

Do you have any forecast for this correction to go to NPM? Version 2.1.1 is still having problems.

@jishnuraghu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I too getting the same error. Had to directly refer to the git repository as of now. Could you publish this to the npm registry as well?

Please sign in to comment.