Saving NSView Content As A PDF

Discussion in 'Mac Programming' started by Blakeasd, May 10, 2011.

  1. macrumors 6502a

    Joined:
    Dec 29, 2009
    #1
    Hello,
    I am attempting to save the contents from an NSView to a PDF file at the resolution 1920x1200. I found the method:
    Code:
    dataWithPDFInsideRect:
    
    I got the data from the view saved to a NSData object. My question is how do I save and open the file at 1920x1200 now that I have the NSData object with the PDF data.
    Thanks
     
  2. macrumors 68000

    Sydde

    Joined:
    Aug 17, 2009
    #2
    from the documentation for that method:
    NSImage is the easiest way to handle displaying a PDF. You can set the size of the NSImage in the image itself or draw the image into a rect if the size you want. Just initialize the NSImage with the data you saved. What could be simpler?
     
  3. thread starter macrumors 6502a

    Joined:
    Dec 29, 2009
    #3
    I know how to save it as an NSImage but how do I save it as a PDF to the Desktop or a Folder? My project is Document-Based but I'm not sure about what method I should use.
     
  4. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #4
    The NSData object should contain the bytes of the PDF file. Try sending it one of the writeToFile or writeToURL messages.
     

Share This Page