Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a Euro currency symbol in a PDF in Objective-C

I am making a PDF file in Objective-C and all goes well. But when I add some curreny symbols in the PDF, it shows something totally different.

‚dž2,060,0 instead of €2,060,0

I have uses the following code to draw text in a PDF:

NSString *reducedString = @"€4,854,525";
CGContextShowTextAtPoint (currentContext,xPos, yPos, [textToDraw UTF8String], [reducedString length]);

Anyone knows how to draw the Euro symbol using this same code ? Is there anything I need to change in the text encoding?

[reducedString drawAtPoint:CGPointMake(xPos  ,yPos) withFont:[UIFont systemFontOfSize:15];

Thanks in advance.

like image 792
Crazy Developer Avatar asked Jan 18 '26 12:01

Crazy Developer


2 Answers

Try using the unicode of euro symbol

\u20AC
like image 118
Shamis Shukoor Avatar answered Jan 21 '26 01:01

Shamis Shukoor


Right way to go is needs to use NSNumberFormatter.

NSInteger currency = 4345;
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
NSString *result = [numberFormatter stringFromNumber:[NSNumber numberWithInteger:currency]];

And result will be string with currency sign depending on the locale.

like image 23
Ramis Avatar answered Jan 21 '26 01:01

Ramis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!