JakubMelka / PDF4QT

Open source PDF editor.
https://jakubmelka.github.io/
GNU Lesser General Public License v3.0
661 stars 67 forks source link

Windows 11 ARM Support #88

Open scott-mackenzie opened 1 year ago

scott-mackenzie commented 1 year ago

Is there any intention to complie a binary for Windows 11 ARM? Or for Apple Silicon?

JakubMelka commented 1 year ago

Hello, first I must finish export to Flatpak (linux).

fraterlinux commented 9 months ago

Hello, first I must finish export to Flatpak (linux).

In my humble opinion you should abandon the Flatpak format as it is too expensive. You need to install a distro inside the Linux distro. AppImage is much more optimized and practical. Investing your time and efforts in an optimized format would be the most appropriate. /\ :)

bjepson commented 2 months ago

I've been able to build it using the commands below. It sort of works, except bitmap images (JPEG and PNG) are coming up blank. I'm guessing I'm either missing a library or there might be an endian-ness issue. But I'm also missing a number of options on the Tools menu (see the screenshots), so I'm probably missing something.

cd src
git clone https://github.com/microsoft/vcpkg
vcpkg\bootstrap-vcpkg.bat
SET VCPKG_ROOT=%cd%\..\vcpkg
PATH=%VCPKG_ROOT%;%PATH%
%VCPKG_ROOT%\vcpkg.exe install qtbase
%VCPKG_ROOT%\vcpkg.exe install qtsvg
%VCPKG_ROOT%\vcpkg.exe install qtspeech
%VCPKG_ROOT%\vcpkg.exe install ijg-libjpeg

unzip PDF4QT-1.4.0.0.zip
cd PDF4QT-1.4.0.0
SET Qt6_DIR=%VCPKG_ROOT%\installed\arm64-windows\share\Qt6
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DPDF4QT_QT_ROOT=../vcpkg/installed/arm64-windows/share/Qt6 -DPDF4QT_INSTALL_QT_DEPENDENCIES=1 -DPDF4QT_INSTALL_PREPARE_WIX_INSTALLER=1 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX='/Local' -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

C:\Users\bjeps\src\vcpkg\installed\arm64-windows\tools\Qt6\bin\windeployqt.exe build\usr\bin\Release

xcopy ..\vcpkg\installed\arm64-windows\bin\Qt6PrintSupport.dll build\usr\bin\Release
xcopy ..\vcpkg\installed\arm64-windows\bin\Qt6TextToSpeech.dll build\usr\bin\Release
xcopy ..\vcpkg\installed\arm64-windows\bin\zlib1.dll build\usr\bin\Release
xcopy ..\vcpkg\installed\arm64-windows\bin\libcrypto-3-arm64.dll build\usr\bin\Release
xcopy ..\vcpkg\installed\arm64-windows\bin\harfbuzz.dll build\usr\bin\Release
xcopy ..\vcpkg\installed\arm64-windows\bin\double-conversion.dll build\usr\bin\Release
xcopy ..\vcpkg\installed\arm64-windows\bin\pcre2-16.dll build\usr\bin\Release
xcopy ..\vcpkg\installed\arm64-windows\bin\zstd.dll build\usr\bin\Release
xcopy ..\vcpkg\installed\arm64-windows\bin\Qt6Multimedia.dll build\usr\bin\Release

build\usr\bin\Release\Pdf4QtEditor.exe

Screenshot 2024-07-10 203839 Screenshot 2024-07-10 203845

SnowballV commented 2 months ago

@bjepson, you wrote,

I'm also missing a number of options on the Tools menu (see the screenshots)

If you used or tested a previous version earlier on, you may need to reset to factory settings to get all options shown. That was my experience with PDF4QT-1.4.0.0-x86_64.AppImage on Kubuntu 22.04, after testing PDF4QT 1.3.7 and daily builds earlier on.

bjepson commented 2 months ago

Thanks, @SnowballV! I found that I needed to copy the plugin folder into the Release folder, and all the plugins appeared:

mkdir build\usr\bin\Release\pdfplugins
xcopy build\usr\bin\pdfplugins\Release\*dll build\usr\bin\Release\pdfplugins

I still have a problem with images not appearing, but I clicked Tools → Rendering Errors and saw this error: "Conversion to CMYK to output device using CMS failed.", but switching the renderer to QPainter seems to fix it.

I also realized that I save a few steps by using the vcpkg_with_qt.json (#68), though I had to remove ijg-libjpeg because of the conflict with libjpeg-turbo that's installed along with qt (I also needed to add blend2d for some reason). Here's the vcpkg.json that I'm using:

{
  "name": "pdf4qt",
  "version-string": "1.3.3",
  "dependencies": [ "blend2d", "openssl", "lcms", "zlib", "openjpeg", "freetype",  "libpng", "qt" ]
}

As a result, I need to make one change (a little quick and dirty) to Pdf4QtLibCore/sources/pdfutils.cpp:

266c266,267
<     libjpegInfo.version = tr("%1.%2").arg(JPEG_LIB_VERSION_MAJOR).arg(JPEG_LIB_VERSION_MINOR);
---
>     libjpegInfo.version = tr("%1").arg(JPEG_LIB_VERSION);
>     //libjpegInfo.version = tr("%1.%2").arg(JPEG_LIB_VERSION_MAJOR).arg(JPEG_LIB_VERSION_MINOR);

Here's what I'm doing now (also using the version of windeployqt from the build directory which simplifies things):

cd src
git clone https://github.com/microsoft/vcpkg
vcpkg\bootstrap-vcpkg.bat
SET VCPKG_ROOT=%cd%\..\vcpkg
PATH=%VCPKG_ROOT%;%PATH%

unzip PDF4QT-1.4.0.0.zip
cd PDF4QT-1.4.0.0
SET Qt6_DIR=%VCPKG_ROOT%\installed\arm64-windows\share\Qt6
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DPDF4QT_QT_ROOT=../vcpkg/installed/arm64-windows/share/Qt6 -DPDF4QT_INSTALL_QT_DEPENDENCIES=1 -DPDF4QT_INSTALL_PREPARE_WIX_INSTALLER=1 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX='/Local' -DCMAKE_BUILD_TYPE=Release

cmake --build build --config Release

build\vcpkg_installed\arm64-windows\tools\Qt6\bin\windeployqt.exe build\usr\bin\Release

mkdir build\usr\bin\Release\pdfplugins
xcopy build\usr\bin\pdfplugins\Release\*dll build\usr\bin\Release\pdfplugins
build\usr\bin\Release\Pdf4QtEditor.exe