在 Mac 上將 PHP/MySQL/HTML 生成的報告轉換為 PDF 格式 (Convert reports generated in PHP/MySQL/HTML to PDF format on a Mac)


問題描述

在 Mac 上將 PHP/MySQL/HTML 生成的報告轉換為 PDF 格式 (Convert reports generated in PHP/MySQL/HTML to PDF format on a Mac)

I'm working on some pages that combine html, php, and mysql to create reports from a mysql database. I'd like to be able to create a button to convert these reports to PDF files for the user to download. Any idea of how to approach this (on a Mac, I might add)?

Thanks!


參考解法

方法 1:

I've used PDFlib a lot in my projects. You can build PDFs from the ground up programmatically, or use a template PDF and add new things on top of that. The downside is that it's a commercial library, and the licensing cost is fairly steep.

方法 2:

You can use libraries to allow you to create pdf files directly on your server  side. The most recommended one for such use is tcpdf.  This will allow you to custom format your reposrt and then convert them to pdf on the fly.

方法 3:

We use TCPDF for some of our reports. It's pretty simple PHP syntax, not hard to figure out, but it is a tad limited. I've heard good things about FPDF as well, which seems to have a few more features and is about as easy to use.

Unfortunately, you probably won't find much more than that using just PHP. You could generate XML/XDP files to populate a pre-made PDF file (we do this on one such report), but it introduces extra steps and large possibilities for glitches.

(by AshtonMarc Bthanedarshmeeps)

參考文件

  1. Convert reports generated in PHP/MySQL/HTML to PDF format on a Mac (CC BY-SA 3.0/4.0)

#MySQL #pdf-generation #PHP #macos






相關問題

MySQL WHERE 時間戳 >= SUBDATE(MAX(timestamp), INTERVAL 5 DAY) (MySQL WHERE timestamp >= SUBDATE(MAX(timestamp), INTERVAL 5 DAY))

無法連接 - 數據庫或編碼錯誤 (Could Not Connect - Database or Coding Error)

在 MySQL 中查看授權 (View grants in MySQL)

修改列與更改列 (Modify column Vs change column)

SQL 查詢沒有返回任何值 (SQL query did not return any values)

IFNULL trong vấn đề tốc độ mysql (IFNULL in mysql speed issue)

Tối ưu hóa truy vấn MySQL PHP - Phản hồi (MySQL PHP Query Optimization - Feedbacks)

我將如何從我的數據庫中顯示用戶個人資料圖片? (How would I go about displaying user profile pictures from my database?)

自聯接以比較同一張表中的季度數據? (Self join to compare quarterly data from same table?)

設置默認數據庫連接 Mysql Workbench 5.2 (Set Default Database connection Mysql Workbench 5.2)

在 Mac 上將 PHP/MySQL/HTML 生成的報告轉換為 PDF 格式 (Convert reports generated in PHP/MySQL/HTML to PDF format on a Mac)

MYSQL查詢神奇地抓取數值 (MYSQL query magically grabs numeric value)







留言討論