Search code examples
macoscocoaxcode4pdfview

How to use PDFView in cocoa app?


I am working on cocoa now a days so, little bit new to mac development.
I want to open a PDF from my server. Is this possible with PDFView?
If anyone guide me in this then it will be very helpful for me.
Is there any sample code to open a PDF file in PDFView ?

Thanks in advance..!!!


Solution

  • I got answer..

    at least working for me.. :)

    NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"1.pdf" ofType:nil];
    NSURL *url = [NSURL fileURLWithPath:urlStr];
    PDFDocument *pdfDoc = [[PDFDocument alloc] initWithURL:url];
    [pdfView setDocument:pdfDoc];