Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7574259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:23:35+00:00 2026-05-30T16:23:35+00:00

i am creating an iphone app for creating pdf. I am using the following

  • 0

i am creating an iphone app for creating pdf. I am using the following code:

    [self drawRect:CGRectMake(0, 0, 100, 20 )text:@"last Name"xVal:10 yVal:-30 len:9];
    [self drawRect:CGRectMake(0, 0, 100, 20 )text:@"First Name"xVal:180 yVal:30 len:10];
    [self drawRect:CGRectMake(0, 0, 100, 20 )text:@"Middle Name"xVal:330 yVal:-30 len:11];

    + (void) drawRect:(CGRect)rect text:(NSString *)string xVal:(int)x yVal:(int)y len:(int)length{
        CGContextRef theContext = UIGraphicsGetCurrentContext(); 
        CGRect viewBounds = rect;
        CGContextTranslateCTM(theContext, 0, viewBounds.size.height); 
        CGContextScaleCTM(theContext, 1, -1);
        // Draw the text using the MyDrawText function 
        MyDrawText(theContext, viewBounds,string, x, y,length);
    }
void MyDrawText (CGContextRef myContext, CGRect contextRect, NSString *textToDraw, int x, int y, int len){
    float w, h; 
    w = contextRect.size.width; 
    h = contextRect.size.height;
    CGAffineTransform myTextTransform;

    CGContextSelectFont (myContext,"Helvetica-Bold", h, kCGEncodingMacRoman);

    CGContextSetCharacterSpacing (myContext, 3);
    CGContextSetTextDrawingMode (myContext, kCGTextFill);   
    CGContextSetRGBFillColor(myContext, 0, 0, 0, 1);    

    CGContextSetRGBStrokeColor (myContext, 0, 0, 0, 0); 
    myTextTransform = CGAffineTransformMakeRotation(0.0); 
    CGContextSetTextMatrix (myContext, myTextTransform); 
    const char *str = [textToDraw UTF8String];
    CGContextShowTextAtPoint (myContext, x, y,str, len);
}

When I use this code I am getting the output like, first and third word is fine but the second one is coming like inverted (head down). Why so? Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:23:36+00:00Added an answer on May 30, 2026 at 4:23 pm

    The issue was with CGContextRef theContext = UIGraphicsGetCurrentContext();, when each time the function calls, the CGContext taking the last state, that’s why getting the inverting output. So, i added,

    CGContextRef theContext = UIGraphicsGetCurrentContext(); 
    CGContextSaveGState(theContext);
    //code to draw....
    CGContextRestoreGState(theContext);
    

    this solved the issue. Thanks 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an iphone app using Facebook api. Here I'm using the following
I've been creating an iPhone App using Core Data. First of all, does it
I am creating an iphone app and wanted to know if using NIB files
I am creating my second iPhone app, and I've included a feedback form using
I'm creating an iphone app using Facebook apis. I need to get the user's
I am currently creating an iPhone app using Xcode 4.0.2, I want the app
I have been following a tutorial on creating an iPhone app with multiple xibs.
I'm creating an iPhone app in X-Code. I have downloaded the ASIHTTPRequest library to
I am creating a iphone app in which I am using Three20 open source
I am creating an iphone app, and I am using a UITextField. In my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.