Discuss anything related to web development but no technical support questions


Post by RedTeam »

Bryntum Team:

We are having difficulties generating a pdf in relation to the gray tones even in the example that they have those colors are not appearing when they generate the PDF.
please help because we need solve this issue.

The problem is appearing even in the example that you have in Gantt Kitchen Sink.
https://dev.bryntum.com/examples/gantt/examples/export/
pdf1.png
pdf1.png (58.08 KiB) Viewed 2335 times
pdf2.png
pdf2.png (15.17 KiB) Viewed 2335 times
pdf3.png
pdf3.png (10.05 KiB) Viewed 2335 times

Post by Terence »

Hi, this issue was already reported. Fix will ship in release 6.0.3

https://app.assembla.com/spaces/bryntum ... icket=6807

If you want a quick workaround, you can adapt the following functions in server.js
async function processPageIntoPdfBuffer (browser, html, config)  {

    config.printBackground = true;
    config.margin = {
        top       : 0,
        bottom    : 0,
        left      : 1,
        right     : 1
    };

    return new Promise(async (resolve, reject) => {

        try {
            const page = await browser.newPage();
            //best way of loading according to https://github.com/GoogleChrome/puppeteer/issues/728
            await page.goto(`data:text/html;charset=UTF-8,${html}`, { waitUntil: 'networkidle0' });
            await page.emulateMedia('print');
            const buffer = await page.pdf(config);
            await page.close();
            resolve(buffer);
        }
        catch (ex) {
            reject(ex.message);
        }
    });
}
and
async function processPageIntoPngBuffer (browser, html, config)  {

    return new Promise(async (resolve, reject) => {

        try {

            const page = await browser.newPage();

            await page.goto(`data:text/html;charset=UTF-8,${html}`, { waitUntil: 'networkidle0' });
            await page.emulateMedia('print');
            const buffer = await page.screenshot(config);
            await page.close();
            resolve(buffer);

        } catch (ex) {
            reject(ex.message);
        }
    });
}
We recently discovered that this is a known issue with puppeteer loading the resources in the page. It needs to wait until all network activity is idle before generating the file buffer.

Post by RedTeam »

We are testing your version in you example of export pdf and we get a error. Could you check this problem?
exportpdf.png
exportpdf.png (50.45 KiB) Viewed 2313 times

Post by arcady »

Thank you for the report. It should be fixed now.

Post Reply