• 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
oddball WebKit printing issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

oddball WebKit printing issues


  • Subject: oddball WebKit printing issues
  • From: "Jim Thomason" <email@hidden>
  • Date: Thu, 18 Jan 2007 15:14:52 -0600

Okay, I'm stumped. I did go with the approach of stuffing my tabular
data into an HTML page and using webkit to render and print it. I've
got two issues.

(1) I'm using stylesheets for the lines around the cells (td {
border-left : 1px solid black; border-bottom : 1px solid black;} ),
but the lines don't display in my previewed page (or when I print). I
know that the stylesheet is linking up properly, since everything else
from it properly displays.

Further, the enclosing table object uses borders as well (table
{border-right : 1px solid black; border-top : 1px solid black}) and
those -do- render. Heck, I'm even careful to flip on backgroundImage
printing, and the row colors are properly showup. It's just the lines,
just at the table cell level.

Finally, if I save the HTML externally and point to the same
stylesheet, it displays properly in Safari, and the print preview does
draw the lines.

(2) Even weirder, the NSPrintOperation doesn't work unless I try to
call print on the WebView itself in advance. here's the code:

	WebView* printView = [[WebView alloc] init];

	WebPreferences* printPreferences = [printView preferences];
	[printPreferences setShouldPrintBackgrounds:YES];
	[printPreferences setUserStyleSheetEnabled:YES];
	[printPreferences setUserStyleSheetLocation:[NSURL
fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"print"
ofType:@"css"]]];

	[printView setPreferences:printPreferences];

	[[printView mainFrame] loadHTMLString:printString baseURL:nil];

	NSLog(@"TRIES PHONY PRINT");
	[printView print:sender];
	NSLog(@"TRIED PHONY PRINT");

	NSView* docView = [[[printView mainFrame] frameView] documentView];

	NSPrintInfo* printInfo = [NSPrintInfo sharedPrintInfo];

	[printInfo setTopMargin:15.0];
	[printInfo setBottomMargin:15.0];

	[printInfo setHorizontallyCentered:YES];
	[printInfo setVerticallyCentered:NO];

	NSPrintOperation* printOperation = [NSPrintOperation
printOperationWithView:docView printInfo:printInfo];
	//[printOperation setShowPanels:YES];
	BOOL ran = [printOperation runOperation];
	NSLog(@"RAN IT %d", ran);

	[printView release];

In the middle there is a call (surrounded by NSLog statements) that
does a [printView print:sender]. This operation fails with this error:

No pages from the document were selected to be printed

However, the printOperation will then run successfully with
runOperation is called later on. If I remove the junk call to
[printView print:sender], the printOperation doesn't run and always
returns false.

I've gotta assume that the first print call sets up...something that
the printOperation then uses to succeed, and without it, the operation
fails, but bugger all if I know what it is.


Any help would be greatly appreciated.

Thanks,

-Jim.....
_______________________________________________

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: oddball WebKit printing issues
      • From: glenn andreas <email@hidden>
  • Prev by Date: custom icon in window title bar
  • Next by Date: Re: zip files
  • Previous by thread: custom icon in window title bar
  • Next by thread: Re: oddball WebKit printing issues
  • Index(es):
    • Date
    • Thread