0
I am developing on Node an application where I have an html page, which I fill with database data and then need to save this page in PDF. I’m trying to use Phatom, I’ve tried following several tutorials, but when I pass the page URL it saves the PDF several times, it does not finish the process and always overwrites the generated PDF. What can I do to fix this?
const timeout = ms => new Promise(resolve => setTimeout(resolve, ms));
(async function() {
const instance = await phantom.create();
const page = await instance.createPage();
await page.property('viewportSize', { width: 1920, height: 1024 });
const status = await page.open('http://localhost/gerar_diploma?id_aluno='+_id);
console.time('wait');
await timeout(500);
console.timeEnd('wait');
await page.render('docs/result.pdf');
await instance.exit();
})();
Good afternoon, if you follow the documentation and recreate this Example your pdf will be created successfully. The phantom methods are promises, no need to create a counter to return the promises.
– Chance