iphone - 如何在 PDF 中输出欧元符号

标签 iphone cocoa pdf currency euro

我正在尝试使用 Core Graphics 将欧元符号输出到 PDF。我有以下代码,它使用 NSMacOSRomanStringEncoding (我必须使用它来使 £ 和 $ 符号正确显示),但欧元符号显示为 ¤

CGRect pageRect = CGRectMake(0, 0, 800, 1150);
CFMutableDataRef pdfData = (CFMutableDataRef) [NSMutableData dataWithCapacity:0];                     
CGDataConsumerRef dataConsumer = CGDataConsumerCreateWithCFData(pdfData);
CGContextRef pdfContext = CGPDFContextCreate(dataConsumer, &pageRect, nil);

CGContextSelectFont(pdfContext, "Helvetica", 15, kCGEncodingMacRoman);
CGContextSetTextDrawingMode (pdfContext, kCGTextFill);
CGContextSetRGBFillColor (pdfContext, 0, 0, 0, 1);
const char *ctext = [@"€" cStringUsingEncoding:NSMacOSRomanStringEncoding];
CGContextShowTextAtPoint(pdfContext, 10, 10, ctext, strlen(ctext));

最佳答案

那是因为 MacRomanEncoding 默认情况下不包含欧元符号,请参阅“PDF 引用 1.7”(第 D.1 节拉丁字符集和编码)中的引用:

  1. In PDF 1.3, the euro character was added to the Adobe standard Latin character set. It is encoded as 200 in WinAnsiEncoding and 240 in PDFDocEncoding, assigning codes that were previously unused. Apple changed the Mac OS Latin-text encoding for code 333 from the currency character to the euro character. However, this incompatible change has not been reflected in PDF’s MacRomanEncoding, which continues to map code 333 to currency. If the euro character is desired, an encoding dictionary can be used to specify this single difference from MacRomanEncoding.

关于iphone - 如何在 PDF 中输出欧元符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7505143/

相关文章:

iphone - 覆盖 openURL 后无法推送 View Controller

ios - 应用程序未出现在 iCloud “Manage Storage” 列表中

pdf - 在 Kindle paperwhite 上阅读科学论文 (pdf)

javascript - Node 将 HTML 表达为 PDF

php - 使用php动态地将内容插入到pdf文件中

iphone - sqlite3 在 iPhone 应用程序中插入或替换语法问题

iphone - 如何每周或每月只调用一次函数?

iphone - UINavigationBar 和 UIScrollView 调整大小

cocoa - 如何提高 CGContextFillRect 和 CGContextDrawImage 性能

iphone - 多次读取 plist 与创建对象并仅读取一次 plist 以访问 plist 中的数据