wkhtmltopdf Performance and Execution Issues in WebSpeed vs prowin32

Chad

New Member
OEv11.7 / Windows 11

Hi all,

I'm using wkhtmltopdf.exe from webSpeed to convert HTML files to PDFs. While everything works perfectly when run via prowin32.exe or _progres.exe. However, I’m hitting two key problems when executed inside a WebSpeed agent:

Problem 1: Extremely Slow Execution in WebSpeed

When I call wkhtmltopdf using OS-COMMAND from a WebSpeed agent, it takes 60–90 seconds to complete, despite the same command running in under a second when called directly running from a batch file or executing from app builder.

Example code:
Code:
DEFINE VARIABLE cCommand AS CHARACTER NO-UNDO.
ASSIGN
  cCommand = "C:\path\to\wkhtmltopdf.exe " +
           "--enable-local-file-access " +
           "C:\temp\input.html C:\temp\output.pdf".

OS-COMMAND SILENT VALUE(cCommand).

Problem 2: No Execution When Broker Runs Under My Admin User

If I configure the WebSpeed broker to run under my personal (admin-level) user account, the wkhtmltopdf command doesn’t run at all — no error, no output, no logs.

However, if I run the broker as LocalSystem, the command executes, but still with the 60–90 second delay.


Questions:

Has anyone encountered this execution delay in WebSpeed?

Are there known restrictions in WebSpeed’s OS-COMMAND context?

Is there a better architectural pattern for offloading command-line tools from WebSpeed?
 
Last edited by a moderator:
I'm going to ask an obvious question. Whatever procedure/method/function that is outputting to C:\temp\input.html, has it closed the output stream before calling the OS-COMMNAD?

Do you still have the performance issue when creating a PDF from a URL i.e. ?
 
Thanks for your reply. The method to create the html file before hand is a simple COPY-LOB from a longchar to the file:

Example code:

DEFINE VARIABLE lcHtmlFile AS LONGCHAR NO-UNDO.
DEFINE VARIABLE cCommand AS CHARACTER NO-UNDO.

ASSIGN lcHtmlFile = "<html><head></head><body><p>Hello World</p></body></html>".

COPY-LOB lcHtmlFile TO FILE "C:\temp\input.html".

ASSIGN
cCommand = "C:\path\to\wkhtmltopdf.exe " +
"--enable-local-file-access " +
"C:\temp\input.html C:\temp\output.pdf".

OS-COMMAND SILENT VALUE(cCommand).


If I modify the command line (below) to output a pdf from a live URL I experience the same issue:

ASSIGN
cCommand = "D:\dev\dlcapps\ascent\scripts\wkhtmltopdf.exe " +
"--enable-local-file-access " +
"Google C:\temp\output.pdf".
 
Try this using INPUT-OUTPUT through. I've tested it on Windows 11 Pro Workstation, OE 12.8 using PASOE. There was no pause, also there was no pause using OS-Command.

Code:
DEFINE STREAM sOSCommand.

PROCEDURE htmltopdf:
    /*------------------------------------------------------------------------------
     Purpose:
     Notes:
    ------------------------------------------------------------------------------*/
    DEFINE VARIABLE chOSCommand      AS CHARACTER NO-UNDO.
    DEFINE VARIABLE chStandardOutput AS CHARACTER NO-UNDO.

    FILE-INFO:FILE-NAME = '.'.

    MESSAGE FILE-INFO:FULL-PATHNAME.

    chOSCommand = '"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" --enable-local-file-access index.html report.pdf'.

    INPUT-OUTPUT stream sOSCommand through VALUE(chOSCommand).

    REPEAT:
 
        IMPORT STREAM sOSCommand UNFORMATTED chStandardOutput.
 
        MESSAGE chStandardOutput.
 
    END.

    INPUT-OUTPUT through stream close.

//os-command value(chOSCommand).

END PROCEDURE.
 

Attachments

That does raise the question: how do you know it's the OS-COMMAND that's taking the time? Have you run it with the profiler enabled?
That will tell you exactly which line of code is the problem.
 
Well, yes. But since that has not happened yet I am suspicious that the malware known as "anti-virus" may be doing something to interfere with the proper operation of the code.
 
Back
Top