1
我试图将UIView作为PDF进行打印。将UIView /图形上下文分割为多个区域
问题是,如果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();
此刻
显然,它只是呈现在每一页上同样的事情。
我该如何更改上面的代码来说“只打印第一页上的第一个782px,然后打印第二页上的下一个782px”?
非常感谢。
啊哈!这非常出色。 :) 谢谢。 – 2013-03-14 08:55:10