I generate a PDF in my Swift
application from some HTML. I use a UIMarkupTextPrintFormatter
and have code similar to this gist. I get the PDF as NSData
and attach it to an email. The app does not show the PDF to the user before attaching it.
I'd now like to include some images. Adding their NSURL
in HTML with my current PDF generating strategy doesn't work. How can I get NSData
of a PDF corresponding to my HTML with images added? Here are some things I've tried:
This answer suggests embedding the base64 image in the HTML and using UIPrintInteractionController
. This does give me a print preview with correctly-embedded images but how do I go from there to NSData
corresponding to the PDF output?
I've seen some similar suggestions going through UIWebView
but those lead to the same issue -- I don't want to show a preview to the user.
question from:
https://stackoverflow.com/questions/40368144/generate-pdf-with-images-from-html-in-swift-without-displaying-print-interface 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…