【发布时间】:2013-03-01 18:52:24
【问题描述】:
我正在尝试将 UIView 打印为 PDF。
问题是,如果 UIView 比页面高,它就会被截断。
所以我想要做的是遍历 UIView 的“页面高度”并将它们分别呈现为 PDF 页面。
这是我的代码:
UIGraphicsBeginPDFContextToData(pdfData, CGRectMake(0, 0, 400, 782), nil);
CGContextRef pdfContext = UIGraphicsGetCurrentContext();
UIGraphicsBeginPDFPage();
// draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData
[self.receiptContentView.layer renderInContext:pdfContext];
UIGraphicsBeginPDFPage();
// draws rect to the view and thus this is captured by UIGraphicsBeginPDFContextToData
[self.receiptContentView.layer renderInContext:pdfContext];
// remove PDF rendering context
UIGraphicsEndPDFContext();
显然,目前它只是在每个页面上呈现相同的内容。
如何将上面的代码更改为“仅在第 1 页打印前 782px,然后在第 2 页打印 NEXT 782px”?
非常感谢。
【问题讨论】:
标签: ios objective-c pdf printing graphicscontext