• 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
Re: PDF on a NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PDF on a NSView


  • Subject: Re: PDF on a NSView
  • From: Stéphane Sudre <email@hidden>
  • Date: Wed, 9 Jan 2002 15:53:33 +0100

On Wednesday, January 9, 2002, at 03:08 PM, Lizardo H. C. M. Nunes wrote:

Hi,

Is it possible to render a PDF file on a NSView? I hope you can help me or point me to the proper documentation.

I'm using the graph application (plotutils, gnu package) to visualize simple data on Mac OS X / XDarwin. Alternatively, a PS file can be created and translated to a PDF one; that's why I want to know how I could render a PDF file on a NSView (if possible).

Didn't check the code or run it but something like this could work. I'm quite sure there's an easier solution.

#include <ApplicationServices/ApplicationServices.h>

- (void) loadPDFFileWithURL:(NSURL *) inURL
{
document_=CGPDFDocumentCreateWithURL((CFURLRef) inURL);
}

- (void) drawRect:(NSRect) aRect
{
if (document_!=NULL)
{
NSGraphicsContext *graphicsContext;
CGContextRef windowContext;
CGRect cgRect;
NSRect tRect=[self frame];

graphicsContext = [NSGraphicsContext currentContext];
windowContext = [graphicsContext graphicsPort];

cgRect=CGRectMake(tRect.origin.x, tRect.origin.y, tRect.size.width, tRect.size.height);
CGContextDrawPDFDocument(windowContext, cgRect,document_,0 /* or 1 maybe */);
}
}


  • Follow-Ups:
    • Re: PDF on a NSView
      • From: email@hidden
    • Re: PDF on a NSView
      • From: Ali Ozer <email@hidden>
References: 
 >PDF on a NSView (From: "Lizardo H. C. M. Nunes" <email@hidden>)

  • Prev by Date: PDF on a NSView
  • Next by Date: Re: Database
  • Previous by thread: PDF on a NSView
  • Next by thread: Re: PDF on a NSView
  • Index(es):
    • Date
    • Thread