How do I print using a windows print driver?

Basicly my problem is that I have a file with fax numbers and faxes that they need to be sent to.  Since it appears that there isn't a good way to send faxes with Perl on Win200 and XP I want to print the the Windows fax program and let it handle sending the faxes.

Any suggestions on how to do this?

Thanks in advance,
Turn123
LVL 11
turn123Asked:
Who is Participating?
 
jmcgOwnerCommented:
On WinXP, there are two fax components that you might already have or can readily get: faxcom and winfax.

Getting them to work with Perl is not immediately apparent to me, since I generally don't do Perl on Windows. Looking around at Microsoft I found this example of how to use faxcom with VB to send a simple text file via FAX to a supplied number.

http://support.microsoft.com/default.aspx?scid=kb;en-us;q303647

I've tried looking at ActiveState's Perl documentation to see if they have any examples of using COM objects from Perl (I've found one article on writing COM objects in Perl several times, but nothing yet on _using_ COM object from Perl), but the site and my browser aren't agreeing with each other at the moment. Maybe this will be a useful lead even if I can't hand you a solution.
0
 
mishagaleCommented:
Take a look at Win32::Printer and Win32::Printer::Enum
The former is used to actually send data to a printer, and the latter is to obtain information about installed printers.
0
 
turn123Author Commented:
mishagale,

Do you have some code showing how I would use this?

Turn123
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
turn123Author Commented:
Saw that but I don't see how to choose to print the the fax printer or pass the fax number.
0
 
mishagaleCommented:
You can choose which printer to use by passing the "printer" parameter to new(), as in "printer => 'fax", where 'fax' is the name listed in your printers folder.
AFAIK, the only way to pass the fax number to a windows fax/printer driver is for the user to type it in - the fax driver has to fit into the printer API, and printers don't need telephone numbers. I'm not an expert on W32 printing, so maybe there's some undocumented call or something, but I doubt it.

I don't know of and can't find any perl modules for sending faxes with a modem, I think your best chance might be to use an e-mail to fax gateway, of which there are many around. Otherwise, the only other thing I can think of is using a command-line program to send to fax, which you could easily call from Perl. Unfortunatley, I'm not aware of any such program for Win32, although there are plenty for unix (efax, hylafax, netfax).
0
 
turn123Author Commented:
mishagale,

Thanks.

I'm going to leave this open for a while to see if anyone can suggest a command line fax program or something else that would work well.

Turn123
0
 
jmcgOwnerCommented:
Is COM just a followup to OLE? In that case, the Win32::OLE module may be able to accomplish the equivalent of the Visual Basic code from the Microsoft Knowledge Base. The names remain the same, you just have to overcome the syntax differences.
0
 
turn123Author Commented:
jmcg,

Thanks for looking at this question.

When you say faxcom Are you referring to this product?

http://www.biscom.com/Merchant2/merchant.mv?Screen=CTGY&Store_Code=B&Category_Code=SBE

If so that is way out of my budget.

I do have a copy of Winfax pro so I'll look and see if I can find anything to work with that.

Turn123
0
 
jmcgOwnerCommented:
It was my impression that these were Microsoft DLLs available on the install disk or for free download, but - since I'm not much of a Windows wiz, I can't say so with much authority. The WinFAX pro product might have a different way for you to send a fax from "the command line" or "in batch mode" -- you'd need to look at the product's documentation.
0
 
turn123Author Commented:
jmcg and mishagale,

Thank you very much for your help.

After looking around I found that Winfax had a SDK so I was able to use that to send a fax.

Here is the basic code that I got working to send a fax:

use OLE;
use strict;

my $fax;

my $fax = Win32::OLE->new("WinFax.SDKSend") || die $!;
$fax->SetSubject("test");
$fax->SetNumber("8868526");
$fax->SetAreaCode("706");
$fax->SetCompany("OWPI");
$fax->AddRecipient();
$fax->LeaveRunning();
$fax->SetCoverText("Hi this is a test\n\nDid it work?");
$fax->Send(1);

print $fax->IsError();

and a link to the documentation...

ftp://ftp.symantec.com/misc/sabu/winfax/wfxsdk.pdf

Mabey in the future this will save someone a lot of time.

Now to get it working with my script :-).

Thanks again to both of you for your help.
Turn123
0
 
jmcgOwnerCommented:
I'm bookmarking this one. Thanks for letting us know (and for pointing people who found your other question on this subject here).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.