• 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
Creating PDF from a view with custom bounds
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating PDF from a view with custom bounds


  • Subject: Creating PDF from a view with custom bounds
  • From: email@hidden
  • Date: Wed, 18 Jul 2001 21:54:40 +0200

I have a progblem while creating a PDF file from a view. I copied the code from the example code (see below the method used in my view). This actually creates a PDF file, but only with a part of the view.
It turns out that my view has custom bounds (something like [-1,-1]x[2,2]); it is important for the app to keep these bounds as they are. But when the PDF is created, it seems to put the point (0,0), which is basically the center of the view, in the lower left corner of the PDF. So I have only about 1/4 of the view -- even though the size of the PDF representation is the same as the size of the view. This look like my drawing have moved to the left and bottom...

So how is it possible to have the PDF representation correctly located?
Here is my code:

-(NSData*) PDFRepresentation {
NSRect frame = [self frame], bounds= [self bounds],
r =NSMakeRect(0.0, 0.0, 2*NSMaxX(frame), 2*NSMaxY(frame));

NSMutableData *pdfData = [[NSMutableData allocWithZone:[self zone]] init];
NSPrintOperation *printOp;

NSLog(@"%@ PDFRepresentation, frame = %@, bounds = %@, r = %@", self, NSStringFromRect(frame), NSStringFromRect(bounds), NSStringFromRect(r));

printOp = [NSPrintOperation PDFOperationWithView:self insideRect:r toData:pdfData];
[printOp setShowPanels:NO];

if ([printOp runOperation]) {
NSLog(@"%@ PDFRepresentation: Ok.", self);
[pdfData autorelease];
} else {
NSLog(@"%@ PDFRepresentation: FAILED.", self);
[pdfData release];
pdfData = nil;
}
return pdfData;
}



Thomas Lachand-Robert
********************** email@hidden
The Commandant Project: http://lachand.free.fr/
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.


  • Follow-Ups:
    • Re: Creating PDF from a view with custom bounds
      • From: Brendan Younger <email@hidden>
  • Prev by Date: Viewing all notifications on a system
  • Next by Date: POP3 and\or SMTP classes?
  • Previous by thread: Viewing all notifications on a system
  • Next by thread: Re: Creating PDF from a view with custom bounds
  • Index(es):
    • Date
    • Thread