Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 打印带有幻影js-@页面规则的PDF不起作用_Javascript_Css_Pdf_Printing_Phantomjs - Fatal编程技术网

Javascript 打印带有幻影js-@页面规则的PDF不起作用

Javascript 打印带有幻影js-@页面规则的PDF不起作用,javascript,css,pdf,printing,phantomjs,Javascript,Css,Pdf,Printing,Phantomjs,我们使用phantom JS从网页(intranet站点)打印PDF。我的问题不在于整个样式,而在于@page规则。@page规则中的所有样式均未应用 你知道这是什么吗 @page { size: auto; padding: 0 !important; margin: 10mm !important; page-break-before: avoid; border: none !important; page-break-after: avoi

我们使用phantom JS从网页(intranet站点)打印PDF。我的问题不在于整个样式,而在于@page规则。@page规则中的所有样式均未应用

你知道这是什么吗

@page {
    size: auto;
    padding: 0 !important;
    margin: 10mm !important;
    page-break-before: avoid;
    border: none !important;
    page-break-after: avoid;
    page-break-inside: avoid;
    overflow: hidden !important;
    box-sizing: border-box !important;

    @top-left-corner {
        content: ""; /* has to be specified! */
        background-color: rgba(42, 201, 80, 0.220);
        border-bottom: solid green;
    }
}

如图所示,描述了浏览器对@页的支持。

我看不出CSS有问题,但可能它包含在已设置为media
screen
的样式表中,在这种情况下,它将被忽略

导入样式表时,请确保使用媒体类型
print
all


我认为在导出为PDF时,phantomJS会自动添加@media print类,这可能会覆盖您为@page设置的许多css规则。

希望您使用的是css3。您可以指定浏览器吗