Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] [OSX Printing] GC(Printer) is disposed immediately after construction

I tried posting this question to the eclipse.platform.swt newsgroup but didn't get a response.

I am trying to use the PaperClips printing library to print on OSX, however I'm getting an error, the root cause of which is that GC.isDisposed() == true immediately after it is constructed. After some experimentation, we found that the GC behaves as expected if I call Printer.startJob() before constructing the GC. I thought this was odd since I've never had to do this on Windows. The javadocs do not seem to have an opinion one way or another on which approach is correct.

There's a reason for not wanting to start a print job when I create my GC: I need to be able to layout my document on the printer earlier than I'm ready to actually print it. The print preview control is one example of this: to preview the printout, I first have to capture the layout. To capture the layout, I need a GC so I can measure string extents.

I tried surrounding the layout code with calls to startJob() / cancelJob(), but found that this causes problems later when trying to print. It appears that a single Printer instance can not be reused for multiple print jobs on OSX. This has never been a problem on Windows, and the javadocs seem silent on this topic as well.

I can't tell if my code isn't following the proper printing protocol, if this is a bug in the OSX SWT implementation, or if it's due to a platform limitation in OSX. But I could sure use somebody's help to sort through this.

Matthew


Back to the top