使用PHP生成PDF格式的出勤列表

时间:2020-12-07 22:23:00

I want to create an attandence list from the student's database in PDF using PHP. I want the columns student.name, student_id, student_rollno and a column for sign for signing to be made as table in pdf. How can I do this?

我想使用PHP从学生的PDF数据库中创建一个attandence列表。我希望列号student.name,student_id,student_rollno和用于签名的标记列以pdf格式显示。我怎样才能做到这一点?

6 个解决方案

#1


Well, this is a somewhat general question but I'll take the PDF part at least and offer up the following PHP class : http://www.tcpdf.org

嗯,这是一个有点笼统的问题,但我至少会参考PDF部分并提供以下PHP类:http://www.tcpdf.org

This class works without having to enable the pdf extension on your server which is a huge benefit. But beyond that, it also supports simple HTML including the 'table' tag. If you know HTML, you can generate simple PDFs based on that knowledge.

这个类无需在服务器上启用pdf扩展即可运行,这是一个巨大的好处。但除此之外,它还支持简单的HTML,包括'table'标签。如果您了解HTML,则可以基于该知识生成简单的PDF。

Once you've retrieved the data from your database, it's really just a matter of assembling an HTML string:

从数据库中检索数据后,只需要组装一个HTML字符串:

$html = '<table>';
foreach ($results as $student) {
     $html .= '<tr><td>'.$student->name.'</td></tr>';
}
$html .= '</table>';

$tcpdf->writeHtml($html); 

...etc.

A full fledged example of the writeHtml method can be found here: http://www.tecnick.com/pagefiles/tcpdf/example_006.phps

可以在此处找到writeHtml方法的完整示例:http://www.tecnick.com/pagefiles/tcpdf/example_006.phps

How you retrieve the data is very much dependent on your project.

如何检索数据在很大程度上取决于您的项目。

#2


I recommend TCPDF. http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf

我推荐TCPDF。 http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf

It is a library that converts html to pdf, so you would run your db query in php and output the results in html. You can reference the php file that generates the html with a tcpdf function.

它是一个将html转换为pdf的库,因此您可以在php中运行db查询并以html格式输出结果。您可以使用tcpdf函数引用生成html的php文件。

See examples here: http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf_examples

请参阅此处的示例:http://www.tecnick.com/public/code/cp_dpage.php?beforepp_dp = tcpdf_examples

/////////////////////

You can also use the DOMPDF: http://www.digitaljunkies.ca/dompdf/ It is a little more recent than tcpdf and a little easier to use

你也可以使用DOMPDF:http://www.digitaljunkies.ca/dompdf/它比tcpdf更新一点,更容易使用

#3


Last time I built a PDF output module in PHP, I used LaTeX. Beautiful output and easily restylable.

上次我用PHP构建了一个PDF输出模块,我使用了LaTeX。美观的输出和易于重新设计。

#4


You could use the pdflib extension for php to do this.

您可以使用php的pdflib扩展来执行此操作。

Take a look at this tutorial for more details.

请查看本教程以获取更多详细信息。

#5


You can use the PDF library in PHP

您可以在PHP中使用PDF库

You will need to use the functions

您将需要使用这些功能

string PDF_fit_table  ( resource $pdfdoc  , int $table  , float $llx  , float $lly  , float $urx  , float $ury  , string $optlist  )

int PDF_add_table_cell  ( resource $pdfdoc  , int $table  , int $column  , int $row  , string $text  , string $optlist  )

you can also try FPDF, Check out this tutorial. Basically, you need to output your database results in the form of a table.

您也可以尝试FPDF,查看本教程。基本上,您需要以表格的形式输出数据库结果。

Other Alternatives : TCPDF, EZPDF

其他替代方案:TCPDF,EZPDF

#6


go for FPDF, http://www.fpdf.org/ - the best thing that is there...

去FPDF,http://www.fpdf.org/ - 那里最好的东西......

#1


Well, this is a somewhat general question but I'll take the PDF part at least and offer up the following PHP class : http://www.tcpdf.org

嗯,这是一个有点笼统的问题,但我至少会参考PDF部分并提供以下PHP类:http://www.tcpdf.org

This class works without having to enable the pdf extension on your server which is a huge benefit. But beyond that, it also supports simple HTML including the 'table' tag. If you know HTML, you can generate simple PDFs based on that knowledge.

这个类无需在服务器上启用pdf扩展即可运行,这是一个巨大的好处。但除此之外,它还支持简单的HTML,包括'table'标签。如果您了解HTML,则可以基于该知识生成简单的PDF。

Once you've retrieved the data from your database, it's really just a matter of assembling an HTML string:

从数据库中检索数据后,只需要组装一个HTML字符串:

$html = '<table>';
foreach ($results as $student) {
     $html .= '<tr><td>'.$student->name.'</td></tr>';
}
$html .= '</table>';

$tcpdf->writeHtml($html); 

...etc.

A full fledged example of the writeHtml method can be found here: http://www.tecnick.com/pagefiles/tcpdf/example_006.phps

可以在此处找到writeHtml方法的完整示例:http://www.tecnick.com/pagefiles/tcpdf/example_006.phps

How you retrieve the data is very much dependent on your project.

如何检索数据在很大程度上取决于您的项目。

#2


I recommend TCPDF. http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf

我推荐TCPDF。 http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf

It is a library that converts html to pdf, so you would run your db query in php and output the results in html. You can reference the php file that generates the html with a tcpdf function.

它是一个将html转换为pdf的库,因此您可以在php中运行db查询并以html格式输出结果。您可以使用tcpdf函数引用生成html的php文件。

See examples here: http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf_examples

请参阅此处的示例:http://www.tecnick.com/public/code/cp_dpage.php?beforepp_dp = tcpdf_examples

/////////////////////

You can also use the DOMPDF: http://www.digitaljunkies.ca/dompdf/ It is a little more recent than tcpdf and a little easier to use

你也可以使用DOMPDF:http://www.digitaljunkies.ca/dompdf/它比tcpdf更新一点,更容易使用

#3


Last time I built a PDF output module in PHP, I used LaTeX. Beautiful output and easily restylable.

上次我用PHP构建了一个PDF输出模块,我使用了LaTeX。美观的输出和易于重新设计。

#4


You could use the pdflib extension for php to do this.

您可以使用php的pdflib扩展来执行此操作。

Take a look at this tutorial for more details.

请查看本教程以获取更多详细信息。

#5


You can use the PDF library in PHP

您可以在PHP中使用PDF库

You will need to use the functions

您将需要使用这些功能

string PDF_fit_table  ( resource $pdfdoc  , int $table  , float $llx  , float $lly  , float $urx  , float $ury  , string $optlist  )

int PDF_add_table_cell  ( resource $pdfdoc  , int $table  , int $column  , int $row  , string $text  , string $optlist  )

you can also try FPDF, Check out this tutorial. Basically, you need to output your database results in the form of a table.

您也可以尝试FPDF,查看本教程。基本上,您需要以表格的形式输出数据库结果。

Other Alternatives : TCPDF, EZPDF

其他替代方案:TCPDF,EZPDF

#6


go for FPDF, http://www.fpdf.org/ - the best thing that is there...

去FPDF,http://www.fpdf.org/ - 那里最好的东西......