C++实现PDF转PNG图片
闲来无事,同事吐槽各种PDF转图片工具都不好用,也不好找,花了两天做了一套工具出来给他用,美滋滋......
* 支持指定页导出
* 支持大小设置导出
* 支持透明/黑白导出
* 支持所有页导出
* 小巧方便、使用容易
ReadMe
1.Support pdf to png/jpg/text/html/ppm
2.Dll usage (C++/C#/VB/JAVA)
std::wstring wDllName = L"D:\\pdftowayx86.dll";
if (sizeof(long) < sizeof(void*))
{
wDllName = L"D:\\pdftowayx64.dll";
}
HMODULE hModule = LoadLibraryW(wDllName.c_str());
if (hModule != NULL)
{
typedef int(__stdcall* PFN_Get)(char*, int);
typedef int(__stdcall* PFN_Put)(const char*);
typedef int(__stdcall* PFN_Task)(int, char**);
PFN_Get fnContactUs = (PFN_Get)GetProcAddress(hModule, "ContactUs");
PFN_Get fnGetUserKey = (PFN_Get)GetProcAddress(hModule, "GetUserKey");
PFN_Put fnPutLicenseCnt = (PFN_Put)GetProcAddress(hModule, "PutLicenseCnt");
PFN_Put fnPutLicenseKey = (PFN_Put)GetProcAddress(hModule, "PutLicenseKey");
PFN_Task fnPdfToPngTask = (PFN_Task)GetProcAddress(hModule, "pdftopng_task");
PFN_Task fnPdfDetachTask = (PFN_Task)GetProcAddress(hModule, "pdfdetach_task");
PFN_Task fnPdfFontsTask = (PFN_Task)GetProcAddress(hModule, "pdffonts_task");
PFN_Task fnPdfImagesTask = (PFN_Task)GetProcAddress(hModule, "pdfimages_task");
PFN_Task fnPdfInfoTask = (PFN_Task)GetProcAddress(hModule, "pdfinfo_task");
PFN_Task fnPdfToHtmlTask = (PFN_Task)GetProcAddress(hModule, "pdftohtml_task");
PFN_Task fnPdfToPpmTask = (PFN_Task)GetProcAddress(hModule, "pdftoppm_task");
PFN_Task fnPdfToPsTask = (PFN_Task)GetProcAddress(hModule, "pdftops_task");
PFN_Task fnPdfToTextTask = (PFN_Task)GetProcAddress(hModule, "pdftotext_task");
char szUserKey[1024] = { 0 };
char szContactUs[1024] = { 0 };
fnGetUserKey(szUserKey, 1024);//send to me with email, i will give your license.
fnContactUs(szContactUs, 1024);
fnPutLicenseCnt("0"),fnPutLicenseKey("BFD5FEE7B051995FF571871BB054506E");
char* argv[] = { "","-f","1","-l","1","-r","102.3","-alpha","d:\\test-debug.pdf","d:\\pngs\\test-" };
int argc = sizeof(argv) / sizeof(*argv);
int ret = fnPdfToPngTask(argc, argv);
printf("%d\n", ret);
}
如果阁下有意,可以通过邮件联系我,价格好商量,绝对亲民。