The loss of kprinter in the move to kde4 was one of the reasons I stuck with kde3 for as long as I could.
After some searching, I found this "3rd party" replacement: http://kde-apps.org/content/show.php/KPrinter4?content=163537, https://github.com/credativ/kprinter4.
It looks like you have to compile it yourself (Its not included in distros since it isn't core kde). The result works like the old one that came with kde3, but in the kde4 environment. It is used the same way, except the executable is called kprinter4.
Note: Some non-KDE alternatives are presented at the bottom.
I tried following the instructions at the vimwiki link you posted to use it, but I found those difficult to follow (too many escaped characters), so I based my vimrc on the function method found in
Building the executable
This bit isn't about Vim, but is a prereq to the solution. I'm writing this with limited assumptions about your (or whoever else finds this answer useful) knowledge of building software.
Download the "latest" source to kprinter4 from the link above. I used http://kde-apps.org/content/download.php?content=163537&id=1&tan=32050597
Extract into some directory:
tar xf 163537-kprinter4-12.tar.xz (filename may be different for a newer version)
Cd into the source directory:
cd kprinter4-12 (directory may be different in a newer version)
Create a build directory and change into it:
mkdir build && cd build
Run cmake. I used the options given at the kde-apps page, but changed the INSTALL_PREFIX such that I don't need to be administrator to install (but the install is only for me):
cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/john/opt/kprinter4 ..
.. is important. The INSTALL_PREFIX can be whatever you want, but it will be used in your vimrc (see below). You'll at least want to replace my username with your own.
If the command fails, it will probably tell you that you are missing libraries (for me it was missing LIBSPECTRE). Install whatever is missing and loop until cmake is successful. (e.g. in my case:
apt-get install libspectre-dev) Depending on your distro and setup, different commands and package names may be needed.
I'm using the install path from my sample isntructions above (which include my home directory). Change the paths as appropriate for your system (e.g. replacing my username with yours, or whatever you did for the INSTALL_PREFIX in the above section)
In my vimrc:
call system("/home/john/opt/kprinter4/bin/kprinter4 " . a:fname)
This creates a function that calls your newly built
kprinter4 program and then cleans up the file whenever you run :hardcopy.
After that, run
:hardcopy on a document and get a pretty printer selector:
Some Linux distributions provide
gtklp (thanks @derobert and @Sparhawk for pointing out and testing these in the comments/chat)
Example for using gpr (presently available on Ubuntu but not Arch). Note that this errors on my system due to a missing PPD file or something. Your mileage may vary.
call system("gpr " . a:fname)
Example for using gtklp (Available on both Ubuntu and Arch)
call system("gtklp " . a:fname)
At least one person has had an issue where gtklp on Arch Linux doesn't accept files specified on the command line. Below is an alternative method that works in that case (or in any case) that passes the contents of the file instead.
call system("cat " . a:fname . " | gtklp")
Note that with this method, gtklp doesn't even have a files tab displayed, but it does in fact print the document when
print is selected.