Merge pull request #109 from presenton/feat/presentation_export

feat/presentation export
This commit is contained in:
Saurav Niraula 2025-07-21 00:38:20 +05:45 committed by GitHub
commit 4ade6a9df4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 8 deletions

View file

@ -7,14 +7,21 @@ import { NextResponse, NextRequest } from 'next/server';
export async function POST(req: NextRequest) {
const { id, title } = await req.json();
const { id, title } = await req.json();
console.log('path', process.env.APP_DATA_DIRECTORY);
if (!id) {
return NextResponse.json({ error: "Missing Presentation ID" }, { status: 400 });
}
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox']
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-gpu',
'--disable-web-security',
'--window-size=1920,1080'
]
});
const page = await browser.newPage();
await page.goto(`http://localhost/pdf-maker?id=${id}`, { waitUntil: 'networkidle0',timeout: 80000 });
@ -27,7 +34,7 @@ export async function POST(req: NextRequest) {
});
browser.close();
const sanitizedTitle = sanitizeFilename(title);
const destinationPath = path.join(process.env.APP_DATA_DIRECTORY!,'exports', `${sanitizedTitle}.pdf`);
const destinationPath = path.join(process.env.APP_DATA_DIRECTORY!, 'exports', `${sanitizedTitle}.pdf`);
console.log('destinationPath', destinationPath);
await fs.promises.writeFile(destinationPath, pdfBuffer);

View file

@ -159,11 +159,9 @@ async function screenshotElement(element: ElementAttributes, screenshotsDir: str
async function getSlidesAttributes(slides: ElementHandle<Element>[], screenshotsDir: string): Promise<SlideAttributesResult[]> {
const slideAttributes = [];
for (const slide of slides) {
const attributes = await getAllChildElementsAttributes({ element: slide, screenshotsDir });
slideAttributes.push(attributes);
}
const slideAttributes = await Promise.all(
slides.map((slide) => getAllChildElementsAttributes({ element: slide, screenshotsDir }))
);
return slideAttributes;
}