• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
C *char representation of PDF into NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C *char representation of PDF into NSImage


  • Subject: C *char representation of PDF into NSImage
  • From: Eric Brown <email@hidden>
  • Date: Sun, 25 Feb 2007 11:08:49 -0600

Dear Cocoa Developers,

Pardon my newbie question (I'm from the Fortran world), but here we go! I have a function that returns a PDF representation of a graphic:

int pdfbuf( *char, int length )

What I would like to do is get this into a format that NSImage can display into an NSView. I can get PNG files, etc. into the NSView so I think that is working.

One issue that I have is that I don't know the length of the representation until later in the function, so I'm doing some alloc/ init stuff. Here is what I have so far:


-(void) awakeFromNib { int PDFDataLength; NSMutableData *PDFData; char *PDFbuffer; char *oneChar=" ";

    NSPDFImageRep *pdfImage;

// obtain length of "%PDF...." The returned number is around 15000.
PDFDataLength=pdfbuf(oneChar,0);


    // I've seen this method used for floats, ints, etc.
    PDFData  =[[NSMutableData alloc]
                    initWithCapacity: (unsigned int) PDFDataLength];
    PDFbuffer=[PDFData mutableBytes];

    // Here I try to slurp in the data
    PDFDataLength=pdfbuf(PDFbuffer, PDFDataLength);


// I'm not sure if this is relevant yet! pdfImage=[[NSPDFImageRep alloc] initWithData: PDFData]; image=[[NSImage alloc] initWithData: PDFData];

}

At the end, I get: Failed to find PDF header: `%PDF' not found. I went to the debugger, and I saw that PDFbuffer seemed to be associated with the PDF contents, but the other stuff doesn't seem to work.

Can anyone see my problem?

Thanks a lot,

Eric




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: C *char representation of PDF into NSImage
      • From: Marcel Weiher <email@hidden>
  • Prev by Date: Re: window background color issue?
  • Next by Date: Re: Any way to tell if a pointer is an object?
  • Previous by thread: Re: window background color issue?
  • Next by thread: Re: C *char representation of PDF into NSImage
  • Index(es):
    • Date
    • Thread