在MAC OS X应用程序中创建PDF文件时出错

时间:2012-03-10 12:05:17

标签: objective-c pdf-generation quartz-2d

这是我第一次尝试使用PDF Creation。我在我的MAC OS X应用程序中使用它。我想让我的用户能够以PDF文件导出数据。我用Google搜索并找到了解决方案并提出了以下代码。

我收到以下错误消息。

Undefined symbols for architecture x86_64:
  "_CopySaveLocation", referenced from:
      -[AppDelegate CreatePDFFile:] in AppDelegate.o
  "_DrawImageToExport", referenced from:
      -[AppDelegate CreatePDFFile:] in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

有没有人在MAC OS X中有一个简单的创建PDF的工作示例?你能告诉我你如何初始化CFURLRef以保存到MAC上的文件?感谢

我的创建PDF功能:

- (void) CreatePDFFile:(CFURLRef) url
{

    // Ask the user where we should save the file.
    CFURLRef saveLocation = CopySaveLocation();
    if(NULL != saveLocation) {

        CGRect mediaBox = CGRectMake(0, 0, 576.0, 576.0);            // Create a dictionary to store our document attributes
        CFMutableDictionaryRef attributes =
        CFDictionaryCreateMutable(
                                  NULL, 3,
                                  &kCFTypeDictionaryKeyCallBacks,
                                  &kCFTypeDictionaryValueCallBacks);
        CFDictionaryAddValue(attributes, kCGPDFContextAuthor,
                             CFSTR("Scott Thompson"));
        CFDictionaryAddValue(attributes, kCGPDFContextTitle,
                             CFSTR("Sample PDF"));
        CFDictionaryAddValue(attributes, kCGPDFContextCreator,
                             CFSTR("CreatePDF Sample Code"));
        // Create a PDF Context that we will draw the graphics into
        CGContextRef pdfContext =
        CGPDFContextCreateWithURL(url,
                                  &mediaBox, attributes);
        CFRelease(attributes);
        // Begin a PDF page
        CGContextBeginPage(pdfContext, &mediaBox);


    DrawImageToExport(pdfContext, mediaBox.size);

        // End the PDF page
        CGPDFContextEndPage(pdfContext);
        // Finalize the PDF document
        CGContextRelease(pdfContext);
    }
}

0 个答案:

没有答案