xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

print pdf bug & DOCTYPE

OK

with <!DOCTYPE html>


<!DOCTYPE html>
<html lang="zh-Hans">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="author" content="xgqfrms">
    <meta name="generator" content="VS code">
    <title></title>
</head>

<body>
    <section>
        <h1>
            <a href="https://feiqa.xgqfrms.xyz/index.html"></a>
        </h1>
    </section>
</body>

</html>

error

no <!DOCTYPE html>


<html lang="zh-Hans">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="author" content="xgqfrms">
    <meta name="generator" content="VS code">
    <title></title>
</head>

<body>
    <section>
        <h1>
            <a href="https://feiqa.xgqfrms.xyz/index.html"></a>
        </h1>
    </section>
</body>

</html>



let html = document.querySelector(`html`);
// let text = html.innerHTML;

text += `
    <style>
        @media print {
            @page {
                margin: 0;
            }
        }
    </style>
`;


@media print {
  @page { margin: 0; }
  body { margin: 1.6cm; }
}

https://stackoverflow.com/questions/46077392/additional-options-in-chrome-headless-print-to-pdf

?

refs



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


原文地址:https://www.cnblogs.com/xgqfrms/p/9732276.html