0

I have created a PDF page with box using core graphics (Image).

I am facing a problem, which is comment section I am not able to set "Text" individual wise. Any idea how can I do this?

Code for "Comment" section.

textToDraw=@"Comments:";
newfont=fontName2(7);
renderingRect = CGRectMake(20,146.5, 842, 300.0);
[textToDraw drawInRect:renderingRect withFont:newfont lineBreakMode:nil alignment:nil];



////////////////
CGContextSetLineWidth(currentContext, 1.0);
CGContextMoveToPoint(currentContext, 20,155);
CGContextAddLineToPoint(currentContext,295, 155);
CGContextStrokePath(currentContext);

CGContextSetLineWidth(currentContext, 1.0);
CGContextMoveToPoint(currentContext, 20,170);
CGContextAddLineToPoint(currentContext,295, 170);
CGContextStrokePath(currentContext);



CGContextSetLineWidth(currentContext, 1.0);
CGContextMoveToPoint(currentContext, 20,185);
CGContextAddLineToPoint(currentContext,295, 185);
CGContextStrokePath(currentContext);



CGContextSetLineWidth(currentContext, 1.0);
CGContextMoveToPoint(currentContext, 20,200);
CGContextAddLineToPoint(currentContext,295, 200);
CGContextStrokePath(currentContext);


@try{


    textToDraw=@"";
    NSString *commentText=@"helo how are you. i am tuna  string. i have so many friends. helllo i am working.here is my paragraph writing";

    renderingRect = CGRectMake(62, 146, 220, 400);
    newfont=fontName2(7);
    [commentText drawInRect:renderingRect withFont:newfont    lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentLeft];



       }

              @catch(NSException *e){

   }
Mikhail Kholodkov
  • 23,642
  • 17
  • 61
  • 78
  • Did you try adding `"\n"` as you're adding other text? Like `@"helo how are you.\ni am tuna string."` – TheTiger May 28 '18 at 11:10
  • First of all, thanks for response. How we add "\n", because use ad this string. I am stuck to implement this things. – Jezebel Smith May 28 '18 at 11:15
  • By separating the whole line by dot `"."` character or try replacing '"."' with `"\n"`? I'm not sure how you get this whole combine string. Was it an array or what? Or first try with static text then we can think further if it works. – TheTiger May 28 '18 at 11:26
  • I have solved this problem using 'NSMutableParagraphStyle' style. – Jezebel Smith May 28 '18 at 11:28
  • Please either post your answer and accept it or delete this question. – TheTiger May 28 '18 at 11:51

0 Answers0