Bug 4851 - Print ignores print to file option (1GKXC30)
Summary: Print ignores print to file option (1GKXC30)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0   Edit
Hardware: All Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Carolyn MacLeod CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 5126 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-10-11 14:24 EDT by Nick Edgar CLA
Modified: 2002-07-29 11:52 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Edgar CLA 2001-10-11 14:24:09 EDT
- open text file
- File / Print
- check Print to File, hit OK
- it tries to send it to the printer, and does not even prompt for a file

NOTES:

NE (10/1/2001 11:34:48 AM)
	Most likely an SWT bug, since TextViewer.print() just creates a Printer from the PrinterData returned by the PrintDialog.
Comment 1 DJ Houghton CLA 2001-10-29 16:43:36 EST
PRODUCT VERSION:
137

Comment 2 Mike Wilson CLA 2002-05-24 19:30:48 EDT
Has this been fixed? Pls, mark as either FIXED or LATER as appropriate.
Comment 3 Carolyn MacLeod CLA 2002-05-27 17:20:26 EDT
The file name to print to is supposed to be completely up to the application.
We didn't want SWT to gratuitously bring up a FileDialog. For example, what if 
the application wanted to specify the file name without asking the user?

So the original intent of the printing API was for the application to:
- check if the user set the "PrintToFile" bit (PrinterData.printToFile)
- if so, open a FileDialog and ask the user to choose a file name
- set the "fileName" field of the PrinterData to the user's chosen name
- then create the Printer using the PrinterData, and start the print job

However, having said that, I have discovered a little-used "feature" of Windows 
printing that will bring up a (very ugly) text-entry dialog if "Print To File" 
was selected and no filename was specified. I do warn you that this dialog is 
very ugly, and to be honest, I haven't seen anything like it in many years.  :)
If you prefer not to use the current printer API, I can turn on this feature 
(if McQ and Steve think it's ok) and you won't have to write any further code. 
However, I think you would probably prefer to bring up your own FileDialog and 
set the PrinterData's fileName field. Much prettier.

I guess I should turn on this feature in either case (as a default), because it 
is confusing to the user to have the file sent to the printer when they check
"Print To File". McQ, Nick - comments? Drop by to see the ugly text dialog.
Comment 4 Mike Wilson CLA 2002-05-28 09:00:29 EDT
I know what the "ugly"dialog looks like. I think it should be enabled, if we 
can easily do it. I also think that the javadoc needs to include the 
description of the right way to enable print to file, so well behaved 
applications don't need to use the ugly one.
Comment 5 Nick Edgar CLA 2002-05-28 10:21:56 EDT
SWT should at least give the ugly text dialog.
However, I don't see why the app needs to get involved here.
It would be better if SWT used a nice file dialog by default.
Deluxe would be to allow the app to override this if needed.
Comment 6 Carolyn MacLeod CLA 2002-05-28 11:47:01 EDT
The reason I think the app should get involved is because I think it's possible 
that some application might want to always use some hardcoded file name. Or 
maybe they have already asked the user for a filename and don't want to ask 
again. Or maybe they are running headless and they want to force the output to 
go to a file (to do this, they set the "printToFile" flag in the PrinterData as 
well as setting the "fileName" field - you don't need the PrintDialog at all). 
I just thought it was restrictive for us to bring up a FileDialog, even if it 
can be overridden.

I have released the "ugly" dialog and I will mark this PR fixed, but a new PR 
can be opened to consider changing the behavior post 2.0.

McQ, please verify.
Comment 7 Mike Wilson CLA 2002-05-28 12:01:53 EDT
Our code needs to ensure that people who relied on the old behavior will 
continue to work. We need to *detect* that the ugly dialog was activated 
and use the name from it only in that case.
Comment 8 Carolyn MacLeod CLA 2002-05-28 12:08:46 EDT
Yes, this case is covered.
Comment 9 Knut Radloff CLA 2002-07-29 11:52:29 EDT
*** Bug 5126 has been marked as a duplicate of this bug. ***