简体   繁体   English

FPDF 包含一个 php 文件?

[英]FPDF including a php file?

I want to send a dynamic page for printing to labels using Fpdf, however I'm not entirely sure how to get Fpdf to display the contents of my php file.我想使用 Fpdf 发送动态页面以打印到标签,但是我不完全确定如何让 Fpdf 显示我的 php 文件的内容。

The php file renders a page with the users url, avatar, custom user background and name in a contactcard.php file. php 文件呈现一个页面,其中包含用户 url、头像、自定义用户背景和contactcard.php文件中的名称。

How would i go about sending this to PDF, using Fpdf?我 go 如何使用 Fpdf 将此发送到 PDF?

I have tried creating a function but it will not print images in the PDF.我尝试创建一个 function,但它不会打印 PDF 中的图像。

I've done a similar thing with a real estate property listing.我对房地产清单做了类似的事情。 I've output text and images to a pdf for saving or printing using fpdf and php.我已经将 output 文本和图像发送到 pdf,以便使用 fpdf 和 php 进行保存或打印。

I used a form with hidden fields.我使用了一个带有隐藏字段的表单。 Click the form button then it goes to the fpdf page.单击表单按钮然后转到 fpdf 页面。 The form uses Post so I can retrieve the data on the fpdf page with something like...该表单使用 Post,因此我可以使用类似...的方式检索 fpdf 页面上的数据。

$username = $_POST(username);

The way I've included images is to link to the images directly, well kind of.我包含图像的方式是直接链接到图像,很好。 I have an id retrieved from the database which I include in the file name to display the correct image eg我从数据库中检索了一个 id,我将其包含在文件名中以显示正确的图像,例如

$image = "http://www.yourdomain.com/img/avatar_$id.jpg";

Then you would display them with fpdf like...然后你会用 fpdf 显示它们,比如......

$pdf->Cell(10,0,$username,0,0);
$pdf->Image($image,30,36);

You could use sessions so you don't have to include a form.您可以使用会话,这样您就不必包含表格。 That should work also.那也应该工作。 Might be more suitable in your case.可能更适合你的情况。

I hope this is what you're after.我希望这就是你所追求的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM