动态内容的 PDF 生成
我正在我的应用程序中生成pdf报告,当页面内容超过一页时如何填充内容,实际上在这种情况下我尝试通过给出CGContextBeginPage()来创建一个新页面; 但它显示错误,如
:CGContextEndPage:不要嵌套调用此函数 - 结果将不是您所期望的。 **** :CGContextBeginPage:不要嵌套调用此函数 - 结果将不是您所期望的。
有人能告诉我在这种情况下如何创建 pdf 吗?
i am generating pdf report in my app,When the page contents exceeds over one page how to populate the contents,actually in this situation i tried to create one more new page by giving CGContextBeginPage();
but it is showing error like
: CGContextEndPage: Don't nest calls to this function -- the results will not be what you expect.
**** : CGContextBeginPage: Don't nest calls to this function -- the results will not be what you expect.
Can somebody tell me how to create pdf during this kind of situation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该有一个变量来存储布局内容时当前的 Y 位置,并按内容(以及任何填充)的高度递增该值。
每次您想要渲染一些文本或图像等时,请在渲染之前检查页面上是否有足够的空间,如果没有,则结束当前页面并开始新页面。通过查看当前 Y 位置、添加内容高度并与页面矩形进行比较来检查空间。
您收到的错误是由于您嵌套 PDF 页面调用而导致的,操作系统需要以下方法...
但是您的代码很可能如下嵌套这些...
You should have a variable that stores your current Y position as you are laying out content, incrementing this value by the height of the content (and any padding).
Each time you want to render some text or image etc, check that you have enough space on the page before rendering and if not end the current page and begin a new one. Check the space by looking at the current Y position, adding the content height to it and comparing to your page rect.
The errors you are getting are due to you nesting PDF page calls, the OS expects the following approach...
However your code is most likely nesting these as follows...