Converting To APF using idShell

There have always been options when converting documents into the image file format (APF) that Async Professional requires when sending a fax.  Using the fax printer driver supplied by Async Professional has always been a popular method along with the TApdFaxConverter method called ConvertToFile.  Async Professional 4 has combined these tools to create one method that will convert documents stored in many different application formats programmatically. 

The TApdFaxConverter component can convert many file formats into an APF file when the InputDocumentType property is idShell.  When using this addition to the InputDocumentType property, the TApdFaxConverter component will use the ShellExecute API method to execute the application associated with the selected file type and print the document to the TurboPower fax printer driver.  The choice of InputDocumentTypes usually depended on your specific needs according to the document type used, but with idShell the file is taken from the application that created the document and printed to the printer driver.   Essentially, this would use the ShellExecute with the ‘printto’ parameter to print the specified document such as a Microsoft Word would be the one to send a .DOC file.

The following Delphi example converts C:\MYDOC.DOC to an APF file:

OpenDialog1.Filter := ‘Any file(*.*)|*.*’;

if OpenDialog1.Execute then begin

  ApdFaxConverter1.DocumentFile := OpenDialog1.FileName;

  ApdFaxConverter1.InputDocumentType := idShell;

  ApdFaxConverter1.ConvertToFile;

end; //End if

The following C++ example converts C:\MYDOC.DOC to an APF file:

OpenDialog1->Filter = “Any file(*.*)|*.*”;

if (OpenDialog1->Execute())

{

  ApdFaxConverter1->DocumentFile = OpenDialog1->FileName;

  ApdFaxConverter1->InputDocumentType = idShell;

  ApdFaxConverter1->ConvertToFile();

} //End if

 

If the application associated with the selected file format does not support the ‘printto’ verb, but does support the ‘print’ verb, then idShell will change the default printer to the fax printer driver, print the document using ShellExecute and the 'print' verb, and then change back to the original default printer.  For example, in Windows 95 “Notepad” does not support the ‘printto’, but does support ‘print’, but both are supported in Windows 98 and 2000.  An exception is raised if the application does not support the 'printto' or 'print' verbs.

The printer driver will not generate TApdFaxDriverInterface events when a document is printed using the TApdFaxConverter component. When a document is being converted, two registry keys are added. One is the window handle that will receive an APW_ENDDOC message indicating that the print job is complete. The other is the name of the output file. See the protected ConvertShell method (not documented) in AdFaxCnv.pas for details on the specific registry keys. If either of these keys is present, the TApdFaxDriverInterface component's OnDocStart and OnDocEnd events are not generated.

This development utilizes what tools are available on the user’s machine and gives the developer a chance to automate faxing services and expand the options with one control method.    

This site is not affiliated, endorsed, or otherwise associated with the entity formerly known as TurboPower Software. The owners and maintainers of Aprozilla.com were merely meager employees of the aforementioned organization, providing this site out of the pure goodness of their collective hearts. SourceForge.net Logo

Last updated: July 22, 2003.