IOS嵌入字体在PDF [英] IOS embed font in PDF

查看:149
本文介绍了IOS嵌入字体在PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在绘制一个PDF文件,无法知道如何将字体嵌入PDF本身,任何人都可以帮助我吗?它在设备上显示精细,但一旦它通过AirPrint发出电子邮件或打印,我只是得到后备字体。这是我的代码...

   - (void)drawChart {
CGContextRef currentContext = UIGraphicsGetCurrentContext
CGContextSetRGBFillColor(currentContext,0.0,0.0,0.0,1.0);


NSUserDefaults * data = [NSUserDefaults standardUserDefaults];
NSString * pChart1 = [data stringForKey:@pchart1];


NSString * textToDraw = [NSString stringWithFormat:@%@,pChart1];

UIFont * font = [UIFont fontWithName:@MyFontsize:14];

CGSize stringSize = [textToDraw sizeWithFont:font
constrainedToSize:CGSizeMake(pageSize.width - 2 * kBorderInset-2 * kMarginInset,pageSize.height - 2 * kBorderInset - 2 * kMarginInset)
lineBreakMode:UILineBreakModeWordWrap];

CGRect renderingRect = CGRectMake(kBorderInset + kMarginInset,kBorderInset + kMarginInset + 50.0,pageSize.width - 2 * kBorderInset - 2 * kMarginInset,stringSize.height);

[textToDraw drawInRect:renderingRect
withFont:font
lineBreakMode:UILineBreakModeWordWrap
alignment:UITextAlignmentLeft];
}

任何帮助将非常感激!


<我不知道为什么,但是,在一个应用程序,我涉及到我们有这个问题,一旦我们从使用开放类型字体切换到真正的类型字体刚刚工作。


I am drawing a PDF file and cannot figure out how to embed the font into the PDF itself, could anyone help me out? It displays fine on the device however once it is emailed out or printed via AirPrint I just get the fallback font. Here is my code...

- (void) drawChart{
CGContextRef    currentContext = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(currentContext, 0.0, 0.0, 0.0, 1.0);


NSUserDefaults *data = [NSUserDefaults standardUserDefaults];
NSString *pChart1 = [data stringForKey:@"pchart1"];


NSString *textToDraw = [NSString stringWithFormat:@"%@",pChart1];

UIFont *font = [UIFont fontWithName:@"MyFont" size:14];

CGSize stringSize = [textToDraw sizeWithFont:font
                           constrainedToSize:CGSizeMake(pageSize.width - 2*kBorderInset-2*kMarginInset, pageSize.height - 2*kBorderInset - 2*kMarginInset) 
                               lineBreakMode:UILineBreakModeWordWrap];

CGRect renderingRect = CGRectMake(kBorderInset + kMarginInset, kBorderInset + kMarginInset + 50.0, pageSize.width - 2*kBorderInset - 2*kMarginInset, stringSize.height);

[textToDraw drawInRect:renderingRect 
              withFont:font
         lineBreakMode:UILineBreakModeWordWrap
             alignment:UITextAlignmentLeft];
}

Any help would be much appreciated!

解决方案

I have no idea why, but, on an application I was involved in we had this problem, once we switched from using an open type font to true type font it just worked.

这篇关于IOS嵌入字体在PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆