| 方案 | 優點 | 缺點 |
|---|---|---|
| Adobe Acrobat SDK (COM) | 官方、功能全 | 需安裝 Acrobat Pro、分發麻煩、VC6 配置繁瑣 |
| PDFium / MuPDF (C/C++ 庫) | 開源、輕量、無依賴 | 需編譯靜態庫、API 學習成本 |
| 商業庫 | 文檔完善、技術支持 | 收費 |
pdfium.lib。pdfium.lib,包含目錄添加 public/。#include "fpdfview.h"
void getPageSize(const char* path) {
FPDF_LIBRARY_INIT();
FPDF_DOCUMENT doc = FPDF_LoadDocument(path, NULL);
int count = FPDF_GetPageCount(doc);
for (int i = 0; i < count; i++) {
FPDF_PAGE page = FPDF_LoadPage(doc, i);
double w = FPDF_GetPageWidth(page);
double h = FPDF_GetPageHeight(page); // 單位:點 (1/72 inch)
printf("Page %d: %.2f x %.2f pt\n", i+1, w, h);
FPDF_ClosePage(page);
}
FPDF_CloseDocument(doc);
FPDF_LIBRARY_DESTROY();
}