有没有办法使用 FPDF 库设置输出 pdf 的 DPI


Is there a way to set the DPI of output pdf using FPDF library?

有没有办法使用 FPDF 库在不影响其大小的情况下降低输出 pdf 的 DPI?

据我所知,PDF 文档没有 DPI 设置,因为它们是矢量对象。我假设您实际上指的是嵌入式光栅图像(JPEG,GIF...在这种情况下,只需查看 Image() 函数的文档:如果您写入负值,第四和第五个参数($w$h )可以表示所需的 DPI:

// Insert a logo in the top-left corner at 300 dpi
$pdf->Image('logo.png',10,10,-300);

No.但是,如果您正在考虑减小文档的大小,则可以使用FPDF SetCompression()方法:

$pdf = new FPDF();
$pdf->SetCompression(true);

在他们的网页上有更多详细信息,在"手册"部分:http://www.fpdf.org/en/doc/setcompression.htm。

function toMM($v) {
   return ($v * 26.2) / 25.4;
}

http://www.dallinjones.com/2008/07/how-to-convert-from-pixels-to-millimeters/comment-page-1/#comment-1079

如果您

正在寻找一种在 mPDF 中设置转换 px -> mm 的方法:

http://mpdf1.com/manual/index.php?tid=449

http://mpdf1.com/manual/index.php?tid=148