Using the Auto-print Service C++ Sample

The Auto-print Service monitors the “Monitored Directory=c:\AutoPrintService\in\” directory and converts the files into “Converted Directory= c:\AutoPrintService\converted”. The conversion process generates a detailed log file that can be used to monitor the conversion process and for troubleshooting the C++ service. The successful and failed document conversion will be registered in the Log file. The Log file can be opened any time in Notepad.

 

To configure the Auto-print Service Sample log file name, edit logfile section in the “Auto Print Service C++ Sample.ini” file. The  “Auto Print Service C++ Sample.ini” located in the directory <Auto-print SDK Installation folder>\<AutoPrint 32/64 bit>\Samples Directory.  If the “Auto Print Service C++ Sample.ini” contains an inaccessible or non-existing folder, the log file will be generated into the Root directory of Drive C:\

 

Any changes to the Auto Print Service C++ Sample.ini require the service to be restarted.

 

Example log file for a successful service startup and conversion:

04/08/14 10:12:56:      AutoPrint Service starts...
04/08/14 10:12:56:      Using printer driver: Black Ice ColorPlus
04/08/14 10:12:56:      Monitored Directory: c:\AutoPrintService\in\
04/08/14 10:12:56:      Converted Directory: c:\AutoPrintService\converted\
04/08/14 10:12:56:      Failed Directory: c:\AutoPrintService\failed\
04/08/14 10:12:56:      Waiting for notification...
04/08/14 10:13:11:      Directory changed.
04/08/14 10:13:11:      Printing: sample1.docx
04/08/14 10:13:15:      Printing: sample2.docx
04/08/14 10:13:21:      Printing: sample3.docx
04/08/14 10:13:27:      Printing: sample4.docx
04/08/14 10:13:30:      Printing: sample5.docx
04/08/14 10:13:36:      Waiting for locked file: c:\AutoPrintService\in\sample5.docx
04/08/14 10:13:37:      Waiting for notification...

“Waiting for notification...” indicates that Auto-print is idle and waiting for files to print. The Auto-print Service Sample receives directory change notifications from Windows, so a file that is copied to the input directory should start printing right away.

 

“Directory changed.” means new files are detected in the input directory.

 

“Waiting for locked file” means that the specified file is locked by another process currently, and Auto-print has to wait to continue. The Auto-print Service Sample waits for a locked file for a maximum of 5 minutes. If the file is not accessible after 5 minutes, Auto-print ignores the file and continues printing the next file. In this case the message “ERROR: Could not open locked file.” appears in the log file and the file is left in the monitored directory.

 

Here is an example for a failed conversion:

04/08/14 16:26:59:      Printing: sample.xps
04/08/14 16:27:00:      ERROR: The XYZ printer is not a Black Ice printer driver.
04/08/14 16:27:00:      Waiting for notification...

After the “ERROR:” text the Auto-print Service Sample prints out the error message returned by the BIAPGetErrorString function. For the list of possible errors, please see the following page: Auto-print Error Codes