Page 1 of 1

Merging pdf files

Posted: Sat Feb 27, 2016 3:46 pm
by DerpyJish
I wanted to create a project that is able to take multiple .pdf files and then be able to split them up by page and merge them again. I.E Is their a way in love to combine/rearrange multiple .pdf files (I would assume with the help of 3rd party modules and things).

I realize this is a bizarre thing to try and achieve in a game engine, but I've taken to using love for all of my personal projects. Recently I've been manually combining .pdf files to create mash ups of past exam papers for my school science revision, and I thought it would be fun to try and find a way of automatically generating 'random papers'.

I hope I've been clear, If not yell at me and I'll try to elaborate for you! :nyu:
Thanks in advance! :awesome:

Re: Merging pdf files

Posted: Sat Feb 27, 2016 4:13 pm
by ivan
Lua can do a lot of things and there any many modules.
Search on Google for "Lua PDF bindings":
http://luahpdf.colloquiki.com/

Rendering the PDFs through Love would be much harder though.

Re: Merging pdf files

Posted: Sat Feb 27, 2016 4:21 pm
by DerpyJish
Thanks for replying!

I've seen luahpdf in my search on google, but I couldn't figure out how to use it within love2d. Is there a way? I also remember having difficulty finding a lua binding for specifically merging and spiting pdfs, luahpdf only generates new ones, but I'll carry on looking for one.

Thanks again for your help! :nyu:

EDIT: I haven't actually been able to find any other lua libraries for PDF manipulation. I have found a C++ one that does quite a few cool things (podofo.sourceforge.net), but I'd imagine that that is even more complicated to incorporate into love! :?

Re: Merging pdf files

Posted: Sat Feb 27, 2016 5:07 pm
by ivan
If you're trying to parse pdf files - what you could do is
use an existing "converter" to turn the files into a manageable format like RTF or TXT.
These would be trivial to handle from Lua.

Re: Merging pdf files

Posted: Sat Feb 27, 2016 5:20 pm
by DerpyJish
ivan wrote:If you're trying to parse pdf files - what you could do is
use an existing "converter" to turn the files into a manageable format like RTF or TXT.
These would be trivial to handle from Lua.
Great idea! I went to pdftotext.com to experiment with it, and obviously turning a pdf to txt back to pdf stripped it all of it's formatting, but I also found pdf2png.com which with love will work a charm!

Many thanks for your help! It's great to be able to get such a useful response from clever people! :ultrahappy: