Reordering pages in PDFs?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 346
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Reordering pages in PDFs?

Post by thatkeith » Thu Apr 27, 2017 3:01 pm

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
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Reordering pages in PDFs?

Post by Klaus » Thu Apr 27, 2017 3:17 pm

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

thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 346
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Re: Reordering pages in PDFs?

Post by thatkeith » Fri Apr 28, 2017 9:41 am

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
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Reordering pages in PDFs?

Post by Klaus » Fri Apr 28, 2017 9:56 am

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

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Reordering pages in PDFs?

Post by capellan » Sat Apr 29, 2017 1:55 am

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

thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 346
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Re: Reordering pages in PDFs?

Post by thatkeith » Sun May 07, 2017 1:38 pm

It looks like a perfect solution! Thanks, this feels like a good way forward. :)

k
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Reordering pages in PDFs?

Post by capellan » Wed May 10, 2017 8:41 pm

Glad to help! :D

gagsoft
Posts: 168
Joined: Sat Jun 29, 2013 7:56 pm

Re: Reordering pages in PDFs?

Post by gagsoft » Sun May 21, 2017 9:11 am

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

thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 346
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Re: Reordering pages in PDFs?

Post by thatkeith » Mon Jul 10, 2017 1:20 pm

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
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist

gagsoft
Posts: 168
Joined: Sat Jun 29, 2013 7:56 pm

Re: Reordering pages in PDFs?

Post by gagsoft » Thu Jul 13, 2017 6:17 pm

My apologies for only replying now.
Was a bit out of action.
This link was most helpful.

Many Thanks
Peter G

Post Reply

Return to “Talking LiveCode”