views:

34

answers:

0

Hello guys!

Here's my code to create a PDF file from a CGPDFPageRef.

+ (void)createPDFFromPDFPage:(CGPDFPageRef)page withFilename:(NSString *)filename {
    CGRect pageRect = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);

    CFStringRef path = CFStringCreateWithCString (NULL, [filename UTF8String], kCFStringEncodingUTF8);
    CFURLRef url = CFURLCreateWithFileSystemPath (NULL, path, kCFURLPOSIXPathStyle, 0);
    CFRelease (path);

    CFMutableDictionaryRef myDictionary = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    CFDictionarySetValue(myDictionary, kCGPDFContextCreator, CFSTR("co"));

    CGContextRef pdfContext = CGPDFContextCreateWithURL(url, &pageRect, myDictionary);
    CFRelease(myDictionary);
    CFRelease(url);

    CGContextBeginPage(pdfContext, &pageRect);
    CGContextSaveGState(pdfContext);
    CGContextDrawPDFPage(pdfContext, page);
    CGContextRestoreGState(pdfContext);
    CGContextEndPage (pdfContext);
    CGContextRelease (pdfContext);
}

But I have problems with creating PDFs. There are some font types which cannot be created or I don't know what is the problem. Maybe you know and can help me. Here is the error message:

<Error>: FT_Open_Face failed: error 2.

Maybe can you help me please?

Edit:

Ok, guys. Here is a possible solution. Somehow de iphone-sdk doesn't support creating embedded fonts in PDFs. What do you think why? And how can I solve it?