build-win64-mxe icon indicating copy to clipboard operation
build-win64-mxe copied to clipboard

pdfium question

Open kefniark opened this issue 4 years ago • 2 comments

Description

Hello there and thanks for the hard work

I'm wondering why even in all, it's build with --without-pdfium argument. The install seem well documented, so is there a problem with pdfium ?

Just trying to see if it could be possible to replace poppler (GPL) by pdfium (apache 2.0)

kefniark avatar Jan 21 '21 10:01 kefniark

PDFium build is a bit of hassle to set-up as it uses a unusual build system (i.e. gclient and gn). Perhaps using the prebuilt binaries from https://github.com/bblanchon/pdfium-binaries here might help, but I'm not sure if this can be done without any problems since these are built with MSVC instead of MinGW-w64.

Let's tag this as an enhancement. Happy to accept a PR, if you're able.

kleisauke avatar Jan 23 '21 15:01 kleisauke

I found a way to integrate pdfium, I write here a step-by-step procedure that can be easy (I guess) to integrate with the current build system. I'm not opening a merge request because I'm not familiar with it.

NOTE: I'm using the meson branch because it's way easier to use.

  1. Download the correct pdf binary
    wget https://github.com/bblanchon/pdfium-binaries/releases/latest/download/pdfium-win-x64.tgz
    
  2. Unpack it, and use gendef (mingw64) and llvm-dlltool (llvm) to create a .def from the .dll and create a .a
    mkdir pdfium
    mv pdfium-win-x64.tgz pdfium
    cd pdfium
    tar xvf pdfium-win-x64.tgz
    cd bin
    gendef pdfium.dll
    cd -
    llvm-dlltool -d bin/pdfium.def -D bin/pdfium.dll -l lib/pdfium.a
    
  3. Move out of the pdfium folder, clone the build-win64-mxe repo, checkout the meson branch.
  4. (extremely manual step). Create the path that mxe uses to look for the dependencies, and put the pdfium libraries inside. Here I suppose we are instested in building the web + shared configuration + pdfium. The same reasoning can be used for building other configurations (web + static, or all + shared, or all + static).
    git clone https://github.com/mxe/mxe build/mxe
    mkdir -p ./build/mxe/usr/x86_64-w64-mingw32.shared.posix.web/lib/
    mkdir -p ./build/mxe/usr/x86_64-w64-mingw32.shared.posix.web/bin/
    mkdir -p ./build/mxe/usr/x86_64-w64-mingw32.shared.posix.web/include/
    
    # suppose that pdfium folder is in the parent folder
    cp ../pdfium/bin/pdfium.* build/mxe/usr/x86_64-w64-mingw32.shared.posix.web/bin/
    cp ../pdfium/lib/pdfium.* build/mxe/usr/x86_64-w64-mingw32.shared.posix.web/lib/
    cp -r ../pdfium/include/ build/mxe/usr/x86_64-w64-mingw32.shared.posix.web/include/pdfium
    
  5. Create the .pc file for pdfium, in the standard directory used by pkg-config. The path are fixed because we are inside a container.
    mkdir -p ./build/mxe/usr/x86_64-w64-mingw32.shared.posix.web/lib/pkgconfig
    cat > ./build/mxe/usr/x86_64-w64-mingw32.shared.posix.web/lib/pkgconfig/pdfium.pc << EOF
    prefix=/data/mxe/usr/x86_64-w64-mingw32.shared.posix.web
    libdir=\${prefix}/lib
    includedir=\${prefix}/include
    bindir=\${prefix}/bin
    
    Name: pdfium
    Description: pdfium
    Version: 4997
    Libs: -L\${libdir} -lpdfium
    Cflags: -I\${includedir}/pdfium
    EOF
    
  6. Enable the pdfium support on meson:
diff --git a/build/vips-web.mk b/build/vips-web.mk
index 0331de0..24134ce 100644
--- a/build/vips-web.mk
+++ b/build/vips-web.mk
@@ -74,7 +74,7 @@ define $(PKG)_BUILD
         -Dopenexr=disabled \
         -Dopenjpeg=disabled \
         -Dopenslide=disabled \
-        -Dpdfium=disabled \
+        -Dpdfium=enabled \
         -Dpoppler=disabled \
         -Dquantizr=disabled \
         -Dppm=false \
  1. Build!
    ./build.sh web x86_64 shared
    

At the end of the building process the zip archive build/vips-dev-w64-web-*.zip is created

galeone avatar Apr 20 '22 09:04 galeone