~skeeto/public-inbox

Question about using libpoppler-glib.so with emacs-ffi

Details
Message ID
<CACJP=3nFFA3MaScxCQDvmHPBc9ZNq=9KwvZL2ugnC_UHerzMNA@mail.gmail.com>
DKIM signature
pass
Download raw message
Hello,

I have found (and tested) your repo, for the elisp-ffi. Additionally,
I have read your article about how it works where you end by
encouraging readers to share ideas for it.
Now I have no experience with c-development nor with using dynamic
libraries, so forgive me if my question is/appears naive. I figured it
is just faster to ask you than to spend hours to figure out the answer
myself. Anyway, my question is if you think it would be possible to
use `libpoppler-glib.so` using the ffi. Poppler is the pdf-library
used by emacs its pdf-tools 'epdfinfo' server to render/edit PDF's.
Although pdf-tools is quite amazing already, I think it would be quite
easy to extend its functionality if it was possible to the epdfinfo
server, written in C, by a server that is written in a more high level
language. I have already managed to replace the server with server
written in python, using the python pymupdf[1] package, and using the
python-epc[2] package, and another one using transaction queues[3]
directly (like the current server) Both servers can be found in my
fork of pdf-tools[4] (in the the 'add-pymupdf-backend' and the
'pymupdf-tq' branches respectively, both currently without
documentation). However, the pymupdf functionality is somewhat
limited, so I was wondering if it would be possible to use the poppler
library somehow.

Now I am aware that the servers 'hold' the state of the document, but
I think that state ultimately is just the state of the PopplerDocument
instance[5] to which I guess the ffi could provide a pointer.
So I was wondering if it is possible to call methods of the object via
ffi (as I mentioned, I have no idea how ffi's work). If that would be
possible, than I guess building the pdf server in elisp wouldn't be
too much work (as most work is done by the functions in the poppler
library). I guess what I am asking is probably too complex to achieve
with ffi, but if not too complex than it would be great! (I hope my
question is clear b.t.w.)

Anyway, thanks for your great blog posts and your great packages, and
I hope also for your great answer ;)

Best regards,
Daniel

1. https://pymupdf.readthedocs.io/en/latest/index.html
2. https://github.com/tkf/python-epc
3. https://www.gnu.org/software/emacs/manual/html_node/elisp/Transaction-Queues.html
4. https://github.com/dalanicolai/pdf-tools/tree/master
5. https://poppler.freedesktop.org/api/glib/PopplerDocument.html#poppler-document-new-from-file
Reply to thread Export thread (mbox)