html – css3页面媒体无法在任何浏览器中运行

您好我使用CSS3页面媒体模块http://www.w3.org/TR/css-gcpm-3/直接从浏览器打印HTML内容到PDF但我没有得到任何浏览器来处理它.我的工作如下.

Box-sizing: border-Box;
        -moz-Box-sizing: border-Box;
    }


        @page {
            size: letter;
            margin: 20mm 25mm;
        }
        @page {
            @top-center {
                content: element(pageHeader);
            }
        }

        @page  {
            @bottom-center {
                content: element(pageFooter);
            }
        }
        #pageHeader {
          position: running(pageHeader);
        }
        #pageFooter{
          position: running(pageFooter);
        }

    }
irst page.displayed in the examples above,or can be set for each side individually,as shown in the code snippet below,where the top and bottom margins are set to 2cm,and the left and right margins are set to 3cm:
The margins can be set as displayed in the examples above,and the left and right margins are set to 3cm:displayed in the examples above,and the left and right margins are set to 3cm:

displayed in the examples above,and the left and right margins are set to 3cm:

它对我来说在任何浏览器中都不起作用.我已经在最新的Chrome,FF,Opera,Safari中进行了测试.它应该在每个页面显示页眉和页脚.标题旨在显示在每个页面底部的每个页面和页脚的顶部.任何人都可以拥有实际工作的CSS3页面媒体模块元素的工作示例.此外,我不是寻找页眉和页脚的绝对或固定解决方案.我已经尝试了它,除了单页之外它不起作用.我缩短了这个问题的文本内容,但它可以复制和过去生成多页文档,以查看没有页眉和页脚的多个页面.页眉和页脚div保持在顶部.

最佳答案
它目前在任何最终用户浏览器中都不受支持,但PrinceXML支持它,这是一个用于生成PDF的专用引擎.见the CSS3 support for Margin boxes.

PrinceXML是一个商业产品,但我用它来从HTML源创建小说的印刷版本.它支持与打印相关的功能的完整列表. (我不以任何方式与他们联系.)

相关文章

vue阻止冒泡事件 阻止点击事件的执行 <div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些