Replies: 1 comment
-
Actually, I don't want to handle all of the Node and Puppeteer dependencies inside ClearScript, which I gather I would need to do. Jering.Javascript.NodeJS may be a better option for me. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a simple NodeJS application that takes the path to an HTML file and a destination path, then uses Google's Puppeteer NodeJS library to generate a PDF from an input HTML file and place the generated PDF at the destination path. I need to execute that app from a C# project. I have read the answers to How can I use ClearScript to call Node.js script with NPM and possibly pass some parameter? which are helpful, but I'm still not certain about how to handle the input and output arguments. The Node application code is:
`'use strict';
// Usage: npm run convertToPdf infile outfile
// or: node app.js infile outfile
import puppeteer from "puppeteer";
const getPdf = async args => {
const infile = args[2];
const outfile = args[3];
const browser = await puppeteer.launch({headless: "new"});
const page = await browser.newPage();
}
getPdf(process.argv);`
From the discussion linked above, it looks like I would include code like this in my C# file:
using var engine = new V8ScriptEngine(); engine.Execute("self = this; setTimeout = () => {}"); engine.DocumentSettings.AccessFlags = DocumentAccessFlags.EnableWebLoading; engine.ExecuteDocument("https://path.to.my.app.js");
Is that correct, and what do I do next to execute my Node app passing in the strings for the input and output file paths?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions