Reputation: 7895
I am utilizing a UIViewPrintFormatter to help me render HTML content from a UIWebView into a PDF context (and I am creating multiple columns for the content). Everything seems to work well except for the fact that the UIViewPrintFormatter seems to be inserting 'extra' spacing wherever it sees fit (and I can't even seem to exactly determine why it is). I am using a custom UIPrintPageRenderer.
From what I can tell, the extra spacing is all happening within the print formatter class. I am getting the rect from the print formatter in this manner:
CGRect formatterRect = [formatter rectForPageAtIndex:column];
I am then using that rect in the following manner (only having modified the origin's x value to support the columns:
[self.printTask.formatter drawInRect:renderRect forPageAtIndex:i];
You can see in the example below that extra spacing is being inserted (see the red rectangles that I added).
Has anyone seen this or know of a way to fix this? I obviously know that I can re-create the same by adding and positioning each item and skipping the HTML / UIWebView all together (and that will probably be what I do if I can't get this to work).
Upvotes: 3
Views: 1198
Reputation: 7895
In short, I found no way to solve this issue using public methods (or private ones for that matter). If you have a similar challenge, I would recommend leveraging TextKit / CoreText to ensure that the formatting meets your needs.
Upvotes: 1