There are two parts to the print dialog box on Windows. The first of these is part of the Windows API (Application Programming Interface). The API is a set of common code pieces that are held in the various DLL files that are part of the Windows. Any Windows program can (and should) call the API to perform common functions such as displaying the Print Dialog box so that it will work the same way in all programs and not have different options in different places the way the print option did back in DOS program days. The Print Dialog API also provides a common interface allowing all programs access to the same set of printer drivers rather than printer manufacturers having to create driver software for their printer for each individual program that wanted to use it. The printer drivers are the other half of the print dialog.
![]()
If a conversion program like Ghostscriptis available however, PrintFile can automatically make a conversion before sending the file to the printer. The program can also print Encapsulated PostScript Files (EPS). These files can normally only be inserted into documents and not be printed directly. It is also possible to control the positioning. RawPrint is a ibrary to send files directly to a Windows printer bypassing the printer driver, it can send PostScript, PCL or other print file types directly to a printer. To install this library on your project, you can use the NuGet package manager of Visual Studio.
There are several different languages that different printers understand that they use to control how the page prints (eg. PCL5 and Postscript). The printer driver instructs the Print API as to how to translate the standard internal print format that the operating system understands into the custom markup language that the specific printer understands. It also adjusts the options that the Print dialog displays to reflect the options offered by the specific printer. When you have a web page on the internet that your visitors are going to print, you have next to no information about what printer(s) they have available. Most printers around the world are configured to print out on A4 paper but you can't guarantee that the printer is set up to that default. One North American country uses a non-standard paper size that is shorter and wider than A4.
Most printers are set up to print out in portrait mode (where the narrower direction is the width but some may be set to the landscape where the longer dimension is the width. Of course, each and every printer also has different default margins at the top, bottom, and sides of the page even before the owners go in and change all of the settings to get the printer the way that they want.
![]()
Basic security says that if something like Javascript doesn't need to know about the operating system and browser configuration in order to manipulate the web page then it should not be provided with that information. It is not like Javascript ought to be able to change the printer settings to appropriate values for printing the current page because that is not what Javascript is for - that is the job of the print dialog. Browsers therefore only make available to Javascript those things that Javascript needs to know such as the size of the screen, the to display the page, and similar things which help Javascript work out how the page is laid out. The current web page is Javascript's one and only concern. The Internet Explorer substitute for Javascript (called JScript) therefore has slightly more information about the browser and operating system that Javascript itself does. The individual computers on the network running the intranet may be able to be configured to allow the JScript window.print command write directly to the printer without displaying the print dialog.
This configuration would need to be set up individually on each client computer and is well beyond the scope of an article on Javascript.
Frank Buss Perhaps you can draw a PDF file with Reportlab (and printing it. Because you are using Outlook Express, I assume you need it for Windows. An example: from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import A4 c = canvas.Canvas('c:tmptest.pdf', pagesize¤, bottomup=0) c.setFont('Helvetica', 14) c.drawString(10, 20, 'Hello World!' ) c.save If you want direct printing, without user interaction and you know the path of the Acrobat Reader, you can use. Willoughby' wrote:I would really like to know how to do this too, basically i want toprint to a standard bubblejet print (non postscript) from a TkinterText widget, any ideas?Perhaps you can draw a PDF file with Reportlab (printing it. Because you are using Outlook Express, I assume you needit for Windows.
An example:from reportlab.pdfgen import canvasfrom reportlab.lib.pagesizes import A4c = canvas.Canvas('c:tmptest.pdf', pagesize¤, bottomup=0)c.setFont('Helvetica', 14)c.drawString(10, 20, 'Hello World!' )c.saveIf you want direct printing, without user interaction and you know thepath of the Acrobat Reader, you can use this line:system('C:ProgrammeAdobeAcrobat 5.0ReaderAcroRd32.exe' /p /h c:tmptest.pdf')Perhaps it's easier with the ShellExecute command, because then you don'tneed to know the path of AcroRd32.exe, but then you need this, if youdon't have ActiveState Python installed:If you just want to show the user the page and let the user decide toprint or close the document, this lines are sufficient:from os import startfilestartfile('c:tmptest.pdf'). Terry Reedy 'Naveed Iqbal' wrote in message news:6afb9d2c.43c5f5f1 at posting.google.com. On.nix or dos/windows, you open the printer port as if it were a file, just like other ports and devices. On.nix, this maybe be something like '/dev/lpt' or a the numbered serial or parallel port that your printer is attached to. On Dos and my win98 machine, this does the trick: and out come a sheet with 'Test Line' printed.
Note that f is formfeed char; without it, nothing is printed on page printers. Peter Hansen writes:Search for Mark Hammond's 'win32all' package and install it, orinstall the ActiveState distribution of Python which has it alreadyincluded.
Win32ui is one of the modules included in that package.Just to confuse further, win32all is not a python package. It's adistribution of python modules and packages. What I mean is thatwin32ui is a module that is not in a package, although it is includedin the win32all distribution.
I think I'll quit now, before I makethings clearer.;-). Search for Mark Hammond's 'win32all' package and install it, orinstall the ActiveState distribution of Python which has it alreadyincluded. Win32ui is one of the modules included in that package.Just to confuse further, win32all is not a python package. It's adistribution of python modules and packages. What I mean is thatwin32ui is a module that is not in a package, although it is includedin the win32all distribution. I think I'll quit now, before I makethings clearer.;-)Oops, my apologies for starting the confusion.
I stupidly usedconventional meanings for 'module' and 'package' instead ofreserving those for their specific Python meanings. Substitutesomething 'extensions' for package, and maybe 'DLL wrapper' or'library interface' for module in my above message and maybe itbecomes a little clearer.
Or not.If not, well, we're already all confused enough that this won'thurt much.:)-Peter. Steve Holden 'Uwe Schmitt' wrote in message news:allofr$lgscc$2 at hades.rz.uni-sb.de. Disk Operating System Rules OK! As a pythonista of somewhat longer standing I found PythonWin a delight. I don't overstress it, and it works. Naveed: while you are likely to stay more up-to-date by installing an updated base Python and installing updated Win32 extensions, there's no real reason for a 'novice' to need (or even want:-) to be so close to the (b)leading edge. I haven't heard anything to suggest the.
Thank you all for your help. I am really a novice when it comes topython. Will someone tell me how to install the win32ui module inwindows?thankanaveedI suceeded without win32all: I generated a postscript fileand copied it to the 'file' 'prn:' using shutil.copyfile.Disk Operating System Rules OK!As a pythonista of somewhat longer standing I found PythonWin a delight. Idon't overstress it, and it works.Naveed: while you are likely to stay more up-to-date by installing anupdated base Python and installing updated Win32 extensions, there's no realreason for a 'novice' to need (or even want:-) to be so close to the(b)leading edge. I haven't heard anything to suggest the ActiveStatedistribution isn't a perfectly practical solution to everyday needs.Uwe: you'll clearly do well with such lateral thinking abilities.
Whatsoftware did you use to generate the PS?nostalgical-ly y'rs - ste ve-Steve HoldenPython Web ProgrammingPrevious.sig file retired to www.homeforoldsigs.com. Uwe Schmitt I just found this solution because I was to lazy to read the win32all ducomentation. At first I use pdflib to generate pdf-files (which can be stored, send by email.) and then used ghostscript to convert pdf to ps. The only 'problem' I have, is that ghostscript opens a window, even if I use it from the commandline. Greetings, Uwe. Uwe Schmitt Computer science is no more about Computers, uwe.schmitt at procoders.net than astronomy is about telescopes. Thank you all for your help.
I am really a novice when it comes topython. Will someone tell me how to install the win32ui module inwindows?thankanaveedI suceeded without win32all: I generated a postscript fileand copied it to the 'file' 'prn:' using shutil.copyfile.Disk Operating System Rules OK!shurely:-)Uwe: you'll clearly do well with such lateral thinking abilities.
Whatsoftware did you use to generate the PS?I just found this solution because I was to lazy to read thewin32all ducomentation.At first I use pdflib to generate pdf-files (which can be stored,send by email.) and then used ghostscript to convert pdf to ps.The only 'problem' I have, is that ghostscript opens a window, evenif I use it from the commandline.Greetings, Uwe.
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
February 2023
Categories |