Bug 393953 - Can't print to PDF or printer
Summary: Can't print to PDF or printer
Status: RESOLVED DOWNSTREAM
Alias: None
Product: kmymoney
Classification: Applications
Component: reports (show other bugs)
Version: 5.0.1
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-07 12:52 UTC by Paul Gover
Modified: 2018-06-08 16:12 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
emerge --info for Christian's setup (18.00 KB, text/plain)
2018-05-10 05:03 UTC, Christian
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Gover 2018-05-07 12:52:58 UTC
Report printing worked OK in 4.8.1.1, but stopped with 5.0.1 (Gentoo skipped 5.0.0).

I go to Reports, and choose any of them.  The report displays OK on the screen.  I then click on File>Print... or the Print... toolbar icon or hit Ctrl+P, and the Printer selection dialog box pops up.  Select "Print to File (PDF)", and the dialog now offers /home/paul/print.pdf, which is fine, so I click on Print, and it says print.pdf already exists, do I want to overwrite it.  I say yes, and it pretends to do it, but it's lying, the file is unchanged.  Alternatively, if I try to print to a printer, again it claims to have worked, but nothing appears in the CUPS queue.

Other KDE5 apps such as Kmail print OK, and come up with the same print dialog.

If I run kmymoney from the terminal, there's nothing relevant in the output.

I tried to rebuild kmymoney with CMAKE_BUILD_OPTIONS=Debugfull, but Gentoo's ebuild overwrote it, so I can't run with --trace, assuming that's still even valid.
Comment 1 Jack 2018-05-07 15:24:16 UTC
I'm not sure if setting the debug USE flag will build one of the debug versions on Gentoo, but it's worth trying.  If it doesn't work, you would have to build manually.  (If you are going to build manually, you can install under /usr/local, so you can install and then remove it without interfering with the emerged version.

I just tried and got the same behavior, using git master (Gentoo ebuild from the KDE overlay.)  I'll try to get a debug version running later today.
Comment 2 Paul Gover 2018-05-08 08:03:20 UTC
I tried on a different box running ArchLinux 32-bit, also with kmymoney-5.0.1, and printing worked there, so it looks like its a Gentoo problem.

Looking further into the Gentoo EAPI stuff, it does inherit a debug flag, but IIUC that sets Qt and other debug settings, but not the correct option for kmymoney (indeed, as far as I can see, it sets CMAKE_BUILD_OPTIONS=Gentoo; not sure what that means).
Comment 3 Jack 2018-05-08 15:28:58 UTC
I don't understand the Gentoo CMAKE_BUILD_OPTIONS either, but getting it to not strip symbols takes changing the environment of the ebuild.  Instead, I rebuilt manually, but have run into separate problems with loading (trying to load) the wrong plugins, so it may take me a bit to revise my process for building/loading a second version.  I'm still working on it.
Comment 4 Christian 2018-05-08 17:40:48 UTC
I tried it on my Gentoo install, also with kmymoney-5.0.1. Here, "Print to PDF" created the file /home/ca/print.pdf and its contents correspond to the report that was on the screen when I clicked on Print.
Next I tried to print a diagram, again using the same PDF file (and saying Yes to the overwrite question). Its contents were changed, the previous report disappeared, but the diagram was not included in the PDF file. Instead, the PDF now shows a one-page document that is blank except for a grey box filling most of the page.
Last, I opened another report and printed that one to PDF, again overwriting the same file. It worked and the new report is now in the PDF.
I haven't tried printing to a printer.
For information, my emerge USE flags for the installed kmymoney are:

Installed versions:  5.0.1-r2(5)(18.50.49 06.04.2018)(activities handbook quotes -addressbook -calendar -debug -hbci -holidays -ofx -test -weboob PYTHON_TARGETS="python2_7")
Comment 5 Jack 2018-05-08 18:20:49 UTC
So since at least one Gentoo user has it working (we can track down the "missing" diagram later) it's probably not the ebuild itself.  My current suspicion is some either missing or misconfigured KDE library or helper utility.  If I can get a new copy properly compiled with debugging, hopefully I'll be able to track it down.
Comment 6 Jack 2018-05-09 15:30:14 UTC
Christian - what is the value of the webkit use flag for KMyMoney? ("emerge --info kmymoney" should show it.)  It's probably -webkit.

Paul - see if printing work if you switch to -webkit use flag for KMyMoney.

If I'm right, we now need to figure out why printing works with ENABLE_WEBENGINE OFF, but not if it's ON.
Comment 7 Paul Gover 2018-05-09 20:26:04 UTC
Summat funny going on:  I've just tried various rebuilds of kmymoney-5.0.1-r2, or so it purports, but the program insists it's 5.0.0 in About kmymoney, and on the splash screen.

According to emerge --info kmymoney (I'll put the full output into another comment):

app-office/kmymoney-5.0.1-r2::gentoo was built with the following:
USE="activities handbook holidays quotes -addressbook -calendar -debug -hbci -ofx -test (-weboob)" ABI_X86="(64)" PYTHON_TARGETS="python2_7"

no sign of a webkit use flag.  I tried adding addressbook and calendar, but as far as I can tell, nothing changed. I presumed I might see something in Settings to say which addressbook and calendar.  I wonder if the ebuild is picking up the  wrong file - though it has the right name.  I don't know where to look in the archive to find its putative version number.

When I ran this version (which still doesn't print) from the command line, console output was

WebConnect: Try to connect to WebConnect server
WebConnect: Connect to server failed
WebConnect: Running in server mode
Plugins: checkprinting loaded
Plugins: csvexporter loaded
Plugins: csvimporter loaded
Plugins: gncimporter loaded
Plugins: icalendarexporter loaded
Plugins: qifexporter loaded
Plugins: qifimporter loaded
Plugins: reconciliation report loaded
Online plugins found 0
Cost center model created with items 0
Payees model created with items 0
reading file
start parsing file
startDocument
reading securities
endDocument
Plugins: checkprinting unloaded
Plugins: csvexporter unloaded
Plugins: csvimporter unloaded
Plugins: gncimporter unloaded
Plugins: icalendarexporter unloaded
Plugins: qifexporter unloaded
Plugins: qifimporter unloaded
Plugins: reconciliation report unloaded
Comment 8 Paul Gover 2018-05-09 20:26:42 UTC
Here's the full emerge --info kmymoney

Portage 2.3.24 (python 2.7.14-final-0, default/linux/amd64/17.0/desktop/plasma, gcc-6.4.0, glibc-2.25-r11, 4.9.95-gentoolxc x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.9.95-gentoolxc-x86_64-AMD_Phenom-tm-_9150e_Quad-Core_Processor-with-gentoo-2.4.1
KiB Mem:     5843156 total,   1783120 free
KiB Swap:   12586908 total,  12586908 free
Timestamp of repository gentoo: Sat, 05 May 2018 15:45:01 +0000
Head commit of repository gentoo: 62601511e80a9c080934c2f74ff2ebd15faefab2
sh dash 0.5.9.1-r3
ld GNU ld (Gentoo 2.29.1 p3) 2.29.1
ccache version 3.3.4 [disabled]
app-shells/bash:          4.4_p12::gentoo
dev-java/java-config:     2.2.0-r4::gentoo
dev-lang/perl:            5.24.3-r1::gentoo
dev-lang/python:          2.7.14-r1::gentoo, 3.5.5::gentoo
dev-util/ccache:          3.3.4-r1::gentoo
dev-util/cmake:           3.9.6::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.4.1-r2::gentoo
sys-apps/openrc:          0.34.11::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.11.6-r3::gentoo, 1.15.1-r2::gentoo
sys-devel/binutils:       2.29.1-r1::gentoo
sys-devel/gcc:            6.4.0-r1::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.13::gentoo (virtual/os-headers)
sys-libs/glibc:           2.25-r11::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.uk.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-metamanifest: no
    sync-rsync-extra-opts: 

Crossdev
    location: /usr/local/portage
    masters: gentoo
    priority: 0

Pauls-Overlay
    location: /usr/local/overlay
    masters: gentoo

Installed sets: @system
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA IBM-J1.6 dlj-1.1 AdobeFlash-10 AdobeFlash-10.1 AdobeFlash-10.3 AdobeFlash-11.x Oracle-BCLA-JavaSE Nero-AAC-EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/var/tmp/distfiles"
EMERGE_DEFAULT_OPTS="--jobs 4 --load-average 4 --quiet-build y --buildpkg-exclude 'sys-kernel/*-sources games-simulation/flightgear-data  media-libs/libsdl2 media-video/ffmpeg media-video/transcode'"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news nostrip parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://mirror.bytemark.co.uk/gentoo/ http://mirror.qubenet.net/mirror/gentoo/ http://www.mirrorservice.org/sites/distfiles.gentoo.org/"
LANG="en_GB.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en_GB en en_US"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp/tmpdir"
USE="3dnow 3dnowext X a52 aac acl acpi activities alsa amd64 berkdb branding bzip2 cairo cdda cdr cleartype cli cmake corefonts crypt cups cxx dbus declarative dri dts dvd dvdr elogind emboss encode exif ffmpeg flac fontconfig fortran gdbm gif glamor glibc-omitfp gpm gtk iconv icu id3 id3tag ipv6 java joystick jpeg kde kipi kwallet lcms ldap libnotify mad mdadm midi mmx mmxext mng modules mp3 mp4 mpeg multilib mysql ncurses nls nptl nsplugin ogg opengl openmp orc pam pango pcre pdf phonon plasma png policykit popcnt ppds qml qt3support qt5 readline reports sdl seccomp semantic-desktop sndfile spell sql sse sse2 sse3 sse4a ssl startup-notification suid svg tcpd threads tiff truetype udev udisks unicode usb vlc vorbis wallpapers wayland widgets wxwidgets x264 xattr xcb xcomposite xine xml xv xvid zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon plan sheets stage words" CAMERAS="sony ptp2 fuji directory" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="3dnow 3dnowext mmx mmxext popcnt sse sse2 sse3 sse4a" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="joystick evdev" KERNEL="linux" L10N="en-GB en en-US" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_5" PYTHON_TARGETS="python2_7 python3_5" RUBY_TARGETS="ruby22 ruby23" SANE_BACKENDS="snapscan" USERLAND="GNU" VIDEO_CARDS="radeon r600" XFCE_PLUGINS="menu" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

app-office/kmymoney-5.0.1-r2::gentoo was built with the following:
USE="activities handbook holidays quotes -addressbook -calendar -debug -hbci -ofx -test (-weboob)" ABI_X86="(64)" PYTHON_TARGETS="python2_7"
Comment 9 Jack 2018-05-09 20:45:20 UTC
My bad on the webkit use flag.  It looks like it's only present in the git (9999) ebuild versions (only in the kde layman overlay.  5.0.1-r2 has -DENABLE_WEBENGINE=OFF instead of being based on the use flag, which seem counter to what I expected (the value, not that it is static.)  I need to get the debug of the views plugin working to see if I can actually find why the print isn't actually happening.

Regarding the version number, it seems to simply be an oversight that 5.0.1 was released with the version still showing 5.0.0.  That's not a packaging issue.
Comment 10 Christian 2018-05-10 05:03:02 UTC
Created attachment 112555 [details]
emerge --info for Christian's setup

Here's my emerge --info output.
Comment 11 Christian 2018-05-10 05:05:46 UTC
I also ran kmymoney from the command line and printed one report to a PDF. Here's the command-line output:
ca@puolukka ~ $ kmymoney
WebConnect: Try to connect to WebConnect server
WebConnect: Connect to server failed
WebConnect: Running in server mode
Plugins: checkprinting loaded
Plugins: csvexporter loaded
Plugins: csvimporter loaded
Plugins: gncimporter loaded
Plugins: qifexporter loaded
Plugins: qifimporter loaded
Plugins: reconciliation report loaded
Online plugins found 0
Cost center model created with items 0
Payees model created with items 0
reading file
start parsing file
startDocument
reading securities
endDocument
void KReportsView::slotOpenReport(const MyMoneyReport&)   "Income/Expenses by month, detailed"
Plugins: checkprinting unloaded
Plugins: csvexporter unloaded
Plugins: csvimporter unloaded
Plugins: gncimporter unloaded
Plugins: qifexporter unloaded
Plugins: qifimporter unloaded
Plugins: reconciliation report unloaded
Comment 12 Christian 2018-05-10 05:07:18 UTC
Version 5.0.1 showing as 5.0.0 is a known Bug 392372 .
Comment 13 Jack 2018-05-12 20:53:46 UTC
The problem occurs when KMM is compiled without WEBENGINE and not when compiled with it, in case anyone knows why that would affect printing.  If you use the print function on the home page, plugins are not involved, so debugging should be easier.  I've done an strace both ways, and the good run does have one more open of ~/print.pdf, but I haven't yet figured out why.  Unfortunately, they were compiled from different git commits, so the strace outputs differ enough that comparison is not easy.
Comment 14 Thomas Baumgart 2018-05-13 08:50:20 UTC
I am not sure if this holds true for all environments. I build KMyMoney without WEBENGINE enabled for a long time and can print without problems (both to printer and to file).

openSUSE Leap 42.3
KDE Frameworks 5.32.0
Qt 5.6.2 (built against 5.6.2)
The xcb windowing system
Comment 15 Jack 2018-05-20 20:21:20 UTC
Well, i'm getting even more confused.  I compiled from git master on an Artix Linux box, and it prints OK with or without WebEngine.  On my Gentoo box, I finally just removed the system version, since it always insisted on loading the system plugins instead of the new ones.  I've tried to gdb step through to find what is happening, but at least two tries failed because it didn't even load the reports view.  I might try to trace through printing of the home page, but that seems to be done in a higher level KDE routine, not within KMM.  I finally did get to step through the reportsview printing, but I just don't follow what's happening.

Question: is there anyone seeing this problem who is NOT on Gentoo?  While I'm still open to any other suggestions here, I'm going to try looking for suggestions within the Gentoo community.  

From the About KMyMoney, Libraries tab, I currently have
KDE Frameworks 5.43.0
Qt 5.9.4 (built against 5.7.1)
Comment 16 Paul Gover 2018-05-25 16:56:29 UTC
I've tried understanding what's going on by using kmymoney within eclipse.  "Debugging" implies a greater degree of sophistication than wot I dun, "flailing about" would be nearer.  Whatever.

The problem seems to be down to the Web Engine stuff.  I had a suspicion about this; when kmail went to frameworks and KDE5 and so forth, at least on Gentoo, it temporarily used web engine to print emails, and I think the same's going on here.

When I tried printing from the Home View, as built - without ENABLE_WEBENGINE, I think it's trying to call something from the KDE4 compatability stuff, except it's not been built against that, and instead might be using one from KDEWebKit.  When I changed ENABLE_WEBENGINE to On with "ccmake .", then it used different code to print, AND IT WORKED!

It produced the same nasty printout I got on Windows 10 - i.e. web fonts and green lineflow paper background.
Comment 17 Paul Gover 2018-06-08 10:59:25 UTC
Solved it!

Having installed kdevelop and learnt how to step through the code, it turns out the problem was caused in Gentoo's handling of the change from QtWebKit V4 to V5.  They added several USE flags in version 5, one of which is called "printsupport", and apparently it defaults to "-printsupport".

Fix is, of course:
   "USE=printsupport" emerge dev-qt/qtwebkit

I now have printed reports
Comment 18 Jack 2018-06-08 16:12:29 UTC
Well, that explains why we didn't see the problem with WebEngine.  I wonder if qtwebkit should raise some error if it is asked to print when compiled without printsupport.  (I know that's a discussion for somewhere else, although I'm not sure where, possibly the Gentoo forums.)

Unless anyone can think of a valid use-case for not having print support, I'll open a Gentoo bug suggesting that it require the printsupport USE flag be set if webkit is enabled for KMyMoney.  Either that or at least some warning message.