Monday, November 10, 2014

Formatting html at runtime:


1. Add custom font files in Proj.plist file
2. Insert the css styles at runtime.

NSString* htmlString = [NSString stringWithFormat:@"<html><head><style type=\"text/css\">"
                             @"@font-face {"
                             @"font-family: 'ITCAvantGardeStd-Bk';"
                             @"src: url('ITCAvantGardeStd-Bk.otf')  format('truetype')"
                             @"}"
                             @"@font-face {"
                             @"font-family: 'ITCAvantGardeStd-Bold';"
                             @"src: url('ITCAvantGardeStd-Bold.otf')  format('truetype')"
                             @"}"
                             @"body {"
                                @"font-family: ITCAvantGardeStd-Bk;"
                                @"font-size: 9pt;"
                                @"color: #969B9D"
                                @"}"
                             @"p{ font-family: 'ITCAvantGardeStd-Bk'; }"
                             @"strong {font-family: 'ITCAvantGardeStd-Bold';color:#5F656A;}"
                             @"</style></head><body>%@</body></html>",[self.contentDict1 objectForKey:@"bodyHTML"]];

No comments: