Re: Creating PDF from a view with custom bounds
Re: Creating PDF from a view with custom bounds
- Subject: Re: Creating PDF from a view with custom bounds
- From: email@hidden
- Date: Fri, 20 Jul 2001 19:15:41 +0200
Hi Brendan,
I guess you are trying to respond to me, but I wasn't in the receiver list.
Le jeudi 19 juillet 2001, ` 11:22, Brendan Younger a icrit :
I'm sorry, I'm completely confused. The bounds that you state would
make your image 2 pixels wide and 2 pixels tall which I doubt is the
case. I assume therefore that the numbers you quoted are scaling
factors.
Not at all. The frame of the view is (0,0)x(400,300), so 400 pixels wide.
The bounds are (-1,-1)x(2,2) (exactly (-1.4, -1.1)x(2.8, 2.2)) and these
are the internal (float) coordinate system of this view. That means that
if I draw a square with rect (-1,-1)x(2,2), it will almost fill the view.
Now the point is that doesn't work correctly with [NSPrintOperation
PDFOperationWithView]. When I call that as indicated in my method, the
drawRect method of the view is called with aRect = (0,0)x(1,1), that is
only 1/4th of the view.
I noticed that there are a number of NSView methods which are supposed to
work along with printing:
- (BOOL)knowsPageRange:(NSRangePointer)range
- (NSPoint)locationOfPrintRect:(NSRect)aRect
- (NSRect)rectForPage:(int)pageNumber
I implemented these, but NONE of them is actually called, not for
PDFOperationWithView or EPSOperationWithView as well. Did anyone has
success using these methods? Some of them are not documented.
Also I tried to pass a NSPrintInfo argument to PDFOperationWithView where
I did that before:
[printInfo setOrientation:NSLandscapeOrientation];
[printInfo setHorizontallyCentered:YES];
[printInfo setVerticallyCentered:YES];
but this didn't work.
For the moment, I managed to have the thing working by concatenating a
translation in the drawRect method, and changing the rect to the current
bounds, but it sound like a hack.
Also the EPS representation is still incorrect in many ways:
-- the drawing is not centered on the page (though it is now in the PDF);
it is not even completly contained in the page;
-- the PS code is very odd, with a lot of dictionaries, etc. Illustrator
complains it contains CMYK together with RGB (I don't use CMYK in my
drawings).
-- there is no Bounding box at all.
Seems to me that all this part (printing/PDF/EPS) is still very buggy and
incomplete in Cocoa...
Thomas Lachand-Robert
********************** email@hidden
The Commandant Project:
http://lachand.free.fr/
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.