0

I have to create a PDF which contains data like a quotation document (text, tables, images, etc.). The data varies from 1 page to 3-4 pages. A table cell may have combination of text and images. Also, I have custom graphics to be rendered in PDF to show different shapes.

Example format: enter image description here

I have tried PDFKit provided by Apple. I was able to draw individual parts. But I don't know how can I achieve auto page break mode (which shifts data to new page when there is no more space available in a page). One way to achieve this is that I have to calculate individual heights and divide data into pages as per available page size.

Is there any better way to do it using PDFKit?

I am also aware about creating PDF using UIGraphicsBeginPDFContextToData(). It also doesn't support auto page break. We have to call UIGraphicsBeginPDFPageWithInfo() for each new page.

I have also tried TPPDF and SimplePDF. Both don't support either page break on table or custom views.

I also can't go for HTML to PDF solution as I have custom views to be drawn in PDF.

Which is the best way in iOS to create PDF with above mentioned requirements?

Chintan Shah
  • 1,744
  • 2
  • 26
  • 28
  • Hi there, I am the creator of TPPDF. Sorry I didn't see your question earlier. Please checkout the `develop` branch over on GitHub and open up an issue if the new table logic/rendering does not fulfill your use case – Phil Niedertscheider May 16 '20 at 09:11

1 Answers1

0

"One way to achieve this is that I have to calculate individual heights and divide data into pages as per available page size." - this is the only way as PDFKit does not include automatic data layout and auto page breaks.

Mihai Iancu
  • 1,818
  • 2
  • 11
  • 10