• 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
Printing with exotic margins (a basic example)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Printing with exotic margins (a basic example)


  • Subject: Printing with exotic margins (a basic example)
  • From: "Ewan Delanoy" <email@hidden>
  • Date: Thu, 10 May 2007 09:28:19 +0200 (CEST)
  • Importance: Normal

                   Hello all,

  the (rather simple) code below produces a blank page instead of the
expected yellow rectangle. Is it a bug or have I done something wrong ?
(the point of this example is to test printing with exotic margins)

/*Contents of file YellowView.h */
#import <Cocoa/Cocoa.h>
@interface YellowView : NSView {}
@end
/*Contents of file YellowView.m */
#import "YellowView.h"
@implementation YellowView
- (void)drawRect:(NSRect)rect {
	[[NSColor yellowColor] set];
	[NSBezierPath fillRect:rect];
}
-(BOOL) knowsPageRange: (NSRange*) pageRange
{
    pageRange->location=1;
	pageRange->length=1;
	return YES;
}
-(NSRect)pageRectForPageNumber:(int)pageNumber
{
   return [self bounds];
}
@end
/*Contents of file MyDocument.h*/
@class YellowView;
@interface MyDocument : NSDocument{
     IBOutlet YellowView* yellowView;
}
/*Contents of file MyDocument.m*/
#import "MyDocument.h"
#import "YellowView.h"

@implementation MyDocument
- (void)printShowingPrintPanel:(BOOL)flag
{
	NSPrintInfo *pi = [self printInfo];
	NSPrintOperation *printOp;
	[pi setPaperSize:NSMakeSize(595,842)];
	[pi setTopMargin:190.00];
	[pi setBottomMargin:56.00];
	[pi setLeftMargin:0.00];
	[pi setRightMargin:0.00];
	printOp = [NSPrintOperation printOperationWithView:yellowView
											 printInfo:pi];
	[printOp setShowPanels:flag];
	[self runModalPrintOperation:printOp
						delegate:nil
				  didRunSelector:NULL
					 contextInfo:NULL];

}
- (NSString *)windowNibName
{
  return @"MyDocument";
}
@end

      On runtime, the main window displays a yellow view as expected, but
when I ask the app to print it, it produces a blank page.

                                                          Ewan


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Printing with exotic margins (a basic example)
      • From: Brian Stern <email@hidden>
    • Re: Printing with exotic margins (a basic example)
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: Place for app version value in document wrapper
  • Next by Date: Re: iSight Capture
  • Previous by thread: Re: Re: Objective-C/Cocoa reference manual
  • Next by thread: Re: Printing with exotic margins (a basic example)
  • Index(es):
    • Date
    • Thread