I'm on a personal project which is a simple form with many inputs to be filled.
The last step is to confirmed the datas, once this is done, I would like to generate a PDF of the form answers and send it to an email that I asked for before (in the form).
I tried Puppeteer, it generates the PDF of the template of the form, but the variables are not filled.
I would like to do something like "When the confirmed button on the recap page is clicked, then generate the PDF with the datas on the page."
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("http://localhost:8888/Medical%20Form/recup_donnees.php", {
waitUntil: "networkidle2",
});
let button = await page.evaluate(() => {
document.querySelector("#test");
});
await page.waitForSelector("button");
await page.click("button");
await page.pdf({ path: "bordeeeeeeeel.pdf", format: "a4" });
await browser.close();
})();
Here is my code, even if I know it is absolutely wrong (because it loads an empty page), I can't figure it out how to make it works, maybe I'm going the wrong way with Puppeteer and I should take something else to do the trick.
Sorry for that noob question, but I'm actually a noob...
And thank you in advance !