Skip to content

Commit 63843da

Browse files
committed
Fix ios webview url
1 parent 5eb764e commit 63843da

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/ios/PDFGenerator.m

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ - (void)htmlToPDF:(CDVInvokedUrlCommand*)command
100100
NSString* type = [command argumentAtIndex:2 withDefault:@"A4"];
101101
NSString* _landscape = [command argumentAtIndex:3 withDefault:@"portrait"];
102102
NSString* option = [command argumentAtIndex:4 withDefault:@"base64"];
103-
NSString* bUrl = [command argumentAtIndex:6 withDefault:NULL];
103+
NSString* bUrl = [command argumentAtIndex:6 withDefault:NULL];
104104

105105

106106
BNPageSize pageSize;
107107
BOOL landscape = NO;
108-
NSURL *baseUrl = nil;
108+
NSURL *baseUrl = nil;
109109

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

122-
if (bUrl != NULL) {
123-
if ([bUrl isEqualToString:@"BUNDLE"]) {
124-
baseUrl = [[NSBundle mainBundle] bundleURL];
125-
} else {
126-
baseUrl = [[NSURL alloc] initWithString:bUrl];
127-
}
128-
}
122+
if (bUrl != NULL) {
123+
if ([bUrl isEqualToString:@"BUNDLE"]) {
124+
baseUrl = [[NSBundle mainBundle] bundleURL];
125+
} else {
126+
baseUrl = [[NSURL alloc] initWithString:bUrl];
127+
}
128+
}
129129

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

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

140140
self.htmlPdfKit = [BNHtmlPdfKit saveHTMLAsPdf:data
141141
pageSize:pageSize
142142
isLandscape:landscape
143-
baseUrl:base
143+
baseUrl:base
144144
success:[self GetPDFHandler:command setOptions:option]
145145
failure:[self GetErrorHandler:command]];
146146

0 commit comments

Comments
 (0)