Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.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
Php 如何将html页面转换为pdf,并在每个pdf页面中用标题分隔内容?_Php_Html_Css_Pdf_Printing - Fatal编程技术网

Php 如何将html页面转换为pdf,并在每个pdf页面中用标题分隔内容?

Php 如何将html页面转换为pdf,并在每个pdf页面中用标题分隔内容?,php,html,css,pdf,printing,Php,Html,Css,Pdf,Printing,我正在使用css来打破需要在新的pdf页面中打印的内容,我想在每个pdf页面上包含页眉/页脚,我尝试使用固定css/以及页边空白,但这适用于第一页,而不是后续页面。页脚与页面内容重叠 mypage.php <?php //call_db //call_func ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1

我正在使用css来打破需要在新的pdf页面中打印的内容,我想在每个pdf页面上包含页眉/页脚,我尝试使用固定css/以及页边空白,但这适用于第一页,而不是后续页面。页脚与页面内容重叠

mypage.php

<?php //call_db
//call_func
 ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>My Print Page</title>
    <style>
    body {
        background-color: white;
        color: black;
        font-size: small;
        font-family: sans-serif, helvetica, tahoma, arial;
        margin: 20%;
    }

    .page-break  { 
        display:block; 
        page-break-before:always; 
    }

     @media screen {
            div.divFooter {
                display: none;
            }
            div.divHeader {
                display: none;
            }
        }
        @media print {
            div.divFooter {
                position: fixed;

                bottom: 0;
            }
            div.divHeader {
                position: fixed;

                top: 0;
            }
        }

    </style>

    <script type="text/javascript" src="jquery.js" > </script> 
    <script type="text/javascript">
        $(document).ready(function(){
            window.print(); 
            });
    </script>

    </head>

    <body>

//call sql query for content // A collection of 200 lists

    <div class="divHeader"> <h1 align="center" style="font-size:36px;"> THE GAME OF THORNES</h1> </div>


    <h1>Sean's CSS Print vs. Screen Example</h1>
    <h2>Lesson 1</h2>
    <p>This is my first Page in the document.</p>

    <div class="page-break"></div>
    <h2>Lesson 2</h2>
    <p>Examples and theory of lesson2</p>

    <div class="page-break"></div>
    <h2>Lesson 3</h2>
    <p>Examples and theory of lesson2</p>

    <div class="divFooter">UNCLASSIFIED </div>
    </body>
    </html>

我的打印页
身体{
背景色:白色;
颜色:黑色;
字体大小:小;
字体系列:无衬线、helvetica、tahoma、arial;
利润率:20%;
}
.分页符{
显示:块;
前分页符:始终;
}
@媒体屏幕{
div.divFooter{
显示:无;
}
div.divHeader{
显示:无;
}
}
@媒体印刷品{
div.divFooter{
位置:固定;
底部:0;
}
div.divHeader{
位置:固定;
排名:0;
}
}
$(文档).ready(函数(){
window.print();
});
//调用sql查询内容//包含200个列表的集合
荆棘游戏
肖恩的CSS打印与屏幕示例
第1课
这是我在文件中的第一页

第二课 第二课实例与理论

第三课 第二课实例与理论

未分类

**我正在添加PHP标签,就好像您有其他更好的方法从db打印内容一样,请建议

我认为这是这个的复制品, 必须使用pdf转换器库向pdf添加页眉和页脚


我已经习惯了我的项目。您也可以使用它。

对于PHP来说,这对于生成一些小型的相同类型的输出(例如仅表格或收据)非常有用。。但如果我需要从db输出大量数据,并用css和其他东西输出为html。假设一本具有多种功能的书是最终输出。。直接将html输出为pdf会更好吗?我不知道如何直接将html输出为pdf,如果你能找到方法,我将非常感谢与我分享。