Skip to content

Images missing after change to WKWebView #47

@HenningH-DEV

Description

@HenningH-DEV

Hello,

I suddenly changed from an old version of NDHTMLtoPDF with UIWebView to the current version with WKWebView. Then problem now is, that I'm missing the images in the pdf. Is this a bug or do I need to change something in the code?

Code for the image (the logo)

NSString *fileURLString = [[[NSBundle mainBundle] URLForResource:@"Logo" withExtension:@"png"] absoluteString];
[htmlStrForPDF appendString:[NSString stringWithFormat:@"<td style=\"border-style:hidden\"; align=\"right\"><img src=\"%@\"/ alt=\"Logo\"; style=\"width:74px; height:50px\"></td>", fileURLString]];
[htmlStrForPDF appendString:@"</tr></table>"];

Code for creating the pdf

PlanExport *export = [[PlanExport alloc] init];                                                   
NSMutableString *htmlStrForPDF = [export createPDFPlan];
CGSize paperSize = CGSizeMake(839, 595); // DIN A4

NSString *ns_pathForFile = [NSString stringWithFormat:@"%@.%@",LocalizedString(@"PlanFileName", nil), LocalizedString(@"ExportFormatPDF", nil)];

self.PDFCreator = [NDHTMLtoPDF createPDFWithHTML:htmlStrForPDF pathForPDF:[AppCommon GetPathForFile:ns_pathForFile] pageSize:paperSize margins:UIEdgeInsetsMake(10, 15, 20, 15) successBlock:^(NDHTMLtoPDF *htmlToPDF) {
   NSString *result = [NSString stringWithFormat:@"HTMLtoPDF did succeed (%@ / %@)", htmlToPDF, htmlToPDF.PDFpath];
   NSLog(@"%@",result);
   
   // Send the generated file through Email.
   [self showEmail];
   
} errorBlock:^(NDHTMLtoPDF *htmlToPDF) {
   NSString *result = [NSString stringWithFormat:@"HTMLtoPDF did fail (%@)", htmlToPDF];
   NSLog(@"%@",result);
}];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions