mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-10 04:22:27 +10:00
Merge pull request #2375 from Avinash99b/main
fix(printer.service.ts): fix pdf rendering, issue #2374 solved
This commit is contained in:
@ -127,11 +127,33 @@ export class PrinterService {
|
||||
// Set the data of the resume to be printed in the browser's session storage
|
||||
const numberPages = resume.data.metadata.layout.length;
|
||||
|
||||
await page.evaluateOnNewDocument((data) => {
|
||||
await page.goto(`${url}/artboard/preview`, { waitUntil: "domcontentloaded" });
|
||||
|
||||
await page.evaluate((data) => {
|
||||
window.localStorage.setItem("resume", JSON.stringify(data));
|
||||
}, resume.data);
|
||||
|
||||
await page.goto(`${url}/artboard/preview`, { waitUntil: "networkidle0" });
|
||||
await Promise.all([
|
||||
page.reload({ waitUntil: "load" }),
|
||||
// Wait until first page is present before proceeding
|
||||
page.waitForSelector('[data-page="1"]', { timeout: 15_000 }),
|
||||
]);
|
||||
|
||||
if (resume.data.basics.picture.url) {
|
||||
await page.waitForSelector('img[alt="Profile"]');
|
||||
await page.evaluate(() =>
|
||||
Promise.all(
|
||||
// eslint-disable-next-line unicorn/prefer-spread
|
||||
Array.from(document.images).map((img) => {
|
||||
if (img.complete) return;
|
||||
return new Promise((resolve) => {
|
||||
// eslint-disable-next-line unicorn/prefer-add-event-listener
|
||||
img.onload = img.onerror = resolve;
|
||||
});
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
const pagesBuffer: Buffer[] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user