WinFax 9.0 using PHP script

Posted on 2010-09-01
Medium Priority
Last Modified: 2012-05-10
Could somebody provide sample of PHP script to send fax via winfax 9.0?
Question by:chwong67
  • 5
  • 5
LVL 40

Expert Comment

by:Richard Quadling
ID: 33581931
According to http://en.wikipedia.org/wiki/WinFax, WinFax 9 is 12 years old. Are you sure this is what you are using?

In the past, I've used PHP to create a plain text file (with special entries to include cover sheet, fax number, layout images, etc.) and drop it into a directory for GFI FaxMaker to send. I've done the same sort of thing with ToBIT FaxWare (and later David).

No direct communication needed. Extremely simple technique and capable of being handled by even an MSDOS Batch file!

I can't find a manual online as the product was discontinued by Symantec in 2005 (Wikipedia).

But if you do have a manual (or help file), look for entries like "file transfer" or "file monitoring" or "directory monitor", etc.

OOI. http://www.winfax.com/ threw me for a sec as it was talking about GFI ... Naughty domain name grab!

Author Comment

ID: 33582817
Thanks for your information...
Could you please recomend the best practice to fax using PHP script?
LVL 40

Expert Comment

by:Richard Quadling
ID: 33582841
It depends upon the capabilities of the faxing software.

If you can provide some documentation for WinFaxPro, then I can advise you on what it can do.

These things tend to be pretty simple.

You create a text file with entries like ...

@@Sheet:Sheet1.png Sheet2.png
And here is the first line of the fax message.

Some are more complex in that you can send the data to a template.

@@Invoice:Customer:Richard Quadling

The template would sort out all the work.

This is the simplest way to work.

More complex would be to see if the faxing software has an COM server. PHP supports COM (nearly perfectly).

I use PHP+COM to talk to Crystal Reports and MS Word.

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.


Author Comment

ID: 33582855
We may consider using other faxing software.
We prefer send fax in PDF format.
Any suggestion?
LVL 40

Expert Comment

by:Richard Quadling
ID: 33582873
For creating a PDF in PHP, I use fpdf (http://www.fpdf.org). This is a free class with a lot of tutorials on creating PDF files.

Once you've got your PDF, you are going to need to send it to something. A fax server.

And as I keep saying, I can't find any documentation on WinFax, so I can't get any further.

Do you have a manual for WinFax?

Author Comment

ID: 33594257
Thanks for your help...
I attched the manual for your reference and i am new to PHP...
I found the following link which is quite related to this issue:

LVL 40

Expert Comment

by:Richard Quadling
ID: 33594746
On page 1-1 of the PDF, you'll see that WinFax PRO SDK uses a Component Object Model interface.

This is good.

This, to a point, means you can talk to WinFax Pro from PHP using PHP's built in COM interface.

It means you should have total control over the content of the fax, the layout, how it is sent, cover page, logging, etc. Everything documented in the PDF link you provided.

You are going to have to learn 2 significant technologies. PHP's OOP/COM and WinFaxPro COM objects.

So, start with http://docs.php.net/manual/en/book.com.php and the PDF.

Please remember that you are using a third party tool (WinFaxPro) and controlling it using PHP (via the COM interface). As such the WFP documentation is all you have to go on to make faxes, etc.

I (and others here), can certainly help you get going and help along the way. But without the SDK, we can't test any code. I do not use WinFax Pro and I have no intention of installing the SDK.

So. Read up on COM and WFP's code. Look at some of the examples of talking to Word or Excel (from the various user notes in the PHP manual on the COM section) and then start adapting the code to talk to WFP.

I've attached a small script that I use to talk to Crystal Reports as an example of PHP+COM.

The code has been heavily edited. The important thing to notice is that once I've created the COM instance, I talk to it like a normal object.

Unfortunately, you will need to fully understand the other app to make use of it. It is NOT PHP's job to know what to do.
// Create an Crystal Object Factory.
$o_CrObjectFactory = New COM('CrystalReports11.ObjectFactory.1');

// Create the Crystal Reports Runtime Application.
$o_CrApplication = $o_CrObjectFactory->CreateObject("CrystalRunTime.Application.11");

// Register the typelibrary.

// Where is the real filename?
$s_RptFilename = realpath("../CrystalReports/Collection Ticket.rpt");

// Load the report.
$o_CrReport = $o_CrApplication->OpenReport($s_RptFilename, 1); // 1 == crOpenReportByTempCopy.

// Logon to the database.

// Don't tell anyone what is going on when running live.
$o_CrReport->DisplayProgressDialog = is_dev();

// Define the params to be supplied.
$a_ParametersToSupply = array
	'{?Collection Ticket Number}' => $s_Ticket,

$s_PDF = realpath("../Work Files") . DIRECTORY_SEPARATOR . 'Collection Ticket #' . md5($s_Ticket) . '.pdf';

// Iterate the parameters and set them to the required values shown above.
foreach($o_CrReport->ParameterFields as $i_Parameter => $o_Parameter)
	$o_Parameter->SetCurrentValue($a_ParametersToSupply[$o_Parameter->Name], $o_Parameter->ValueType);

// Run the report and save the PDF to disk.
$o_CrReport->ExportOptions->DiskFileName = $s_PDF;
$o_CrReport->ExportOptions->PDFExportAllPages = True;
$o_CrReport->ExportOptions->DestinationType = 1; // Export to File
$o_CrReport->ExportOptions->FormatType = 31; // Type: PDF


Open in new window


Author Comment

ID: 33601639
Thank you very much  for your valuable information...
My requirement is very simple,
I manage to save the report to pdf format (using fpdf), next i need to know how to send this pdf file to winfax with fax number provided ...
LVL 40

Accepted Solution

Richard Quadling earned 1500 total points
ID: 33602419
Do you know if the COM library is installed?

Using a type lib viewer you can examine the library (google for this, there are simply loads!).

I've not got the library, so I don't know the exact mechanism, but you've got the documentation.

So give it a go and I can help with ideas on what you need to change.

Expert Comment

ID: 33741155
There is a WinFax specific SDK forum here:

Author Closing Comment

ID: 33882579
Thanks for your help.

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

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.

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
I recently worked on a Wordpress site that utilized the popular ContactForm7 (https://contactform7.com/) plug-in that only sends an email and does not save data. The client wanted the data saved to a custom CRM database. This is my solution.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

597 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