创建pdf

 //创建pdf图形上下文
    NSString *path = [NSHomeDirectory() stringByAppendingString:@"/Documents/pdf.pdf"];
    NSLog(@"%@",path);
    UIGraphicsBeginPDFContextToFile(path, CGRectZero, nil);
//    CGContextRef context = UIGraphicsGetCurrentContext();
    //创建pdf中某一页
    UIGraphicsBeginPDFPage();
    UIImage *image = [UIImage imageNamed:@"1.png"];
    [image drawInRect:CGRectMake(0, 0, 200, 200)];
    NSString *str = @"上海宝山";
    [str drawInRect:CGRectMake(0, 220, 200, 100) withAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:30],NSForegroundColorAttributeName:[UIColor redColor]}];
    UIGraphicsEndPDFContext();

 

posted on 2015-09-13 20:19  Baymax01  阅读(155)  评论(0编辑  收藏  举报

导航