PHP PDF 创建 A3、A4 和 A5 [英] PHP PDF creation A3, A4 and A5

查看:86
本文介绍了PHP PDF 创建 A3、A4 和 A5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑使用 PHP 生成 PDF 以输出各种类型的文档大小,A3、A4、A5.

I'm looking at generating PDFs to output various types of document sizes, A3, A4, A5 using PHP.

目前我有一个 div,该 div 在该区域内具有绝对定位的各种 div.

Currently I have a div that has various divs within this area that are positioned absolutely.

我想做的是让这个 div 具有固定的高度和宽度,但是当我保存内容时,它可以用于 A4、A3 和 A5 打印尺寸.

What I'm looking to do though is to have this div a fixed height a width, but when I save the contents, it can be used for A4, A3 and A5 print sizes.

实现这一目标的最佳方法是什么?

What's the best way of achieving this?

谢谢

我还想为每种类型添加全宽背景图像?

I am also trying to add a full width background image for each type?

此外,为了创建每个文档,div 是否需要具有特定的高度/宽度?​​

Also, does the div need to be a specific height/width in order to create each document?

我想要一个区域",我可以在其中查看文档的 HTML.所以,如果我选择 A3,它会将 PDF 保存为 A3,背景图像全宽,所有定位的 div 都在正确的位置.

I'd like to have an 'area' where I can view the HTML of document. So, if I select A3, it will then save the PDF as A3, with the background image full width and all the positioned divs in the correct places.

推荐答案

使用 MPDF

mPDF 是一个 PHP 类,它从 UTF-8 编码的 HTML 生成 PDF 文件.它基于 FPDFHTML2FPDF,具有许多增强功能.

mPDF is a PHP class which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF, with a number of enhancements.

我编写了 mPDF 以从我的网站即时"输出 PDF 文件,以处理不同的语言.它比原始脚本慢,例如HTML2FPDF 并在使用 Unicode 字体时生成更大的文件,但对 CSS 样式等的支持已大大增强 - 请参阅功能.

I wrote mPDF to output PDF files 'on-the-fly' from my website, handling different languages. It is slower than the original scripts e.g. HTML2FPDF and produces larger files when using Unicode fonts, but support for CSS styles etc. has been much enhanced - see the features.

请参阅示例,并随时下载.mPDF 有相当丰富的在线文档手册.

Please see the examples, and feel free to download it. There is quite an extensive online documentation manual for mPDF.

这是您可以传递给默认构造函数的参数列表.

Here is the list of arguments you can pass to default constructor.

$mpdf = new mPDF('',    // mode - default ''
 '',    // format - A4, for example, default ''
 0,     // font size - default 0
 '',    // default font family
 15,    // margin_left
 15,    // margin right
 16,     // margin top
 16,    // margin bottom
 9,     // margin header
 9,     // margin footer
 'L');  // L - landscape, P - portrait

这篇关于PHP PDF 创建 A3、A4 和 A5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆