Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 4, 2007, 12:18 PM   #1
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
[SOLVED] Printing problems with Cocoa

I have been trying to add printing to D&D Manager, so that you can print off information about the characters. I have created a view for printing, which seems to print fine except that half my labels are in the wrong place. The first attachment is the view in Interface Builder, and the second is the PDF "print".

The Image from IB:
Click image for larger version

Name:	Picture 1.png
Views:	56
Size:	91.5 KB
ID:	90210
The Output:
PDF Output.pdf

The code I am using for printing in MyDocument.m is:

Code:
-(IBAction)printDocument:(id)sender{
	[printInfo setOrientation:NSLandscapeOrientation];
	//probably not do the following.
	[printInfo setLeftMargin:36];//1.25cm
	[printInfo setRightMargin:36];//1.25cm
	[printInfo setTopMargin:28];//1cm
	[printInfo setBottomMargin:28];//1cm
	[self printDocumentWithSettings:[printInfo dictionary] showPrintPanel:YES delegate:self didPrintSelector:nil contextInfo:NULL];
}
- (NSPrintOperation *)printOperationWithSettings:(NSDictionary *)printSettings error:(NSError **)outError{
	if(quickPrint==nil){
		quickPrint=[[QuickPrintController alloc] init];
	}
	NSManagedObject *obj=[[[appController characterController] selectedObjects] objectAtIndex:0];
	//NSLog(@"character printing=%@",[obj valueForKey:@"name"]);
	[quickPrint setSelectedCharacterToCharacter:obj];
	NSPrintOperation *op=[quickPrint printOperation];
	[op setPrintInfo:[[[NSPrintInfo alloc] initWithDictionary:printSettings] autorelease]];
	return op;
}
QuickPrintController contains the printing view and the line:
Code:
return [NSPrintOperation printOperationWithView:quickPrintView];
The full project can be downloaded here.

I am using Xcode 3.0 on Mac OS X 10.5.0, but the issue seemed to occur even when I built my code on Tiger (10.4.10) with Xcode 2.4.

Last edited by Eraserhead; Nov 5, 2007 at 02:37 AM.
Eraserhead is offline   0 Reply With Quote
Old Nov 4, 2007, 10:09 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
I didn't download the project, but the only reason I can think of that the form fields would be moving is because the autoresizing masks haven't been properly setup?
kainjow is offline   0 Reply With Quote
Old Nov 5, 2007, 02:37 AM   #3
Eraserhead
Thread Starter
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
Quote:
Originally Posted by kainjow View Post
but the only reason I can think of that the form fields would be moving is because the autoresizing masks haven't been properly setup?
That looks like the reason, they are different for the different elements, and given the new IB I didn't notice. Thanks .
__________________
If they have to tell you every day they are fair you can bet they arent, if they tell you they are balanced then you should know they are not - Don't Hurt me
Eraserhead is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Need help thinking of Essay topic - Solving world problems with technology ghking Community Discussion 7 Jun 13, 2013 07:46 AM
Problem with Cocoa Gui Application on Mac 10.6.4 pkmk Mac Programming 3 Apr 14, 2011 07:00 AM
Help solve sync problem with Outlook 2011 and AOL Big D 51 Mac Applications and Mac App Store 5 Jan 20, 2011 07:36 PM
MBP overheating... solving the problem with iLap? 11miles MacBook Pro 2 Jan 28, 2009 01:58 PM
Problem with Cocoa Bindings saving-loading. Help! Soulstorm Mac Programming 18 Oct 26, 2006 04:56 PM


All times are GMT -5. The time now is 11:20 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC