简体   繁体   中英

Is it possible to embed an iframe using html-pdf on Express?

I have the following file as a html just for testing purposes:

    <div id="pageHeader">
        <h1>Page Header</h1>
        <p>test</p>
    </div>
    <div>
        <iframe
            title="something"
            src="https://geoportal.implanchihuahua.org/sigmun/apps/webappviewer/index.html?id=92971c77b4b047f89d35b08791a83db9"
            width='100%'
            height='100%'>
        </iframe>

The question might seem kind of weird and obvious, but I wanted to give it a try. Is it possible to embed an iframe component and export it as an image to a pdf file using the library html-pdf?

My sample method to make the PDF on an endpoint is the following:

    let baseFile = fs.readFileSync('./src/templates/test.html', 'utf8');
    console.log(baseFile);
    pdf.create(baseFile).toFile('./test.pdf', (err, res) => {
        if (err){
            console.log(err);
        }else {
            console.log(res);
        }
    })

Without html-pdf active I can not say for definite, However the css styling of the iFrame will potentially need to be obtained and applied by you for your own html-pdf rendering, here we can see using skia engine, that there is a mixture of good and bad PDF rendering in parts of the iFrame.

Customisation of.css is likely to be complex or varied from case to case.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM