Reputation: 3908
I have all the data in NSData object but I dont know how to create a pdf that will display in this format. The main problem is that product does not have a fixed content size, there will be more and more depending upon the customer, how much he/she purchases.
I don't want to make uiview like below format because if do so then how do captured entire uitableview in .png format.
Please give the logic how to create pdf for below format. Thanks a ton!
Upvotes: 3
Views: 1902
Reputation: 6954
There are two ways to create PDFs in iOS:
If you want text in your PDF, you need to use Quartz 2D There is no API that helps you to draw in tabular format. You need to draw lines, text by calculating x and y positions, all done manually. If you have fixed set of fields then only you can follow this approach.
Else, you can create a html page for your required format, and then set this page in PDF as an image, a very simple approach.
Both will be done using Quartz 2D
Hope this helps :)
Upvotes: 7
Reputation: 1506
There are two ways to draw PDF.
Using UIKit API:
For this your can draw pdf line by line & image by imagem i.e. Object by Object. Link to this is : http://www.raywenderlich.com/6581/how-to-create-a-pdf-with-quartz-2d-in-ios-5-tutorial-part-1
Using Quartz 2D Api:
Using this You can draw pdf using the UIViews. Link for the same is: http://mobile.tutsplus.com/tutorials/iphone/generating-pdf-documents/
http://www.ioslearner.com/generate-pdf-programmatically-iphoneipad/
The UIKit Api creates a nice clean & smooth PDF. While Quartz2D framework creates a little blur pdf. So you need to be sure before using it.
Let me know if it works or any issues.
Upvotes: 1