企业如何利用HarmonyOS开发工具提升小程序开发效率与合规性
1655
2022-09-13
Window下编译qtpdfium
系统环境:windows11
Qt版本:Qt5.15.2
源代码路径:d)#后面,添加下面代码if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") #设置编译C++文件时,使用c++11 message(STATUS "optional:-std=c++11")endif(CMAKE_COMPILER_IS_GNUCXX)IF (WIN32) MESSAGE(STATUS "Now is windows") add_compile_options(-shared -fPIC) ELSEIF (APPLE) MESSAGE(STATUS "Now is Apple systens.")ELSEIF (UNIX) MESSAGE(STATUS "Now is UNIX-like OS's. Including aPPLE os x and CygWin") add_compile_options(-std=c++11 -shared -fPIC) #linux下必须要添加编译选项-fPIC,要不然提示错误ENDIF ()
2.修改qpdf\src\3rdparty\CMakeLists.txt
#注释掉下面代码#if(MSVC)# list(APPEND PDFIUM_SOURCES# pdfium/core/fxge/win32/fx_win32_device.cpp# pdfium/core/fxge/win32/fx_win32_dib.cpp# pdfium/core/fxge/win32/fx_win32_dwrite.cpp# pdfium/core/fxge/win32/fx_win32_gdipext.cpp# pdfium/core/fxge/win32/fx_win32_print.cpp# )# list(APPEND PDFIUM_HEADERS# pdfium/core/fxge/win32/dwrite_int.h# pdfium/core/fxge/win32/win32_int.h# )#endif(MSVC)#添加下列代码IF (WIN32) add_definitions(-DCOMPILE_SAL_MINGW) #增加预编译宏,等下在代码修改里要用到 MESSAGE(STATUS "Now is windows") list(APPEND PDFIUM_SOURCES pdfium/core/fxge/win32/fx_win32_device.cpp pdfium/core/fxge/win32/fx_win32_dib.cpp pdfium/core/fxge/win32/fx_win32_dwrite.cpp pdfium/core/fxge/win32/fx_win32_gdipext.cpp pdfium/core/fxge/win32/fx_win32_print.cpp ) list(APPEND PDFIUM_HEADERS pdfium/core/fxge/win32/dwrite_int.h pdfium/core/fxge/win32/win32_int.h )ELSEIF (APPLE) MESSAGE(STATUS "Now is Apple systens.")ELSEIF (UNIX) MESSAGE(STATUS "Now is UNIX-like OS's. Including aPPLE os x and CygWin")ENDIF ()
3.修改代码:qpdf\src\3rdparty\pdfium\core\fxge\win32\fx_win32_dwrite.cpp
## 修改函数:HRESULT(__stdcall* FuncType_DWriteCreateFactory)为下面# 大概位置14行##ifdef COMPILE_SAL_MINGWtypedef HRESULT(__stdcall* FuncType_DWriteCreateFactory)( _In_ DWRITE_FACTORY_TYPE, _In_ REFIID, _Out_ IUnknown**);# elsetypedef HRESULT(__stdcall* FuncType_DWriteCreateFactory)( __in DWRITE_FACTORY_TYPE, __in REFIID, __out IUnknown**);#endif## 修改函数:HRESULT STDMETHODCALLTYPE DrawGlyphRun(const FX_RECT& text_bbox为下面# 大概位置120行##ifdef COMPILE_SAL_MINGW HRESULT STDMETHODCALLTYPE DrawGlyphRun(const FX_RECT& text_bbox, __in_opt CFX_ClipRgn* pClipRgn, __in_opt DWRITE_MATRIX const* pMatrix, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_MEASURING_MODE measuringMode, _In_ DWRITE_GLYPH_RUN const* glyphRun, const COLORREF& textColor);# else HRESULT STDMETHODCALLTYPE DrawGlyphRun(const FX_RECT& text_bbox, __in_opt CFX_ClipRgn* pClipRgn, __in_opt DWRITE_MATRIX const* pMatrix, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_MEASURING_MODE measuringMode, __in DWRITE_GLYPH_RUN const* glyphRun, const COLORREF& textColor);#endif## 修改函数:STDMETHODIMP CDwGdiTextRenderer::DrawGlyphRun(为下面# 大概位置431行##ifdef COMPILE_SAL_MINGWSTDMETHODIMP CDwGdiTextRenderer::DrawGlyphRun( const FX_RECT& text_bbox, __in_opt CFX_ClipRgn* pClipRgn, __in_opt DWRITE_MATRIX const* pMatrix, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_MEASURING_MODE measuringMode, _In_ DWRITE_GLYPH_RUN const* glyphRun, const COLORREF& textColor) {# elseSTDMETHODIMP CDwGdiTextRenderer::DrawGlyphRun( const FX_RECT& text_bbox, __in_opt CFX_ClipRgn* pClipRgn, __in_opt DWRITE_MATRIX const* pMatrix, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_MEASURING_MODE measuringMode, __in DWRITE_GLYPH_RUN const* glyphRun, const COLORREF& textColor) {#endif
4.修改代码qpdf_cmake\src\3rdparty\pdfium\core\fxge\win32\fx_win32_gdipext.cpp
# 694行m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]);# 修改成m_Functions[i] = (void*)GetProcAddress(m_hModule, g_GdipFuncNames[i]);# 709行GetProcAddress(m_GdiModule, "AddFontMemResourceEx");# 修改成(void*)GetProcAddress(m_GdiModule, "AddFontMemResourceEx");# 711行GetProcAddress(m_GdiModule, "RemoveFontMemResourceEx");# 修改成(void*)GetProcAddress(m_GdiModule, "RemoveFontMemResourceEx");
修改完毕,可以执行run cmake,build,run,然后就可以打开pdf啦。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~