This app showcases the following:
- Loading an HTML file into a web view (actually both a
WKWebView
andUIWebView
), - Generating a PDF using either
- the web views'
viewPrintFormatter()
or - a
UIMarkupTextPrintFormatter
,
- the web views'
- Printing a PDF using either
- one of the web views'
viewPrintFormatter()
or - a
UIMarkupTextPrintFormatter
- one of the web views'
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.
- Run the application.
- Tap
Create PDF
and thenUIMarkupTextPrintFormatter
: a PDF is generated from theindex.html
file and loaded into both aWKWebView
and aUIWebView
. Images are not rendered. - Tap
Load HTML
and thenindex-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 theimg
tags are the same). - Re-do step 1: tap
Create PDF
and thenUIMarkupTextPrintFormatter
: 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.