title: Ghostscript merge of pdf's is causing orientation to flip
body: <p>Ghostscript merge of pdf's is causing orientation to flip</p>
  
  <p>I'm using a similar method as this SO question:
  <a href="https://stackoverflow.com/questions/3444931">How to merge two postscript files together?</a></p>
  
  <p>On the merged PDF, every couple pages are flipped upside down. I haven't seen it mentioned anywhere else about this symptom. Merging a single troublesome pdf still has the orientation upside down.</p>
  
  <pre><code>@echo off
  REM FILE: merge.bat
  
  call :merge 1 155 out.pdf
  pause
  goto :eof
  
  REM MERGE PDFs
  REM @param # of first file in sequence
  REM @param # of last file in sequence
  REM @param new file of merged pdf
  goto :eof
  :merge
  SET START=%1
  SET END=%2
  SET OUT=%3
  echo START=%START%
  echo END=%END%
  echo OUT=%OUT%
  echo.
  SET CMD="c:\Program Files\gs\gs9.01\bin\gswin32c.exe"
  SET INPUT_DIR=c:\input
  SET CMD_ARGS=args.bat
  echo Generating args file...
  (echo.|set /p="-dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=%OUT% ") &gt; %CMD_ARGS%
  for /L %%G IN (%START%,1,%END%) do (
    (echo.|set /p=" "%INPUT_DIR%\%%G.pdf" ") &gt;&gt; %CMD_ARGS%
  )
  echo. &gt;&gt; %CMD_ARGS%
  del %OUT%
  if exist %OUT% goto :error
  echo Executing command...
  %CMD% @%CMD_ARGS%
  del %CMD_ARGS%
  echo Done.
  if not exist %OUT% goto :error
  goto :eof
  
  :error
  echo Error processing command.
  goto :eof
  </code></pre>