Generate a PDF from an HTML file containing images (iOS).
This app showcases the following:
WKWebView
and UIWebView
),viewPrintFormatter()
orUIMarkupTextPrintFormatter
,viewPrintFormatter()
orUIMarkupTextPrintFormatter
Generating a PDF using a UIMarkupTextPrintFormatter
will not render the images of the HTML file. Unless the HTML code has been loaded into a web view beforehand.
Create PDF
and then UIMarkupTextPrintFormatter
: a PDF is generated from the index.html
file and loaded into both a WKWebView
and a UIWebView
. Images are not rendered.Load HTML
and then index-img.html
: the HTML code is loaded into both web views and the images are displayed. The HTML code is not the same as the one we used to generate our PDF (but the img
tags are the same).Create PDF
and then UIMarkupTextPrintFormatter
: another PDF is generated and loaded into the web views. And this time with images.This behavior tells me that UIMarkupTextPrintFormatter
does support img
tags. Also confirmed by the fact that Print PDF
> UIMarkupTextPrintFormatter
shows a PDF with images (actually only one image is displayed).
The Create PDF
> WebView.viewPrintFormatter()
action creates a PDF from what each web view is currently displaying, that can either be nothing, one of the HTML loaded beforehand or a PDF loaded from a previous execution.
The Create PDF
> UIMarkupTextPrintFormatter
action always creates the PDF from the index.html
file.