Printing Issue via IE API

ruan007

New Member
Hi Guys

Our application has a procedure using the following code to do file printing. Before we call this procedure, we output the file to html format. This routine has been working for years. But lately, our main application hangs when our users try to print the document. It doesn't happen all the time though, once it happens, we have to kill and restart the entire application and the printing works again.

I have checked that there is no software changed in terms of IE version, it's always IE 6. What I did realise is that the iexplorer.exe process stays alive and memory usage grows everytime when the printing occurs. I am not sure if that is the case, but even though the memory usage is low, the app still freezes. I did try to add webPrint:QUIT() and RELEASE OBJECT webPrint NO-ERROR two statements after webPrint:ExecWB(), it didn't seem to be useful, iexplorer.exe is still alive and grows in memory.

Any advice? (btw, our progress version is 91E)

Thanks

Code:
[FONT=courier new,courier]&SCOPED-DEFINE HWND_BROADCAST 65535[/FONT]
[FONT=courier new,courier]&SCOPED-DEFINE WM_WININICHANGE 26[/FONT]
 
[FONT=courier new,courier]DEF VAR webPrint    AS COM-HANDLE       NO-UNDO.[/FONT]
[FONT=courier new,courier]DEF VAR printPrompt AS INT              NO-UNDO INITIAL 2. /* Use default printer */[/FONT]
[FONT=courier new,courier]DEF VAR appAction   AS INT              NO-UNDO INITIAL 6. /* Print the thing */[/FONT]
[FONT=courier new,courier]DEF VAR spoolFile   AS CHAR             NO-UNDO.[/FONT]
[FONT=courier new,courier]DEF VAR winConParam AS CHAR             NO-UNDO.[/FONT]
[FONT=courier new,courier]DEF VAR iReturn     AS INT              NO-UNDO.[/FONT]
 
[FONT=courier new,courier]PROCEDURE WriteProfileStringA EXTERNAL "KERNEL32.DLL":[/FONT]
[FONT=courier new,courier] DEF INPUT PARAMETER lpszSection AS CHAR.[/FONT]
[FONT=courier new,courier] DEF INPUT PARAMETER lpszKeyName AS CHAR.[/FONT]
[FONT=courier new,courier] DEF INPUT PARAMETER lpszString AS CHAR.[/FONT]
[FONT=courier new,courier] DEF RETURN PARAMETER iReturn AS LONG.[/FONT]
[FONT=courier new,courier]END.[/FONT]
[FONT=courier new,courier]PROCEDURE SendMessageA EXTERNAL "USER32.DLL":[/FONT]
[FONT=courier new,courier] DEF INPUT PARAMETER p1 AS LONG.[/FONT]
[FONT=courier new,courier] DEF INPUT PARAMETER p2 AS LONG.[/FONT]
[FONT=courier new,courier] DEF INPUT PARAMETER p3 AS LONG.[/FONT]
[FONT=courier new,courier] DEF INPUT PARAMETER p4 AS CHAR.[/FONT]
[FONT=courier new,courier] DEF RETURN PARAMETER result AS LONG.[/FONT]
[FONT=courier new,courier]END.[/FONT]
 
[FONT=courier new,courier]ASSIGN[/FONT]
[FONT=courier new,courier]spoolFile   = "c:\temp\docket.html"[/FONT]
[FONT=courier new,courier]winConParam = "[/FONT][FONT=courier new,courier]\\fs-01\toshiba-bw-printer,winspool,Ne04:". /* at run time, this value is retrieved by reading the regitry key value [/FONT]
[FONT=courier new,courier]in HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\device*/[/FONT]
 
 
[FONT=courier new,courier]CREATE "InternetExplorer.Application" webPrint.[/FONT]
[FONT=courier new,courier]/* get the file */[/FONT]
[FONT=courier new,courier]NO-RETURN-VALUE webPrint:Navigate (spoolFile, , , , ).[/FONT]
[FONT=courier new,courier]SESSION:PRINTER-CONTROL-HANDLE = 0.[/FONT]
[FONT=courier new,courier]RUN WriteProfileStringA("windows", [/FONT]
[FONT=courier new,courier]                     "device",[/FONT]
[FONT=courier new,courier]                     winConParam,[/FONT]
[FONT=courier new,courier]                     OUTPUT iReturn).[/FONT]
[FONT=courier new,courier]RUN SendMessageA( {&HWND_BROADCAST},[/FONT]
[FONT=courier new,courier]               {&WM_WININICHANGE},0,"WINDOWS",[/FONT]
[FONT=courier new,courier]               OUTPUT iReturn).[/FONT]
[FONT=courier new,courier]NO-RETURN-VALUE webPrint:ExecWB ( appAction, printPrompt, , ).  [/FONT]
 

ruan007

New Member
Hi,

A correction to my previous post. The webPrint:QUIT() call does terminate the iexplorer.exe process if there is no iexplorer process exists in the first place. In our case, we always have a embeded web brower to display intranet content.
Another problem with webPrint:quit() method is that it doesn't send the print job to the printer anymore, probably it terminates the process before the job reaches the printer.

Damn it :(
 

Cecil

19+ years progress programming and still learning.
hi. I don't have a solution to the IE6 printing issues, but I might have an alternative workaround. using wkhtmlopdf http://code.google.com/p/wkhtmltopdf/. It's opensource so you might be able to use it to convert html to PDF. Then print the PDF file via adobe reader using com object autiomation. It's going to be an extra step in printing to paper but it will mean that you no longer on relying on IE6.

Before the forum Nazi jump on my back I am not trying to promote wkthmltopdf I just trying to come up with an alternative method to printing html documents.
 
Top