What I want to achieve: Before merging pdfs I want to make sure that each one has an even number of pages. So if it is an uneven number of pages a blank page should be added.
Is there a chance somebody could get me on track how to formulate such an if condition?
(Short cut for being of great help: Is there a preference setting in MS word to achieve this? Then problem would be solved since the guy producing the pdfs with MS word would always send me pdfs with even numbers.)
Me, I would just tell/ask/negotiate/pay-for the guy to send PDF’s with even number of pages…
It might be simpler to have them send you the Word doc and you write a small (probably is just a few lines) macro in Word that checks for number of pages, and if not even, then add a blank one at end. Give that macro to your guy for them to pre-preocess before giving you the PDF.
My experience is that messing with PDFs is harder than with Word doc’s, as the former are built without intention to be edited whereas the opposite is true for Word doc’s. Not saying it’s impossible to do with PDF’s and maybe DEVONthink automation, but very simple in Word.
You are right. Always better to first try the source.
I found my way now with google.
in VBA it seems to be “Mod 2 <> 0” to check if it a odd number.
Actually mod 2 = 1 is equivalent (but clearer, since mod 2 can only be 1 or 0). Positive conditions are easier to understand.
As far as I know you can’t determine the number of pages contained by a PDF using AppleScript (AS) within DT. I have no doubt there are roundabout ways, calling other software from DT, but it’d be messy. There’s also no direct way to add a page to a PDF using AS from within DT AFAIK, and merge isn’t listed in the dictionary either, so simply merging with an empty page wouldn’t be an option either.
It would be possible to do this by sending the file to Adobe Acrobat (AA), for example. AA can return the number of pages using AS and can also insert pages from another document (so you could set up a document with an empty page). If you can stomach it, Acrobat JS would allow you add the blank page without inserting it from another document. Whether you can call that function from AS from another app, I don’t know.
Looks messy anyway… @rmschne is almost certainly right that this would better be done before the document turns into a PDF and arrives in your inbox…
For a visual check…
The number of pages is shown in the window title, if more than one page exists…
From Help > Documentation > Appendix > Search Prefixes…
The Length column can be shown in List view in the item list.
A PDF shows the current page/number of pages in the view/edit pane’s Navigation bar.
This is also reported in the Info inspector and Info popover.