在创建 pdf 文件期间处理 HPDF_FAILD_TO_ALLOC_MEM
handle HPDF_FAILD_TO_ALLOC_MEM during creation of pdf file
我正在使用 libharu 库创建 pdf 并进入系统
hPDF error error_no=4117, detail_no=0 which HPDF_FAILD_TO_ALLOC_MEM
我想知道这个错误背后的原因。应用程序崩溃了。有没有办法处理这个错误,因为我无法生成 pdf
**Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4133, detail_no=0
***Error: (Report::NextPage) current page is empty
***Fatal: *************************** FATAL ERROR ***************************
***Fatal: /usr/lib64/libc.so.6(+0x35270) [0x7ffff6801270]
***Fatal: HPDF_Page_SetWidth+0x49 [0x596159]
我已经尝试编写小程序并尝试重现此问题,但没有遇到任何错误。
#include<iostream>
#include "hpdf.h"
using namespace std;
class Report {
public:
HPDF_Doc document;
HPDF_Page currentpage;
void static error_handler (HPDF_STATUS,HPDF_STATUS,void *);
void NextPage();
Report(string, string, int);
~Report();
string m_ReportFilePath;
};
void Report::NextPage()
{
if (document == NULL)
cerr << "(Report::NextPage) document is empty" << endl;
currentpage = HPDF_AddPage(document);
if (currentpage == NULL)
cerr << "(Report::NextPage) current page is empty" << endl;
cout<<currentpage<<" "<<std::endl;
HPDF_Page_SetWidth(currentpage, 595.3);
}
Report::Report(string fileName, string booktitle, int marg) {
m_ReportFilePath = fileName;
document = HPDF_New(Report::error_handler, &document);
NextPage(); // Create new page
}
Report::~Report()
{
}
void Report::error_handler(HPDF_STATUS error_no,
HPDF_STATUS detail_no, void *user_data)
{
cout << "hPDF error error_no=" << (HPDF_UINT) error_no <<
", detail_no=" << (HPDF_UINT) detail_no << endl;
}
int main() {
Report r("test.pdf", "test", 50);
return 0;
}
编译命令
/depot/gcc-4.8.2/bin/g++ -rdynamic -Wall -I../include -std=c++11 -c lib_haru.cpp -o lib_haru -L../libs -lhpdf
/depot/gcc-4.8.2/bin/g++ -o libh lib_haru.o -rdynamic -L../libs -lm -ltcl8.4 -lxml2 -lz -lpng -lhpdf -lncurses -lreadline -Wl,-rpath,/depot/gcc-4.8.2/lib64
OBJECTS=$(addsuffix .o,$(basename $(SRC)))
VERSION=$(USER)
CXXFLAGS=-g -D Version=$(VERSION) -rdynamic -Wall -I../include
LDFLAGS=-rdynamic -L../libs -lm -ltcl8.4 -lxml2 -lz -lpng -lhpdf -lncurses -lreadline -Wl,-rpath,/depot/gcc-4.8.2/lib64
#CXX= /usr/bin/g++
CXX= /depot/gcc-4.8.2/bin/g++
在本机编译时出现问题
Linux Machine 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
GDB 输出
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6852c31 in __strlen_sse2 () from /usr/lib64/libc.so.6
可能的问题
currentpage = HPDF_AddPage(document);
if (currentpage == NULL)
logerror << "(Report::NextPage) current page is empty" << endl;
#value of currentpage is 0
我唯一一次看到此错误是在 PDF 变得如此之大以至于占用了所有可用内存时。就我而言,我正在使用 PDF 基元创建图像(例如填充的矩形)。
您确实没有提供足够的信息来帮助诊断问题。 libHaru 版本,32 位或 64 位,通常您尝试做的事情会有帮助。
I have tried to written small program and try to reproduce this issue but did not encounter any error.
我建议你把小程序做大,直到你能重现问题,如果仍然不清楚post代码,以便我们调查和评论。
我正在使用 libharu 库创建 pdf 并进入系统
hPDF error error_no=4117, detail_no=0 which HPDF_FAILD_TO_ALLOC_MEM
我想知道这个错误背后的原因。应用程序崩溃了。有没有办法处理这个错误,因为我无法生成 pdf
**Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4117, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4177, detail_no=0
***Error: hPDF error error_no=4133, detail_no=0
***Error: (Report::NextPage) current page is empty
***Fatal: *************************** FATAL ERROR ***************************
***Fatal: /usr/lib64/libc.so.6(+0x35270) [0x7ffff6801270]
***Fatal: HPDF_Page_SetWidth+0x49 [0x596159]
我已经尝试编写小程序并尝试重现此问题,但没有遇到任何错误。
#include<iostream>
#include "hpdf.h"
using namespace std;
class Report {
public:
HPDF_Doc document;
HPDF_Page currentpage;
void static error_handler (HPDF_STATUS,HPDF_STATUS,void *);
void NextPage();
Report(string, string, int);
~Report();
string m_ReportFilePath;
};
void Report::NextPage()
{
if (document == NULL)
cerr << "(Report::NextPage) document is empty" << endl;
currentpage = HPDF_AddPage(document);
if (currentpage == NULL)
cerr << "(Report::NextPage) current page is empty" << endl;
cout<<currentpage<<" "<<std::endl;
HPDF_Page_SetWidth(currentpage, 595.3);
}
Report::Report(string fileName, string booktitle, int marg) {
m_ReportFilePath = fileName;
document = HPDF_New(Report::error_handler, &document);
NextPage(); // Create new page
}
Report::~Report()
{
}
void Report::error_handler(HPDF_STATUS error_no,
HPDF_STATUS detail_no, void *user_data)
{
cout << "hPDF error error_no=" << (HPDF_UINT) error_no <<
", detail_no=" << (HPDF_UINT) detail_no << endl;
}
int main() {
Report r("test.pdf", "test", 50);
return 0;
}
编译命令
/depot/gcc-4.8.2/bin/g++ -rdynamic -Wall -I../include -std=c++11 -c lib_haru.cpp -o lib_haru -L../libs -lhpdf
/depot/gcc-4.8.2/bin/g++ -o libh lib_haru.o -rdynamic -L../libs -lm -ltcl8.4 -lxml2 -lz -lpng -lhpdf -lncurses -lreadline -Wl,-rpath,/depot/gcc-4.8.2/lib64
OBJECTS=$(addsuffix .o,$(basename $(SRC)))
VERSION=$(USER)
CXXFLAGS=-g -D Version=$(VERSION) -rdynamic -Wall -I../include
LDFLAGS=-rdynamic -L../libs -lm -ltcl8.4 -lxml2 -lz -lpng -lhpdf -lncurses -lreadline -Wl,-rpath,/depot/gcc-4.8.2/lib64
#CXX= /usr/bin/g++
CXX= /depot/gcc-4.8.2/bin/g++
在本机编译时出现问题
Linux Machine 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
GDB 输出
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6852c31 in __strlen_sse2 () from /usr/lib64/libc.so.6
可能的问题
currentpage = HPDF_AddPage(document);
if (currentpage == NULL)
logerror << "(Report::NextPage) current page is empty" << endl;
#value of currentpage is 0
我唯一一次看到此错误是在 PDF 变得如此之大以至于占用了所有可用内存时。就我而言,我正在使用 PDF 基元创建图像(例如填充的矩形)。
您确实没有提供足够的信息来帮助诊断问题。 libHaru 版本,32 位或 64 位,通常您尝试做的事情会有帮助。
I have tried to written small program and try to reproduce this issue but did not encounter any error.
我建议你把小程序做大,直到你能重现问题,如果仍然不清楚post代码,以便我们调查和评论。