Re: PDF on a NSView
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 */);
}
}
References: | |
| >PDF on a NSView (From: "Lizardo H. C. M. Nunes" <email@hidden>) |