there is currently an interface that needs to be requested using the POST method, and then the interface will return the HTML page, and we will save the HTML page as a PDF file.
const puppeteer = require("puppeteer");
(async() => {
const browser = await puppeteer.launch({
args: ["--no-sandbox", "--disable-setuid-sandbox"]
});
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on("request", interceptedRequest => {
var data = {
url: "http://localhost/print",
"method": "POST",
"postData": "operatingAccountID=57207213d41ce5d90300007c"
};
interceptedRequest.continue(data);
console.log(interceptedRequest.method(),"method")//GET
});
await page.goto("http://localhost/print");
await page.screenshot({path: "example.png"});
await page.pdf({path: "example.pdf", format: "A4"});
await browser.close();
})();
the above code has made some changes with reference to issue and stackoverflow in github, but currently method cannot be set to POST.