Solved

How do I print using a windows print driver?

Posted on 2004-08-21
12
927 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
Comment Utility
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
Comment Utility
mishagale,

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

Turn123
0
 
LVL 2

Expert Comment

by:mishagale
Comment Utility
0
 
LVL 11

Author Comment

by:turn123
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 20

Accepted Solution

by:
jmcg earned 400 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now