简体   繁体   English

从HTML正文创建PDF文件并作为邮件附件发送,iOS

[英]Create PDF file from HTML Body and Sending as mail attachment, iOS

I have a HTML body as a NSString and would like to send it as an pdf-attachment. 我有一个HTML正文作为NSString,并希望将其作为pdf附件发送。 I'm quite new to iOS and can't figure out how, see code below. 我对iOS还是很陌生,不知道怎么做,请参见下面的代码。

NSString* body = "<html><body>stuff</body></html>"
MCOMessageBuilder * builder = [[MCOMessageBuilder alloc] init];
[builder setHTMLBody:body];

MCOAttachment *pdf = ... //body to pdf
[builder addAttachment:pdf];

Try this github iOS-htmltopdf . 试试这个github iOS-htmltopdf Its working for me. 它为我工作。 This code create one pdf file. 此代码创建一个pdf文件。 store that file into document directory, and attach the pdf file in mail. 将该文件存储到文档目录中,然后将pdf文件附加到邮件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM