Solved

How do I print using a windows print driver?

Posted on 2004-08-21
12
929 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:turn123
  • 5
  • 4
  • 3
12 Comments
 
LVL 2

Assisted Solution

by:mishagale
mishagale earned 100 total points
ID: 11860666
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
 
LVL 11

Author Comment

by:turn123
ID: 11860794
mishagale,

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

Turn123
0
 
LVL 2

Expert Comment

by:mishagale
ID: 11861069
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 11

Author Comment

by:turn123
ID: 11861371
Saw that but I don't see how to choose to print the the fax printer or pass the fax number.
0
 
LVL 2

Expert Comment

by:mishagale
ID: 11861591
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
 
LVL 11

Author Comment

by:turn123
ID: 11861796
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
 
LVL 20

Accepted Solution

by:
jmcg earned 400 total points
ID: 11862428
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
 
LVL 20

Expert Comment

by:jmcg
ID: 11871710
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
 
LVL 11

Author Comment

by:turn123
ID: 11872483
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
 
LVL 20

Expert Comment

by:jmcg
ID: 11872608
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
 
LVL 11

Author Comment

by:turn123
ID: 11884219
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
 
LVL 20

Expert Comment

by:jmcg
ID: 11888599
I'm bookmarking this one. Thanks for letting us know (and for pointing people who found your other question on this subject here).
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl efficient DB Call 8 87
syslog unix file 20 71
Using Perl DBI to query oracle 3 41
How to translate this 2-line while loop into C from Perl? 8 93
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question