Morning,
I’ve started to work on a print feature of an app I’m developing.
When I use ‘g = OpenPrinterDialog(Nil, mainWindow)’ the dialog displays but the look of it is a bit different from Safari for example.
Safaris dialog has the PageSize properties and stuff I only get from the PageSetupDialog.
Is there a way to get the same print dialog as Safari from a Xojo app?
This way I could skip the PageSetupDialog as it would not be necessary
That depends on how you implement it.
If you have a Cocoa app with a document, the NSDocument class provides a preview in print dialog.
As OpenPrinter function in Xojo doesn’t do that, you see a dummy page with a one.
Thanks.
But I was more looking at the Page Size, Page Orientation and Scale settings in the Safari dialog.
You think I can get them to show in the OpenPrinterDialog? The preview isn’t that important to me
[quote=273555:@Christian Schmitz]That is page setup dialog.
You get it by using PageSetupDialog function on PrinterSetup class.[/quote]
I know
My goal here is NOT to use the PrinterSetupDialog. Safari doesn’t have one as these settings are in the OpenPrinterDialog instead.
If I’m not misunderstanding something here
I wrote a quick tutorial in an issue of xDev mag, but the complete process requires considerable amounts of work. Because the NSView printing uses the drawRect event from the NSView, it’s possible to use Xojo functions to print, however if your printing is a little bit more complicated, you’ll have to use pure Core Graphics.
I was hoping to write a full blown tutorial for xDev mag, but the requirement of CG held it back, as it would require most people to re-write their entire print solution, just for this dialog.
You can also inject views into the dialog, like in our example we’ve inject a view that allows the user to set some print options.
Thanks Sam
I guess I’ll just stick with both dialogs then as it seems to be a bit more work than I’m willing to put into it right now.
Have a great day guys!
I looked through your site and through the MBS examples but there seem to be no practical example about how one would use that plugin to create a printerSetup and the graphics object to print to.
Basically, what would be required to obtain the same as the picture Sam posted ?
the way cocoa paints is to have a view draw itself on the page.
So you would use maybe a Canvas and run the NSPrintOperationMBS on it’s NSViewMBS.
I didn’t try it, but if needed I can check that the next days. Email me.
This should be interesting… I could probably extract a demo project over the weekend; but you’d need to convert your drawing commands over to CG to get the benefit (at least from my experience).
Core Graphics is resolution less, so if you draw to a bitmap and then to Core Graphics you’ll lose resolution when printing.
You can do some basic printing (as the article demonstrates), but for our card program it had to be converted to CG. For some bizarre reason Xojo doesn’t quite align correctly while CG did, at least that’s what I recall.
It was a lot of hassle; I rather stupidly thought that if I tried my hardest to make a great Mac application; Apple might promote it, as opposed to the clone apps written in QT which look like bad Windows apps. Turns out I’m wrong, Apple quite likes fat apps written in QT that look like something from Windows 3.11 days, especially when they don’t even do Retina properly.
Hi Christian, I’ve tried NSPrintOperation.xojo_binary_project in plugins MBS 164 examples, but the Print Dialog doesn’t show the orientation choice (portrait/landscape)
Is there a way ?