using namespace std;
using namespace mupdf;
FzPixmap
loadPdfPage (const string &path, int page_number)
auto doc = FzDocument (path.c_str ());
auto page = doc.fz_load_page (page_number);
// 取得页面大小
auto rect = page.fz_bound_page ();
auto width = rect.x1 - rect.x0;
auto height = rect.y1 - rect.y0;
cout << "pdf page " << page_number << " size: " << width << "," << height
<< endl;
// 设置缩放比例
auto matrix = FzMatrix::fz_scale (1.0f, 1.0f);
// 设置旋转角度
matrix = fz_pre_rotate (matrix, 0.0f);
auto pixmap = page.fz_new_pixmap_from_page (matrix, fz_device_rgb (), 0);
return pixmap;
mupdf用于将pdf转化为图片版本:/home/zjm/activemq/mupdf-1.11-source编译 make prefix=/usr/local install
prefix后面跟的是目标目录,正常应为/usr/local/mupdf现象:
1、无权限:用sudo
2、glfw未找到,需要自己编译glfw
编译步骤:1、在mupdf-1.11-source目录下cd
有时候需要从pdf中提取图片,那么此时可以使用mupdf库,如果采用vs2013版本,那么此时就需要考虑mupdf库的版本了,编译过多次之后,最终成功的版本是1.15.0,代码实例如下:
// TestPdf2png.cpp : 定义控制台应用程序的入口点。
#include "stdafx.h"
* pdfextract -- the ultimate way to extract images and fonts from pdfs
#include "mupdf/fitz.h