Errores al crear un archivo PDF en la aplicación MAC OS X

This is first time I am trying to play with PDF Creation. I am using this in my MAC OS X application. I would like to give my users the ability to export data in PDF file. I googled around to find a solution and came up with following code.

I am getting following error messages.

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)

Does anyone have a simple working example of Create PDF in MAC OS X? Can you also let me know how do you initialise CFURLRef to save to documents on MAC? Thanks

My Create PDF function:

- (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);
    }
}

preguntado el 10 de marzo de 12 a las 12:03

This looks like it's everything except determining where to put the data (CopySaveLocation) and drawing the graphics to the image (DrawImageToExport). Are you using this in an app, a command line program? -

I am using this in my MAC OS X application. I would like to give my users the ability to export data in PDF file. -

For an app, look at NSSavePanel for getting the URL, and add your own routine to draw replacing DrawImageToExport. -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.