iOS在pdf文档中绘制表格
我将从 UIViewController 的内容创建 pdf。 当UIViewController有表格区域时(与Excel相同),我没有找到在pdf文档中绘制表格的方法。 有谁知道如何解决这个问题?请帮我。
I will create the pdf from the contents of UIViewController.
When UIViewController has a table region(the same as Excel), I didn't find the method for drawing an table in pdf document.
Does anyone know to solve this problem? Please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,如果您使用 Quartz 图形上下文(CGContextRef 类型),则没有简单的方法来创建表。我能够通过在嵌套 for 循环中在 PDF 上绘制线条,并仔细注意间距以使其看起来正确,以编程方式创建表格。
伪代码:
这是您可能用来绘制表格的逻辑类型的粗略示例。您可能需要在桌子周围有一个矩形或边框以使其看起来正确,以及进行任何其他类型的调整以使其达到您想要的效果。您可以通过以下链接找到有关如何执行此操作的方法列表以及更多信息。我知道这可能不是您想要的,但我希望这可以为您在完全陷入困境时提供一些指导。祝你好运!
您可以在 Apple 文档中找到可用于绘制 PDF 的完整函数库: http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html
There is no easy method of creating a table I know of if you're using a Quartz graphics context (CGContextRef type). I was able to create a table programmatically by drawing lines on the PDF in nested for loops, and by paying careful attention to spacing to make it look right.
Psuedo-code:
This is a rough example of the kind of logic you might use to draw a table. You'll probably want a rectangle, or a border, around your table to make it look right, among any other kinds of tweaks to make it how you want. You can find the list of methods on how to do that and more through the below link. I know this probably isn't what you had in mind, but I hope this gives you some direction to take if you were totally stuck. Good luck!
You can find the full library of functions available for drawing PDFs in Apple's documentation: http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html