Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdfium question #20

Open
kefniark opened this issue Jan 21, 2021 · 2 comments
Open

pdfium question #20

kefniark opened this issue Jan 21, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@kefniark
Copy link

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)

@kleisauke kleisauke added the enhancement New feature or request label Jan 23, 2021
@kleisauke
Copy link
Member

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.

@galeone
Copy link

galeone commented Apr 20, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants