我正在创建PDF,我在PDF中添加了许多NSString值,但是我想在PDF中添加一些我创建的HTML样式文本;唯一的事情是当我像这样的普通字符串加载它时:
[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);
///....
答案 0 :(得分:-1)
试试这个 -
UIGraphicsBeginPDFContextToFile(...);
UIGraphicsBeginPDFPageWithInfo(...); // load first uiwebview
// ...
UIGraphicsBeginPDFPageWithInfo(...); // load second uiwebview
// ...
UIGraphicsEndPDFContext();