How to use Xcode to populate PDF and HTML templates with user-defined variable data
Okay, s开发者_Python百科o I have developed my entire user interface with xcode. I have set various text fields as variables, and I am trying to figure out how to populate either PDF templates or HTML templates with this user defined variable data.
First, which would be better for printing (with a hardware printer, not in the coding sense)- PDF or HTML?
Second, is it possible to populate the user's input to either a PDF or HTML template? I am writing a legal software suite in which the PDF/HTML templates will not need to be visible in the interface itself, only when print previewing, or exporting the templates to another source (iPad, laptop, etc)?
Thanks for any advice you can offer.
Mitch
I think it would be easier to create a HTML document but for printing, PDF is better. This is because, as far as I know, HTML is rendered differently depending on the browser but PDF will always look the same.
To create HTML you could just write plain text to a file so you could write a template before-hand, read that template into a string in memory, search for fields and insert the user's data into that string, and write a new file.
For PDF it would be more complex. I would suggest having a look at PDF-kit for high-level and Quartz for low-level PDF programming.
I wrote razpdf app extension (static library) to make it easy to add PDF output to iOS apps. www.raz.com. Define a page sized view in IB, add dynamic data, call add page, save pdf on device. mail it to users. Check out docs and evaluation copy.
精彩评论