Copy link to clipboard
Copied
I have project that takes an html file and using Chrome headless it converts that html into a PDF. That all works great, the problem is that I want to be able to save that html file as a jpg thumbnail. I know you can do it using Puppeteer but I'm not sure how to get Puppeteer to execute using CFEXECUTE as puppeteer is run from the command line like this:
node testcase1.js
testcase1.js holds all the puppeteer code. If I run it direct from the command line it works perfectly.
i've tried using a cfexecute in various ways:
<cfexecute name="node.exe" arguments="testcase1.js">
<cfexecute name="C:\Program Files\nodejs\node.exe" arguments="testcase1.js">
but nothing happens, the page doesnt even error. I've tried adding an output variable to see any errors and its just blank.
Can anyone offer any advice to get this working?
Copy link to clipboard
Copied
What account is your ColdFusion service running under? It might not have permissions to access the node directory?
You could try putting your node commnd in a batch file and then use CFExecute to run that.
<cfexecute name="C:\myNodeCommand.bat">
I might also suggest a different app, altogether. To my knowledge, it the same engine CF uses in its HTMLTOPDF engine:
We use this all the time for site screenshots. Running it from the command line gives us much more flexibility and control than Adobe's tag. It can do PDFs or images.
<cfexecute name="C:\Program Files\wkhtmltopdf\0.12.6\bin\wkhtmltopdf.exe" arguments="#yourOptions#">
</cfexecute>
<cfexecute name="C:\Program Files\wkhtmltopdf\0.12.6\bin\wkhtmltoimage.exe" arguments="#yourOptions#">
</cfexecute>
All the command-line options are here: https://wkhtmltopdf.org/usage/wkhtmltopdf.txt
Copy link to clipboard
Copied
we used to use wkhtml but it was too limiting with the CSS it supported. Going Chrome headless sorted that.
Copy link to clipboard
Copied
I like the batch file suggestion. I seem to recall that working consistently. But if you didn't want to put everything in a batch file for some reason, you could also try something like this:
<cfexecute name="c:\windows\system32\cmd.exe" arguments="/c \path\to\node.exe testcase1.js">
Dave Watts, Eidolon LLC
Copy link to clipboard
Copied
node testcase1.js
testcase1.js holds all the puppeteer code. If I run it direct from the command line it works perfectly.
By @partTimeCrazy
How/Where does the HTML file come in?