HPDF_SetCompressionMode() not working in Libharu

戏子无情 提交于 2020-01-07 03:02:38

问题


I am generating Pdf files using LibHaru libraries. My code is following

#include <iostream>
#include "hpdf.h"


using namespace std;

void error_handler(HPDF_STATUS   error_no,  HPDF_STATUS   detail_no, void *user_data)
{
}

int main()
{
    cout<<"Compression"<<endl;

    HPDF_Doc pdf = HPDF_New(error_handler, NULL);

    if (!pdf) 
        return 0;
    HPDF_STATUS Status = HPDF_SetCompressionMode(pdf, HPDF_COMP_ALL);


    return 0;
}

PROBLEM: I debugged the code and found that HPDF_SetCompressionMode() returns 4129, which is the error code for Invalid value set when invoking HPDF_SetCommpressionMode(). .


回答1:


If you step into the code, you will see you are getting the error because the ZLIB compression library was not compiled into your copy of HaruPDF.

First: comment out this line in ..\win32\include\hpdf_config.h:

/* zlib is not available */
//#define LIBHPDF_HAVE_NOZLIB

Second: find, download and unzip the ZLIB code. You can obtain the source from the following Website:

http://www.zlib.net/

Third: tell HaruPDF where it can find the ZLIB code, and recompile HaruPDF.

You should now be able to use compression.

Ain't Open Source grand?



来源:https://stackoverflow.com/questions/40111433/hpdf-setcompressionmode-not-working-in-libharu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!