Closed rocketraman closed 2 months ago
Thank you for the information, I had no idea that pdftk was problematic. I'll try out the alternatives you suggested.
@rocketraman If you want to help with testing, see branch issue-5
@svenssonaxel Tried out the issue-5 branch but doesn't see to be working very well for me. The window that opens first shrinks down to a very small size, then the signature is shown in the middle of the first page. None of the controls to move the signature or navigate through pages work.
I'm using KDE on Fedora 38.
@rocketraman Could you please try branch issue-5
again?
@rocketraman Could you please try branch
issue-5
again?
Hi @svenssonaxel ! Pretty much the same as before. I see this error on startup:
/home/raman/opt/bin/pdf-sign:437: SyntaxWarning: invalid escape sequence '\('
[ignored, w, h, *ignored2]=fromCmdOutput(['pdfinfo', filePath], '^.*\nPage size: +([0-9.]+) x ([0-9.]+) pts( \([A-Za-z0-9]+\))?\n.*$')
After startup the window is quite small. The signature is in the middle and cannot be moved as far as I can tell. I also cannot navigate through the pages.
If I actually try to save the signature, it writes out a file, but page 3 of my 3 page PDF has been replaced by page 1 with my signature in the middle of the page.
@rocketraman I'd like some version information to try to reproduce this.
python3 --version
which -a python3 gs qpdf pdftk pdfinfo
gs --version
qpdf --version
pdftk --version
pdfinfo --help 2>&1|head -n 1
python3 -m tkinter
@svenssonaxel :
@rocketraman I'd like some version information to try to reproduce this.
python3 --version
Python 3.12.3
which -a python3 gs qpdf pdftk pdfinfo
which: no pdftk in (...) /usr/bin/python3 /bin/python3 /home/raman/.linuxbrew/bin/python3 /home/raman/.linuxbrew/bin/python3 /usr/bin/gs /bin/gs /usr/bin/qpdf /bin/qpdf /usr/bin/pdfinfo /bin/pdfinfo
gs --version
10.02.1
qpdf --version
qpdf version 11.6.4 Run qpdf --copyright to see copyright and license information.
pdftk --version
fish: Unknown command: pdftk
pdfinfo --help 2>&1|head -n 1
pdfinfo version 23.08.0
python3 -m tkinter
@rocketraman And your window manager and desktop environment?
@rocketraman And your window manager and desktop environment?
KDE Plasma 5.27.11 on X11.
@rocketraman I've tried with kwin 5.27.5, python 3.12.3, tkinter 8.6.13. I wasn't able to reproduce all of the issues, but I'd still like you to pull branch issue-5
and try again.
Thanks for the new drop. I'm on KDE Plasma 6.1.1 on Wayland now (after many years of trying Wayland every year and then giving up, I'm finally staying on Wayland this year!).
Other updated versions (if not listed here, its the same version as before):
I've given the latest issue-5 branch a try.
The window is hard-coded to open with 800x600
geometry, intended to be small enough to fit on pretty much all screens. It should be possible to resize it though. Does resizing work for you?
I'm glad page navigation works. The 2s to switch between pages is due to the hacky way a page is shown; it is extracted from the source pdf using qpdf
, then converted to an image and lastly loaded. If the pdf or page is complex/large, or the temporary file system is slow, this will take some time. I don't think I'll improve this much in the foreseeable future.
I do want to fix the key presses and clicks, though. I've now pushed a debug version. Could you try some key presses and clicks, and send me the output? Thanks!
The window is hard-coded to open with
800x600
geometry, intended to be small enough to fit on pretty much all screens. It should be possible to resize it though. Does resizing work for you?
That's really small for modern screens, especially high-DPI ones. But yes, it is resizable.
I'm glad page navigation works. The 2s to switch between pages is due to the hacky way a page is shown; it is extracted from the source pdf using
qpdf
, then converted to an image and lastly loaded. If the pdf or page is complex/large, or the temporary file system is slow, this will take some time. I don't think I'll improve this much in the foreseeable future.
My test PDF is 3 pages, 580kb. Large, but not huge. The temp filesystem is tmpfs backed by NVMe SSDs (and I have plenty of memory so it should never even see the SSD), so it should be pretty quick. For inspiration, maybe you could look at the way pdfarranger does it. In any case, this isn't a huge deal.
I do want to fix the key presses and clicks, though. I've now pushed a debug version. Could you try some key presses and clicks, and send me the output? Thanks!
Here is the output:
Debug: in dbg(event) for root <KeyPress>: char=, delta=0, height=??, keycode=64, keysym=Alt_L, keysym_num=65513, num=??, send_event=False, serial=676, state=16, time=122153149, type=2, widget=., width=??, x=261, x_root=5619, y=72, y_root=851
Debug: in onclick(event): char=??, delta=0, height=??, keycode=??, keysym=??, keysym_num=??, num=1, send_event=False, serial=4643, state=16, time=122163360, type=4, widget=.!canvas, width=??, x=991, x_root=6003, y=1268, y_root=1417
Debug: in dbg(event) for root <Button>: char=??, delta=0, height=??, keycode=??, keysym=??, keysym_num=??, num=1, send_event=False, serial=4643, state=16, time=122163360, type=4, widget=.!canvas, width=??, x=991, x_root=6003, y=1268, y_root=1417
Debug: in onclick(event): char=??, delta=0, height=??, keycode=??, keysym=??, keysym_num=??, num=1, send_event=False, serial=5038, state=16, time=122165356, type=4, widget=.!canvas, width=??, x=393, x_root=5405, y=1427, y_root=1576
Debug: in dbg(event) for root <Button>: char=??, delta=0, height=??, keycode=??, keysym=??, keysym_num=??, num=1, send_event=False, serial=5038, state=16, time=122165356, type=4, widget=.!canvas, width=??, x=393, x_root=5405, y=1427, y_root=1576
Debug: in onclick(event): char=??, delta=0, height=??, keycode=??, keysym=??, keysym_num=??, num=1, send_event=False, serial=5471, state=16, time=122169100, type=4, widget=.!canvas, width=??, x=237, x_root=5249, y=473, y_root=622
Debug: in dbg(event) for root <Button>: char=??, delta=0, height=??, keycode=??, keysym=??, keysym_num=??, num=1, send_event=False, serial=5471, state=16, time=122169100, type=4, widget=.!canvas, width=??, x=237, x_root=5249, y=473, y_root=622
Debug: in onkey(event): char=, delta=0, height=??, keycode=116, keysym=Down, keysym_num=65364, num=??, send_event=False, serial=5472, state=16, time=122170656, type=2, widget=., width=??, x=652, x_root=5659, y=903, y_root=1047
Debug: in onkey(event): char=, delta=0, height=??, keycode=116, keysym=Down, keysym_num=65364, num=??, send_event=False, serial=5854, state=16, time=122171426, type=2, widget=., width=??, x=652, x_root=5659, y=903, y_root=1047
Debug: in onkey(event): char=, delta=0, height=??, keycode=116, keysym=Down, keysym_num=65364, num=??, send_event=False, serial=5854, state=16, time=122171896, type=2, widget=., width=??, x=652, x_root=5659, y=903, y_root=1047
Debug: in onkey(event): char=, delta=0, height=??, keycode=114, keysym=Right, keysym_num=65363, num=??, send_event=False, serial=6570, state=16, time=122175756, type=2, widget=., width=??, x=652, x_root=5659, y=903, y_root=1047
Debug: in onkey(event): char=, delta=0, height=??, keycode=114, keysym=Right, keysym_num=65363, num=??, send_event=False, serial=6904, state=16, time=122176618, type=2, widget=., width=??, x=652, x_root=5659, y=903, y_root=1047
Debug: in onkey(event): char=, delta=0, height=??, keycode=114, keysym=Right, keysym_num=65363, num=??, send_event=False, serial=6904, state=16, time=122177203, type=2, widget=., width=??, x=652, x_root=5659, y=903, y_root=1047
Aborted
That's really small for modern screens, especially high-DPI ones. But yes, it is resizable.
Made it adaptive, does that feel better?
it should be pretty quick.
I've sped up the startup, at least on my side, and also added debug prints to find out what is taking so long on your side.
Could you try some key presses and clicks
Here is the output:
This is a little mysterious; I see nothing wrong in this output. I've pushed a heavier load of debug prints. Could you please
...signature-positioned.pdf
and ...display.png
. Open them and see in which ones the signature is correct.Made it adaptive, does that feel better?
Yes!
it should be pretty quick.
I've sped up the startup, at least on my side, and also added debug prints to find out what is taking so long on your side.
Could you try some key presses and clicks
Here is the output:
This is a little mysterious; I see nothing wrong in this output. I've pushed a heavier load of debug prints. Could you please
- Try it out as it is, with clicking and arrow keys. Make sure to wait a good while, up to 10s, in case it's just very slow.
- If the signature really does not change position, look through the debug output for the latest mention of temporary files
...signature-positioned.pdf
and...display.png
. Open them and see in which ones the signature is correct.
I'm not sure what I'm looking for here... ...signature-positioned.pdf
is just a 60x40mm blank PDF with my signature positioned exactly in the middle. And ...display.png
is the entire page with the signature in the original location (the center).
- Send me the output for a similar session as your last one. It's going to be more output this time, so you might want to pipe it.
Thank you, I might've found the issue, but not yet solved it.
Some pdf signatures work but not others. I have attached good-signature.pdf
and bad-signature.pdf
. On my machine,
pdf-sign
, good-signature.pdf
works as expected. It is possible to position it with both pointer clicks and arrow keys. When pressing S
, the signature is located in the correct position in the resulting pdf.pdf-sign
, bad-signature.pdf
exhibits the behavior you describe. It is positioned in the middle and cannot be moved. Pressing S
produces a pdf looking like what was shown, with the signature in the middle.Can you confirm that all of the above is the case for you as well?
@svenssonaxel Yes, I can confirm the same behavior on my machine for bad-signature.pdf and good-signature.pdf.
Fixed on my side, can you confirm that everything is working for you now?
Yes it works!
@rocketraman Thanks for all your help. Feel free to open new issues for any remaining concerns.
Hello, this looks like a really useful tool. However, it depends on pdftk, which is no longer maintained. For example, Fedora retired this package six years ago: https://src.fedoraproject.org/rpms/pdftk.
Would you consider using pypdf (Python) or qpdf (C++ with Python bindings) instead?