Tudo: Primeiro commit
This commit is contained in:
commit
06a90928dc
4633 files changed
+6327263
No files matched your search
@@ -0,0 +1,54 @@
|
||||
// Gera build/robo-movel-etapa2.pdf a partir de build/index.html.
|
||||
// Abre a apresentacao no Chromium headless e imprime cada slide como uma
|
||||
// pagina de 1920x1080 px, com fundo e com todos os reveals no estado final.
|
||||
//
|
||||
// Uso: node scripts/make_pdf.cjs
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { chromium } = require('/home/marcel/.npm/_npx/e41f203b7505f1fb/node_modules/playwright');
|
||||
|
||||
const ROOT = path.resolve(__dirname, '..');
|
||||
const HTML = path.join(ROOT, 'build', 'index.html');
|
||||
const PDF = path.join(ROOT, 'build', 'robo-movel-etapa2.pdf');
|
||||
|
||||
(async () => {
|
||||
if (!fs.existsSync(HTML)) {
|
||||
console.error('build/index.html nao encontrado. Rode `make build` antes.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const browser = await chromium.launch({ args: ['--no-sandbox'] });
|
||||
const page = await browser.newPage({ viewport: { width: 1920, height: 1080 } });
|
||||
await page.goto('file://' + HTML, { waitUntil: 'load' });
|
||||
|
||||
// Garante que as fontes locais estejam carregadas antes de imprimir.
|
||||
await page.evaluate(async () => {
|
||||
if (document.fonts && document.fonts.ready) await document.fonts.ready;
|
||||
});
|
||||
|
||||
// Estado final das animacoes e ocultacao dos controles, por seguranca
|
||||
// (o CSS @media print tambem cobre isso).
|
||||
await page.addStyleTag({
|
||||
content: `
|
||||
.reveal, .reveal-scale { opacity: 1 !important; transform: none !important; transition: none !important; }
|
||||
.edit-hotzone, .edit-toggle, .progress { display: none !important; }
|
||||
`,
|
||||
});
|
||||
|
||||
await page.emulateMedia({ media: 'print' });
|
||||
await page.waitForTimeout(600);
|
||||
|
||||
const slides = await page.$$eval('.slide', (els) => els.length);
|
||||
await page.pdf({
|
||||
path: PDF,
|
||||
width: '1920px',
|
||||
height: '1080px',
|
||||
printBackground: true,
|
||||
margin: { top: '0px', right: '0px', bottom: '0px', left: '0px' },
|
||||
});
|
||||
|
||||
await browser.close();
|
||||
|
||||
const kb = (fs.statSync(PDF).size / 1024).toFixed(0);
|
||||
console.log(`PDF gerado: build/robo-movel-etapa2.pdf (${slides} slides, ${kb} KB)`);
|
||||
})();
|
||||
Reference in new issue
Block a user