Printing to CutePDF Causes Strange Behavior

55 views
Skip to first unread message

craigotis

unread,
Feb 24, 2010, 1:42:02 PM2/24/10
to SWT PaperClips
To start, I'd like to say thanks Matt for the great printing library.
It has been a great help to our coders.

One issue that we have encountered is strange behavior when printing
to the CutePDF writer. In many applications, printing to CutePDF will
present the user with the standard "Save As..." dialog, allowing the
user to select location, filename, and file type. (Including PDF,
which is A Good Thing.)

Our code:

PrintDialog dialog = new PrintDialog(tree.getShell(), SWT.NONE);
PrinterData printerData = dialog.open();
if (printerData != null) { // Will be null if 'Cancel' clicked
Printer printer = new Printer(printerData);

// ... Build a Print object

PrintJob printJob = new PrintJob("...", pagePrint);
PaperClips.print(printJob, printer);
}

When executed, will display the standard print dialog, allowing users
to select CutePDF. When confirming the print options however, instead
of being presented with the usual "Save As..." dialog, a simple Dialog
with title "Print to File" is shown, with a single text field asking
for an "Output File Name." Upon manually typing an output file name, a
*PostScript* file is created at this location. Is this an issue with
our code above, or is it an incompatibility with Paperclips and
CutePDF?

I have been unable to find any reference to this issue in the forums
or in the examples, which (are very well written, I should add) we are
following diligently.

Thanks,
Craig

Matthew Hall

unread,
Feb 24, 2010, 11:24:08 PM2/24/10
to swt-pap...@googlegroups.com
craigotis wrote:
> PrintDialog dialog = new PrintDialog(tree.getShell(), SWT.NONE);
> PrinterData printerData = dialog.open();
> if (printerData != null) { // Will be null if 'Cancel' clicked
> Printer printer = new Printer(printerData);
>
> // ... Build a Print object
>
> PrintJob printJob = new PrintJob("...", pagePrint);
> PaperClips.print(printJob, printer);
> }
>
I'm not familiar with CutePDF--at my work everybody uses PDFCreator
which works a little differently.

I'm not sure if it will make a difference but one thing I notice is that
you are creating a Printer instance which is unnecessary. You can pass
the PrinterData to PaperClips.print and it will create and dispose a
printer internally.

If that doesn't help, send some screenshots of the dialogs you see so I
can get an idea what you're looking at.

Matthew

craigotis

unread,
Feb 26, 2010, 4:46:13 PM2/26/10
to SWT PaperClips
Hey Matt,

Thanks for the reply, unfortunately leaving the Printer creation to
PaperClips results in the same behavior. I'll email you two
screenshots, the first of which shows the dialog presented using
PaperClips, the second shows the dialog presented when printing from a
webpage in Chrome. (Simply Ctrl+P)

I'm wondering if this is an issue in SWT, as the PrintDialog class
appears a bit differently from the dialog presented in other
applications.

Thanks,
Craig

craigotis

unread,
Mar 5, 2010, 12:59:13 PM3/5/10
to SWT PaperClips
Thanks again to Matt for all his help. Leaving the "Print to File"
checkbox unchecked in the SWT PrintDialog allowed us to save straight
to PDF.

Craig

Reply all
Reply to author
Forward
0 new messages