DavBfr / dart_pdf

Pdf creation module for dart/flutter
https://pub.dev/packages/pdf
Apache License 2.0
1.41k stars 629 forks source link

Printing and pdfx modules are incompatible in windows #1622

Open Mapashito1 opened 8 months ago

Mapashito1 commented 8 months ago

Describe the bug When I launch a windows build of my app with modules printing and pdfx, I have a compile problem.

CMake Error at flutter/ephemeral/.plugin_symlinks/printing/windows/DownloadProject.cmake:179 (message): Build step for pdfium failed: 1 Call Stack (most recent call first): flutter/ephemeral/.plugin_symlinks/printing/windows/CMakeLists.txt:36 (download_project)

The problem is variable PDFIUM_VERSION. In pdfx module the value is 4636 and in printing module the value is 5200. It tries to download pdfx variable value instead of printing variable value. I put a debug trace and it's easy to see... image

To Reproduce Launch a windows project with this in pubspec.yaml printing: ^5.11.1 pdfx: ^2.6.0

Additional context Temporaly, I can build a windows app if I make a flutter clean and comment out pdfx import in pubspec.yaml. Then it gives me a error because I use this module in my code but It has downloaded correct libraries. After, I put pdfx import back in pubspec.yaml and it works because printing module uses cache libraries.

Is it necessary "CACHE" variable for PDFIUM_VERSION?

I have opened this topic in pdfx forum too https://github.com/ScerIO/packages.flutter/issues/490

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Versi¢n 10.0.22621.3155], locale es-ES)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.4.1)
[√] Android Studio (version 2023.1)
[√] VS Code (version 1.86.2)
[√] Connected device (3 available)
[√] Network resources

• No issues found!
lecuivre-alban commented 3 months ago

Hello,

I managed to solved the issue by adding the following line in the file windows/CMakeLists.txt of my project

set(BINARY_NAME, "APPNAME")
set(PDFIUM_VERSION, "5200", CACHE STRING "") # << Add this

I am using

printing: ^5.13.1
pdfx:  ^2.6.0