Page 1 of 1

Reordering pages in PDFs?

Posted: Thu Apr 27, 2017 3:01 pm
by thatkeith
I don't know if this is possible in LiveCode - but almost everything seems to be, so here goes:

Can LiveCode be used to take an existing multiple-page PDF and change the page order?

I'll happily experiment until the cows come home, but if anyone can say categorically no I'll give up now. Otherwise, any suggestions for where I should start looking?

k

Re: Reordering pages in PDFs?

Posted: Thu Apr 27, 2017 3:17 pm
by Klaus
Hi Keith,

no!

The "Business" edition comes with a PDF reader external, but I don't think this can reorder the pages in PDFs.
Take a look here: https://livecode.com/products/livecode- ... df-viewer/


Best

Klaus

Re: Reordering pages in PDFs?

Posted: Fri Apr 28, 2017 9:41 am
by thatkeith
Hah! Damn. :)

I have LC Business, but it sounds like the PDF features aren't quite all-powerful. Hmm...
I wonder, can PDFs be shown within a card and included in the output when printing, using the actual PDF data not a bitmap graphic render? It'd be a fairly funky workaround, but I could try making cards for PDF page spreads and 'print' a new PDF out... (can you tell I'm new to working with these things in LC? :D

Or I could use AppleScript to drive Preview to do the job. But that seems less elegant.

k

Re: Reordering pages in PDFs?

Posted: Fri Apr 28, 2017 9:56 am
by Klaus
Hi Keith,

sorry, I only have an Indy licence, so I cannot give any adsvice regarding LC & PDF here.
AppleScript and Preview is surely a solution, but, as you mentioned, not the most elegant one.


Best

Klaus

Re: Reordering pages in PDFs?

Posted: Sat Apr 29, 2017 1:55 am
by capellan
PDFtk, a command line utility (that you can run from a LiveCode script)
is ideal for this task. The solution posted in this message from Ubuntu
forums is effectively a single line:
pdftk theoriginalfile.pdf cat 1 4 19 16 22 13 7 10 2 5 20 17 23 14 8 11 3 6 21 18 24 15 9 12 25 output thenewfile.pdf

Read the whole message thread visiting this link
https://ubuntuforums.org/showthread.php?t=868950

Re: Reordering pages in PDFs?

Posted: Sun May 07, 2017 1:38 pm
by thatkeith
It looks like a perfect solution! Thanks, this feels like a good way forward. :)

k

Re: Reordering pages in PDFs?

Posted: Wed May 10, 2017 8:41 pm
by capellan
Glad to help! :D

Re: Reordering pages in PDFs?

Posted: Sun May 21, 2017 9:11 am
by PeterG
HI Capellan
I just recently discovered PDFTK but not sure how to launch it using the shell command.
My goal is to just do a wild card of the files in a folder which the user select and the resulting Merged PDF name got from a user using the "ask" command.
I am a LC newbie :)
Here is my code:

Code: Select all

ask question "Type in the name of the file. (name.PDF)" titled "Merge File Name"
put it into  gFilename
get shell( "pdftk *.pdf output combined.pdf")
end mouseUp
I am not sure how to use the variable in the shell command.

Any suggestions would be appreciated.

Many thanks
Peter G

Re: Reordering pages in PDFs?

Posted: Mon Jul 10, 2017 1:20 pm
by thatkeith
Hi Peter,
The thread http://forums.livecode.com/viewtopic.php?f=9&t=29445 has some example scripts from something I'm working on that use both pdftk and pdfjam, along with some very helpful scripts for handling paths with spaces when setting up a more complex quoted command for shell() to use. Let me know if you want some sample scripts for pdftk.

k

Re: Reordering pages in PDFs?

Posted: Thu Jul 13, 2017 6:17 pm
by PeterG
My apologies for only replying now.
Was a bit out of action.
This link was most helpful.

Many Thanks
Peter G