3

enter image description here

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!

2

3 Answers 3

7

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 :)

1
  • For an HTML page, you can use UIMarkupTextPrintFormatter. Jan 19, 2017 at 23:31
1

Best place to start here and then here

need to draw a table with lines and add text and image to it also :)

For info refer

and docs

1

There are two ways to draw PDF.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.