SWT Cocoa PrintPreview problems

40 views
Skip to first unread message

Nick

unread,
Apr 25, 2010, 2:55:30 PM4/25/10
to SWT PaperClips
Hi. I'm trying to use PaperClips with SWT Cocoa. I'm using the code
from the Paperclips Article (http://hexapixel.com/2009/09/18/printing-
swt-tables-with-paperclips), but also tried it outside of that code
base using only a modified version of the PrintPreviewDialog.

The code works fine in Linux, but with Mac Cocoa (both 32 and 64 bit
versions), the preview dialog shows an empty area where the document
should be. I can print the document, but the preview portion never
displays.

I assume that the problem is not with Paperclips, but with SWT Cocoa.
However, I was wondering if anyone had any thoughts as to where to
start looking? Could this be a problem with SWT Cocoa GC? or the
Canvas? or even with PaperClips PrintPreview widget?

Thanks for any assistance.
Nick

--
You received this message because you are subscribed to the Google Groups "SWT PaperClips" group.
To post to this group, send email to swt-pap...@googlegroups.com.
To unsubscribe from this group, send email to swt-paperclip...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swt-paperclips?hl=en.

Matthew Hall

unread,
Apr 26, 2010, 3:39:59 PM4/26/10
to swt-pap...@googlegroups.com
I suspect this has to do with how PrintPreview achieves WYSIWYG: the printer is instantiated, then we create an image the size of the preview on the printer instance and render the page onto that Image. We then grab the ImageData from the image and create a copy on the Display side.  Then we render the display image to the display.

My guess is that the rendering to the printer Image is not working.

Matthew



-- Sent from my Palm Pre


Fabian

unread,
May 13, 2010, 12:54:01 PM5/13/10
to SWT PaperClips
Hi all,
I'm having the same problem, the printPreview works fine on windows
and linux, but it fails on mac.

I've noticed that if I don't have any printer configured on the mac
then the printPreview dialog appears and the print image is empty. If
I define a printer, the printPreview dialog doesn't even show and I
get this exception:

java.lang.NullPointerException
at org.eclipse.swt.printing.Printer.internal_new_GC(Printer.java:307)
at org.eclipse.swt.graphics.GC.<init>(GC.java:169)
at org.eclipse.swt.graphics.GC.<init>(GC.java:132)
at net.sf.paperclips.ui.PrintPreview.getGC(PrintPreview.java:507)
at net.sf.paperclips.ui.PrintPreview.fetchPages(PrintPreview.java:
535)
at net.sf.paperclips.ui.PrintPreview.getPageCount(PrintPreview.java:
188)
at
it.ansa.one.gui.ui.print.PrintPreviewDialog.updatePageNumber(Unknown
Source)
at
it.ansa.one.gui.ui.print.PrintPreviewDialog.createDialogArea(Unknown
Source)

I'll try to investigate the problem, did you already find a solution
for this?

Thanks,
Fabian

On 26 Apr, 21:39, "Matthew Hall" <matth...@woodcraftmill.com> wrote:
> I suspect this has to do with how PrintPreview achieves WYSIWYG: the printer is instantiated, then we create an image the size of the preview on the printer instance and render the page onto that Image. We then grab the ImageData from the image and create a copy on the Display side. &nbsp;Then we render the display image to the display.
>
> My guess is that the rendering to the printer Image is not working.
>
> Matthew
>
> -- Sent from my Palm Pre
> On Apr 25, 2010 12:55 PM, Nick &lt;n...@transparentech.com&gt; wrote:
>
> Hi. I'm trying to use PaperClips with SWT Cocoa. I'm using the code
>
> from the Paperclips Article (http://hexapixel.com/2009/09/18/printing-
>
> swt-tables-with-paperclips), but also tried it outside of that code
>
> base using only a modified version of the PrintPreviewDialog.
>
> The code works fine in Linux, but with Mac Cocoa (both 32 and 64 bit
>
> versions), the preview dialog shows an empty area where the document
>
> should be.  I can print the document, but the preview portion never
>
> displays.
>
> I assume that the problem is not with Paperclips, but with SWT Cocoa.
>
> However, I was wondering if anyone had any thoughts as to where to
>
> start looking? Could this be a problem with SWT Cocoa GC? or the
>
> Canvas?  or even with PaperClips PrintPreview widget?
>
> Thanks for any assistance.
>
> Nick
>
> --
>
> You received this message because you are subscribed to the Google Groups "SWT PaperClips" group.
>
> To post to this group, send email to swt-pap...@googlegroups.com.
>
> To unsubscribe from this group, send email to swt-paperclip...@googlegroups.com.
>
> For more options, visit this group athttp://groups.google.com/group/swt-paperclips?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "SWT PaperClips" group.
> To post to this group, send email to swt-pap...@googlegroups.com.
> To unsubscribe from this group, send email to swt-paperclip...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/swt-paperclips?hl=en.

Nicholas Rahn

unread,
May 21, 2010, 9:31:57 AM5/21/10
to swt-pap...@googlegroups.com
Hi. No I haven't had much luck in finding a solution. I never tried
either with a printer configured so I've never seen the NPE before.

My workaround has been to generate my document with iText and open it
in the platform default PDF viewer. The user can print it from there.

Cheers,
Nick

Matthew Hall

unread,
May 21, 2010, 3:23:34 PM5/21/10
to swt-pap...@googlegroups.com
If you're trying to write PDFs then iText is the right solution.


Matthew

-- Sent from my Palm Pre

Reply all
Reply to author
Forward
0 new messages