iclems / iOS-htmltopdf

MIT License
305 stars 79 forks source link

Multiple HTML files to one PDF #25

Closed alexvenom closed 10 years ago

alexvenom commented 10 years ago

Guys, I'm having a very difficult time trying to generate one PDF with multiple pages, each page being a different HTML file. I can generate N pdf files each one having the content of one of the HTML files, but I want to group all that in just one PDF. In time, I can't use the content coming from a UIWebView. It has to come from a URL. Anyone has any tips on this? Thank you in advance!

iclems commented 10 years ago

Hi there,

I think you do have to stick to iOS-htmltopdf as other solutions will make it harder for you as you don't know the number of pages a URL will create. The simplest solution is probably to concatenate the PDFs after they've all been created. Alternatively, we could make iOS-htmltopdf more complex to expose the PDF context, etc, but I'm not sure it's what we're looking for here. It needs to remain simple.

Either you fork it and implement an array of URL and append to the PDF context, or you just concatenate. The first solution is definitely more efficient, while the second will make your code simpler. One issue you have to be careful about is that all your pages should probably have the same size (it will make things simpler), but as you're only concatenating different URLs, it should