These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Header/footer placement on landscape pages

lcharles
Registered: Feb 4 2010
Posts: 10
Answered

I work with large documents that are of mixed portrait and landscape orientation. The documents will have to be printed and put into a binder with the landscape pages with the top margin at the binding. I am trying to put a header and footer on all pages such that they will all appear as if they were portrait. How can I do this without going through each document and putting the header individually on the landscaped pages? Note, these are documents going to US regulatory authorities.

My Product Information:
Acrobat Pro 9.2, Windows
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
If you mean that the H/Fs will rotate with the rotated pages, then you can't do that via Acrobat's UI - it can cope with different page *sizes* but ignores a page flagged with a software rotation.

Best option would be to write a script that searches the PDF, writes an array of which pages are rotated, rotates them all back to vertical, applies the H/F and then re-rotates them back the way they were.

Bit busy right now but will post a sample script later.
lcharles
Registered: Feb 4 2010
Posts: 10
Thanks, I am definitely NOT a programmer so the script (and how to use it) would be very helpful.
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Given it's a pain to apply H/Fs etc via scripts, the simplest way to do this is to define two functions (one to store and reset the rotations, and one to put them back again).

I've put them both in a script that also adds an entry to the 'Advanced' menu - "Rotations" (assuming you have JavaScript enabled, which is controlled in General Preferences!)

// Acrobat JavaScript to process PDFs with rotated pages, ready to add watermarks etc.// by Dave Merchant, www.uvsar.com // First run "unRotate()" to store the list of affected pages and reset every page to R=0// Then apply your watermarks etc in the normal way// Then run "reRotate()" to reapply the stored rotation values  var rotatedPageList = new Array();		// contains page numbers and rotations  function unRotate() {var _rdeg = 0;var _ind = 0;rotatedPageList = new Array();for (i=0; i<this.numPages; i++) {_rdeg = this.getPageRotation(i);if (_rdeg) {rotatedPageList[i] = _rdeg;this.setPageRotations(i);_ind++;}}app.alert( {cMsg: "Stored and removed rotation for " + _ind + " pages", nIcon:3, cTitle: "Rotations Removed"} );}  function reRotate() {var _pge;var _ind = 0;var _len = rotatedPageList.length;if (_len) {for (i=0; i<_len; i++) {if (rotatedPageList[i]) {this.setPageRotations(i, i, rotatedPageList[i]);_ind++;}}app.alert( {cMsg: "Reset rotation for " + _ind + " pages", nIcon:3, cTitle: "Rotations Reset"} );} else {app.alert( {cMsg: "No stored list of pages to rotate!", nIcon:0, cTitle: "ERROR" });}rotatedPageList = new Array(); } app.addSubMenu({ cName: "Rotations", cParent: "Advanced", nPos: 0 }); app.addMenuItem({ cName: "Store and unrotate", cParent: "Rotations",cExec: "unRotate();",cEnable: "event.rc = (event.target != null);" }); app.addMenuItem({ cName: "Re-apply rotations", cParent: "Rotations",cExec: "reRotate();",cEnable: "event.rc = ((event.target != null) && (rotatedPageList.length > 0));" });

Copy all that and paste it into a new text file, called "rotations.js" or whatever. Save the file in your startup script folder, which on Win will be

\Program Files\Adobe\Acrobat 9.0\Acrobat\Javascripts

Restart Acrobat and you'll get the menu (after a little delay while the script engine wakes up). Open your PDF, choose "Store and unrotate", do your headers etc, then choose "Re-apply rotations".

Remember though - this only finds software-rotated pages. If the document was distilled with the pages already turned, Acrobat won't know.


If you just want to try the script once, open your console window (CTRL-J), press ENTER to wake it up, clear it with the trashcan symbol and paste the entire code into it. Select it all (CTRL-A) and press CTRL-ENTER to run it. You'll get your menu items until you close Acrobat again.
lcharles
Registered: Feb 4 2010
Posts: 10
Thank you so much. I expect this will be a big help.