Sign in to follow this  
Followers 0
Tankbuster

Print Html file to a friendly printer name

5 posts in this topic

Hello,

this time I do not have much (not one line of) code, more like a general search/question.

Task:

print a file with html content to a given printer with a friendly printername without displaying any dialog.

So for printing I got a solution (forum search) also for changing temporarily the default printer (before print set def printer, print, set back def printer).

But I want to know if there is a chance to skip this change of the default printer.

More or less all print solutions work with the default printer (at least the ones I found).

Is there already something I missed in the forum to complete the task?

If you know something just provide the link or some hints.

btw: no extra DLL would be extra nice :-) But in case needed, yes also an option.

Have a nice day.

Share this post


Link to post
Share on other sites



"But I want to know if there is a chance to skip this change of the default printer."

Mmmh, answer in short: don't run your script for changing the default printer.

" to a given printer with a friendly printername"

What means that? Because I've 2 pdf printer I renamed one to "Harald-PDF" and the other to "Maud-PDF".

Works good. But do you mean that with "friendly" printername?

The display (or not) of a print dialog, depends on the software you use for printing and how you can control it.

So don't can be answered without seeing your script or more info about the software you use for printing the html.

best regards, Reinhard

Share this post


Link to post
Share on other sites

Mmmh, answer in short: don't run your script for changing the default printer.

Sorry, my fault I was not precise enough. I saw some solutions that do change the default printer for some short time. So I do not want to change the default printer, this is for sure.

" to a given printer with a friendly printername"

What means that? Because I've 2 pdf printer I renamed one to "Harald-PDF" and the other to "Maud-PDF".

Works good. But do you mean that with "friendly" printername?

Yep, exactly.

The display (or not) of a print dialog, depends on the software you use for printing and how you can control it.

So don't can be answered without seeing your script or more info about the software you use for printing the html.

best regards, Reinhard

So the answer is in fact I do want to use a thrid party software. All should be done more or less with Autoit.

There is a software that will do this:http://www.printhtml.com/ but for windows 7 it will need "DHTML Editing Control for Applications Redistributable".

But for example this software will change the default printer.

You are right let me draft some (dummy)code to work with:

#include <IE.au3>
$DefaultPrinterNameSaved = RegRead( "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\windows", "Device")
$DefaultPrinterNameSaved = StringSplit($DefaultPrinterNameSaved, ",")
$DefaultPrinterNameSaved = $DefaultPrinterNameSaved[1]
console(":"&$DefaultPrinterNameSaved&":")
 
$url="http://www.autoitscript.com/forum/topic/132967-print-html-file-to-a-friendly-printer-name/"
;~ $url="file:///" &@ScriptDir&"/Dummy.html"
SetDefaultPrinter("PDFCreator")
$oIE = _IECreate ("about:blank",0,0)
_IENavigate($oIE,$url,1)
_IELoadWait ($oIE)
console("loaded")
_IEAction ($oIE, "printdefault")
console("printed")
SetDefaultPrinter($DefaultPrinterNameSaved)
 
func console($text)
consolewrite($text&@CRLF)
EndFunc
Func SetDefaultPrinter($Printer)
   Run(@ComSpec & " /c RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n " & $Printer , "",@SW_HIDE)
EndFunc

As you can see I change the printer. I would like to skip this if possible. PDFCreator is just a example, it's not about writing a pdf, could be something like "Hp1234" or "Hp5678".

Share this post


Link to post
Share on other sites

Hi,

renaming you can do with a right mouse click on the printer, under start->settings->printers (just above properties).

Using the IE-Object for printing, I think there is no way to state a printer direct (no properties/no methods), so changing before and after seems to be the only method.

HTH, Reinhard

Share this post


Link to post
Share on other sites

Thx for your approach.

Yes, so currently I read the default printer, change printer x to default , create a IE object, "printdefault" and change back to previous default printer.

Not what I like but something that worked (for now).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0