Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering often fails #62

Open
leegee opened this issue Jan 11, 2023 · 2 comments
Open

Rendering often fails #62

leegee opened this issue Jan 11, 2023 · 2 comments

Comments

@leegee
Copy link

leegee commented Jan 11, 2023

Rendering 85,000 rows, I found the first page was lovely, but the row that started page two was spread out so that each cell of that row was on a new page. That seems to happen for three records in a row.

Then, every now and again, at the end of a page, when a row contains a cell that is spread over several lines, one cell is rendered on a page by itself.

Sadly, I can't send a sample as I'm working on a sensitive commercial project.

I'll have to get Puppeteer to render the PDF for now, but hope this vague report is of some help.

image

@tonprince
Copy link

I have thr same issue. Any workaround?

@leegee
Copy link
Author

leegee commented Mar 8, 2023

I have thr same issue. Any workaround?

I did it by hand using Puppeteer:

import * as puppeteer from 'puppeteer';
const inlineCss = require('inline-css');

const htmlInput = '<p>something to go in the doc</p>';
const browser = await puppeteer.launch({
    headless: true,
    pipe: true,
    args: [
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--disable-dev-shm-usage',
        '--headless',
        '--disable-gpu',
        '--full-memory-crash-report',
        '--unlimited-storage',
    ]
});
const page = await browser.newPage();

await page.emulateMediaType('screen');

// Just inlines a stylesheet:
const htmlCssed = await inlineCss(htmlInput, { url: "/" });

await page.setContent(htmlCssed, {
    waitUntil: ['load', 'domcontentloaded', 'networkidle0'],
    timeout: 60000,
});

let pdfStream;
try {
    // https://pptr.dev/api/puppeteer.pdfoptions
    pdfStream = await page.createPDFStream({
        timeout: 0,
        printBackground: true,
        format: 'A4',
        landscape: true,
        displayHeaderFooter: true,
        margin: {
            top: '1cm', left: '1cm', right: '1cm', bottom: '1cm'
        },
        headerTemplate: '<div></div>',
        footerTemplate: `<div style="text-align: right; width: 100%;">
            <span class="pageNumber"></span> of <span class="totalPages"></span>
        </div>`,
    });
    logger.log({ action: "PDF created pdf stream" });
} catch (e) {
    logger.error({ action: "PDF error in create pdf stream", e });
}

pdfStream
    .on('end', () => logger.log('pdfStream done'))
    .on('error', (e) => logger.error({ e, action: 'pdfReport' }))

return pdfStream;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants