Skip to main content
chrisfer78
Participant
November 16, 2018
Question

Batch add same action / same javascript on page x .. y

  • November 16, 2018
  • 1 reply
  • 949 views

I have pdf's from scanned documents. Most pages have size A4 (210x297mm). 'Document Properties' > 'Initial View' > 'Page layout' is set to 'Two-up' (Cover page)', so that always 2 pages will be showed side by side, like reading a book. Now, few pages have the double size, A3 (297x410mm). Viewing them, 'Page layout' should switch to 'Single sided'. Going back or forward to an A4 page, 'Page layout' should switch back to 'Two-up'.

The only method I found for achieving this, was by adding an action to each page of the document. The trigger is 'Open page', the action 'javascript'. Depending on the page size:

this.layout = "TwoPageRight";

this.layout = "SinglePage";

My quesion: How can I add such (identical) actions with (identical) javascript snippets conveniently for page x to y ? I could not find any feature in preflight.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
November 16, 2018

Preflight is not the right tool for this. It can be done using a script.

Do you want to apply it to all pages, or just some?

chrisfer78
Participant
November 16, 2018

Actually I want to apply it just to some pages:  
this.layout = "TwoPageRight";
   to all pages with size A4 (210x297mm),

this.layout = "SinglePage";   to all pages with size A3 (297x410mm).

As usually most pages are A4, I'd like to apply the first javascript to e.g. pages 1 to 56 and 58 to 123, the last javascript to page 57.


But a workaround could be to separate the document in pdfs containing 1 page only, moving all pdfs with an A4 page in one directory and all with A3 in another. Then I could run an batch job, that applies exactly the same javascript action to all pdfs in a directory, and then combine all pdfs of both directories in the right order. (however I don't know yet how to do this). In this procedure I would apply the javascrpt to the one and only page per pdf.

try67
Community Expert
Community Expert
November 16, 2018

There's no need to split the file, but I don't understand if you want to do it based on the page numbers or their sizes...