diff --git a/DocOutput.cpp b/DocOutput.cpp index 8f2e956..d9f6f29 100644 --- a/DocOutput.cpp +++ b/DocOutput.cpp @@ -1,5 +1,6 @@ #include "hpdf.h" #include "DocOutput.h" +#include "Util.h" HPDF_Font fontStyles[4]; @@ -34,6 +35,12 @@ } +HPDF_Page DocOutputPage::page() +{ + return m_pimpl->page; +} + + float DocOutputPage::width() { return HPDF_Page_GetWidth(m_pimpl->page); @@ -134,6 +141,7 @@ }; +#ifdef _WIN32 #include // for OutputDebugStringA static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) { @@ -146,6 +154,17 @@ // delete context; // Can't do this, it could be on the stack as is the case currently exit(-1); } +#else + +static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) +{ + // DocOutputDevice* context = (DocOutputDevice*)user_data; + fprintf(stderr, "%s(%i): error %04X: detail_no=%u\n", file, line, (HPDF_UINT)error_no, (HPDF_UINT)detail_no); + // delete context; // Can't do this, it could be on the stack as is the case currently + exit(-1); +} + +#endif DocOutputDevice::DocOutputDevice() : m_pimpl(std::make_unique()) diff --git a/DocOutput.cpp b/DocOutput.cpp index 8f2e956..d9f6f29 100644 --- a/DocOutput.cpp +++ b/DocOutput.cpp @@ -1,5 +1,6 @@ #include "hpdf.h" #include "DocOutput.h" +#include "Util.h" HPDF_Font fontStyles[4]; @@ -34,6 +35,12 @@ } +HPDF_Page DocOutputPage::page() +{ + return m_pimpl->page; +} + + float DocOutputPage::width() { return HPDF_Page_GetWidth(m_pimpl->page); @@ -134,6 +141,7 @@ }; +#ifdef _WIN32 #include // for OutputDebugStringA static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) { @@ -146,6 +154,17 @@ // delete context; // Can't do this, it could be on the stack as is the case currently exit(-1); } +#else + +static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void * /*user_data*/, int line, const char* file) +{ + // DocOutputDevice* context = (DocOutputDevice*)user_data; + fprintf(stderr, "%s(%i): error %04X: detail_no=%u\n", file, line, (HPDF_UINT)error_no, (HPDF_UINT)detail_no); + // delete context; // Can't do this, it could be on the stack as is the case currently + exit(-1); +} + +#endif DocOutputDevice::DocOutputDevice() : m_pimpl(std::make_unique()) diff --git a/DocOutput.h b/DocOutput.h index 257a9a1..61885e4 100644 --- a/DocOutput.h +++ b/DocOutput.h @@ -7,6 +7,9 @@ struct DocImage; +// Messy +#include "hpdf.h" + class DocOutputPage { @@ -14,6 +17,8 @@ DocOutputPage(void*); ~DocOutputPage(); + HPDF_Page page(); // TODO: remove need for this + float width(); float height();