如何将页面中的 MySQL 数据转换为 PDF [英] How to convert MySQL data from page into PDF
问题描述
我想在单击图像时将从 mySQL 数据库中检索到的数据转换为 PDF.我想在我网站上的每篇文章上放置图片,当有人点击该图片时,会自动获得该文章的 pdf 版本.我怎样才能做到这一点?请帮帮我.
I want to convert data that I retrieve from mySQL database into PDF on image click. I want to place image on each article from my website, and when someone click on that image, automaticaly gets pdf version of the article. How can I do that? Please help me.
为了从 MySQL 检索数据,我使用这个:
For retrieve data from MySQL I use this:
<?php
$id = (int)$_GET['vij'];
$sql="SELECT id,news_title,news_text,publish_date,hit_count FROM news WHERE id=$id";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
?>
然后调用:
<? echo $rows['news_text']; ?>
推荐答案
你可以试试 TCPD - 一个 PHP类,不需要任何额外的库.有很多例子很容易使用.它支持 UTF-8,并具有许多其他功能.只需访问该网站.
You could try TCPDF - a PHP class, that does not require any additional libraries. There are a lot of examples which are quite easy to use. It supports UTF-8, and has a lot of other features. Just visit the site.
这篇关于如何将页面中的 MySQL 数据转换为 PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!