ipad - iOS Dynamic PDF generation, with desired Text font type and font color -


i creating dynamic pdf application. in cases want text write in pdf desired color. how can that?

i using coretext.

here code draw text in pdf,

+(void)drawtext:(nsstring*)texttodraw inframe:(cgrect)framerect {     framerect.origin.y = framerect.origin.y + framerect.size.height; // new line     cfstringref stringref = ( cfstringref)texttodraw;     cgcolorspacecreatewithname(stringref);     cfattributedstringref currenttext = cfattributedstringcreate(null, stringref, null);     ctframesetterref framesetter = ctframesettercreatewithattributedstring(currenttext);     cgmutablepathref framepath = cgpathcreatemutable();     cgpathaddrect(framepath, null, framerect);     // frame rendering.     cfrange currentrange = cfrangemake(0, 0);     ctframeref frameref = ctframesettercreateframe(framesetter, currentrange, framepath, null);     cgpathrelease(framepath);     // graphics context.     cgcontextref    currentcontext = uigraphicsgetcurrentcontext();     // put text matrix known state. ensures     // no old scaling factors left in place.     cgcontextsettextmatrix(currentcontext, cgaffinetransformidentity);     // core text draws bottom-left corner up, flip     // current transform prior drawing.     cgcontexttranslatectm(currentcontext, 0, framerect.origin.y*2);     cgcontextscalectm(currentcontext, 1.0, -1.0);     // draw frame.     ctframedraw(frameref, currentcontext);     cgcontextscalectm(currentcontext, 1.0, -1.0);     cgcontexttranslatectm(currentcontext, 0, (-1)*framerect.origin.y*2);     cfrelease(frameref);     //cfrelease(stringref);     cfrelease(framesetter); } 

any or suggestion appreciated., in advance.

if using coretext, try

ctfontref font = ctfontcreatewithname((cfstringref)@"helvetica", 16.0f, nil); cfattributedstringsetattribute(textstring,cfrangemake(0, strlength-1), kctfontattributename, font); 

you can try cgcontextsetfont

nsstring *fontname = @"helvetica"; cgfontref fontref = cgfontcreatewithfontname((__bridge cfstringref)fontname); cgcontextsetfont(context, fontref); cgcontextsetfontsize(context, 30); 

see my question, idea.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -