I'm having a heck of time figuring out how to create a dynamic PDF - I don't know why I just can't seem to wrap my head around the logic to put this together and keep getting caught in some variation of a loop.
I have an NSArray that varies in length as it's generated with user created content. The content consists of strings and images (well NSData that's used to create UIImages).
The first page of the PDF has a dynamic header, so there's a static placement of things like name and address but that data is dynamically generated as well. I've created two UIViews in a xib (another concept I'm not really famaliar with as I'm very new to this all) and have created two classes that are a subclass of UIView for each UIView in the xib. On the first view I have another UIView in it's hierarchy that will take the dynamic content from the array.
So my thought is to iterate through the array and keep track of the height of every object, plus a vertical offset for each object, then to minus the height of the dynamic content view of the first PDF page, then divide what's left by the height of a PDF page, then add 1 (for the first page) and that will give me the number of pages that I'll need.
Two things strike at me first, what do I do if a string is longer than a PDF page?
Whats' the best way to iterate, using an integer as an index, but keeping track of what objects still need to be added?
Then onto the PDF creation itself, I think visually seeing something in a UIView is great but would like to draw the text in using real typography and not just a scaled bitmap of a UIView, reading over Apple's docs on that has got my head spinning as well. I have a feeling I'm a bit brain frazzled at this point so any help or pointing in the right direction would be greatly greatly appreciated.
I have an NSArray that varies in length as it's generated with user created content. The content consists of strings and images (well NSData that's used to create UIImages).
The first page of the PDF has a dynamic header, so there's a static placement of things like name and address but that data is dynamically generated as well. I've created two UIViews in a xib (another concept I'm not really famaliar with as I'm very new to this all) and have created two classes that are a subclass of UIView for each UIView in the xib. On the first view I have another UIView in it's hierarchy that will take the dynamic content from the array.
So my thought is to iterate through the array and keep track of the height of every object, plus a vertical offset for each object, then to minus the height of the dynamic content view of the first PDF page, then divide what's left by the height of a PDF page, then add 1 (for the first page) and that will give me the number of pages that I'll need.
Two things strike at me first, what do I do if a string is longer than a PDF page?
Whats' the best way to iterate, using an integer as an index, but keeping track of what objects still need to be added?
Then onto the PDF creation itself, I think visually seeing something in a UIView is great but would like to draw the text in using real typography and not just a scaled bitmap of a UIView, reading over Apple's docs on that has got my head spinning as well. I have a feeling I'm a bit brain frazzled at this point so any help or pointing in the right direction would be greatly greatly appreciated.