0
我正在创建一个PDF,我已经将很多NSString值添加到了PDF中,但是现在我想添加一些我已经创建的HTML样式的文本到PDF中;唯一的一点是,当我打开它像一个正常的字符串是这样的:如何添加UIWebView到CGContextRef PDF?
[materialsHTML drawInRect:CGRectMake(55.0, 523.0, kDefaultPageWidth-100, 137.0) withAttributes:grayAttributes];
我失去所有的格式和所有你能看到的是HTML标签等
这是我开始我打开页面,我希望有人能告诉我如何插入某种UIWebView。
// create some sample data. In a real application, this would come from the database or an API.
NSString* path = [[NSBundle mainBundle] pathForResource:@"sampleData" ofType:@"plist"];
// get a temprorary filename for this PDF
path = NSTemporaryDirectory();
self.pdfFilePath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"Job Sheet #%@.pdf", jobSheetNumber]];
// Create the PDF context using the default page size of 612 x 792.
// This default is spelled out in the iOS documentation for UIGraphicsBeginPDFContextToFile
UIGraphicsBeginPDFContextToFile(self.pdfFilePath, CGRectZero, nil);
// get the context reference so we can render to it.
CGContextRef context = UIGraphicsGetCurrentContext();
// every student gets their own page
// Mark the beginning of a new page.
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, kDefaultPageWidth, kDefaultPageHeight), nil);
///....
不幸的是没有,那是从一个UIWebView使得整个PDF,我想两个小UIWebViews中添加到PDF,我猜你会称它为层。 – HurkNburkS 2015-04-06 06:51:27
尝试更新的答案。测试工作正常 – 2015-04-06 07:36:11
我认为,更新只是创建一个两页PDF ...我有PDF创建罚款,我希望添加两个视图内我已经创建的PDF包含HTML。 – HurkNburkS 2015-04-06 08:07:22