Need to be able to create an nsIPrintSettings from Script




17 years ago
15 years ago


(Reporter: rods, Assigned: rods)


Windows 2000

Firefox Tracking Flags

(Not tracked)




17 years ago
It seems like it might be help to provide an implementation of nsIPrintSettings, 
that could also be created from script


17 years ago
Target Milestone: --- → mozilla1.0


17 years ago
Target Milestone: mozilla1.0 → mozilla1.0.1
XPCOM objects are implementable in JS, anyone could today implement a object
that has the properties and methods that nsIPrintSettings defines and pass that
from JS through XPConnect into a C++ method expecting a nsIPringSettings. I'm
not sure this is something that's common enough to need a scriptable
implementation, but maybe I'm wrong.

Comment 2

17 years ago
Given that the purpose of XUL is to allow rapid XP application development, it 
seems to me that simple scripted access to ALL printing functionality must be 
available for UI developers.   

I would have thought that simple script access to all printing apis must be 
essential for XUL to be become a RAD environment?

My main concern/requirenment  is how to issue 'transient' print 
command/settings via script which may or may not be required to update prefs.

Comment 3

17 years ago
Can you clarify a simple example?

Assuming that orientation can be modified via nsPrintSettings, and that the 
default orientation is portrait, 

 would a XUL script via a scriptable nsPrintSetting allow a document to be 
printed in landscape, WITHOUT changing the default setting of portrait? 

In otherwords is there some kind of 'transient' request option?


17 years ago
Priority: -- → P1
Target Milestone: mozilla1.0.1 → Future

Comment 4

16 years ago
this no works
Last Resolved: 16 years ago
Resolution: --- → WORKSFORME

Comment 5

16 years ago

Comment 6

16 years ago
Please please can you provide  a couple of javascript examples of dialog-box-
less print setting commands ?

a) the command syntax to turn silent printing on/off
b) the command syntax to change landscape to portrait, etc

Ive temporaily reopended this in the absence of documentation explaining how 
this is done.
Resolution: WORKSFORME → ---

Comment 7

16 years ago

In fact examples of how to

a) turn silent printing on/off
b) setting the running header and footer text (page numbering)

would be more useful. 


Comment 8

16 years ago
PS In other words are there features such as page numbering style (e.g. 
numeric, roman, etc ) which are available via nsPrintSettings but not included 
in the sample page setup dialog?

Is silent printing one of these printsetting options and if so what is it 


Comment 9

16 years ago
You cannot control any of these from a web page, being able to create a
PrintSettings object is only available in JS for the UI. 

Some of this functionality will be available via CSS styling see Bug 115199.

Also, being able to print silently will be available via a pref (see Bug 104501)
Last Resolved: 16 years ago16 years ago
Resolution: --- → FIXED

Comment 10

16 years ago
Many thanks for reply

A problem with bugzilla admin is that similar earlier bugs reports get closed 
off with no reference to any superceding reference ( see #61580 silent printing 
for script and the earlier #17141 report)

PS I have no interest in using web pages for page settings only in building 
UI's (i.e. XUL IFRAME + javascript )

PPS As requested ,I have filed (yet again) a request for javascript printing of 
XUL IFRAME content (#159900). .... although the original request goes back at 
least 2 years  (#61580 + #70950)

Comment 11

15 years ago
After searching for a solution for printing using the javascript print(); 
command WITHOUT creating a print dialog box I finally found a solution. I 
couldn't find any information online, so I thought I would put it here for the 
next guy. 

We are creating an application using LINUX/MySQL/PHP/Apache. The application 
runs on a dedicated box and is used by customers. We have successfully removed 
all of the dialog boxes, but the print dialog box kept popping up every time 
the user hit our javascript window.print() button. This created a probelm of 
professionalism in the interface. After much searching, we discovered that the 
talented team at has already solved this problem, but there were no 
instructions on how to make it work. 

All you need to do, is set a preference up on the CLIENT BROWSER, you can't do 
this through the web, you must have direct access to the local browser. If 
people could do this through the web, every porn popup in the world would come 
streaming through the printer. 

Go to about:config (Type this in the address bar) 

Right click on any preference and select "NEW" > "BOOLEAN" IMPORTANT: DO NOT 
SELECT STRING or NUMERIC as this will not work if you are an idiot (like me) 
and select "STRING" 

type: print.always_print_silent 

Hit OK 

type: true 

Restart the browser. This writes a line to the prefs.js file (on windows) (or 
the user.js file on Linux?) the next time you start the browser, any javascript 
print(); command will print directly to the printer using the currently 
configured print settings. The exact syntax is: 

<a href="#" OnClick="window.print();">PRINT THIS WINDOW</a> 

I hope that this helps someone else, as we had much trouble tracking this down. 
The following are key words to help the next guy find this: 

mozilla silent printing 
silent print 
javascript print without dialog mozilla 
printing without dialog box
You need to log in before you can comment on or make changes to this bug.