Re: Generating a PDF file without a NSView
Re: Generating a PDF file without a NSView
- Subject: Re: Generating a PDF file without a NSView
- From: Stefan Jung <email@hidden>
- Date: Fri, 16 Nov 2001 20:35:11 +0100
Am Freitag den, 16. November 2001, um 06:42, schrieb David Adalsteinsson:
How can I create a PDF file (and EPS) without drawing it inside a
drawRect in NSView and then
using "dataWithPDFInsideRect/dataWithEPSInsideRect" on the view.
Why? Is there a special reason to avoid drawRect:?
Calling drawRect does not mean anything happens onscreen, as long as you
"lockFocus" on a view object that is not on screen.
For example:
NSImage *specImage;
specImage = [[NSImage alloc] initWithSize:[self bounds].size];
[specImage lockFocus];
[self drawRect:[self bounds]];
[specImage unlockFocus];
should do what you want.
I would like to be able to do something like:
Create an empty NSPDFImageRep/NSEPSImageRep
Connect it to a NSImage
draw into the NSImage using standard drawing command (lockFocus, ....,
unlockFocus)
extract the representation with NSPDFImageRep/NSEPSImageRep
Is this in the right direction? If so, what is the exact syntax for
lines 1 & 2.
Another example:
NSPDFImageRep *specImage = [[NSPDFImageRep alloc] initWith
Data:[self
dataWithPDFInsideRect:[self bounds]]];
"self" because this line is used in a method of your view class. If you
want to call it from within another class you need an explicit pointer.
Should I do this entirely differently.
With the information you gave us, the above examples should be
appropriate..
Any help appreciated.
David
Stefan Jung