title: Scale scanned PDF without resampling image layer
body: <p>I have a batch of PDFs (about 80,000 files) that consist of scanned pages.  The pixel size of the image layer is consistent with 300dpi, but seems to be set to 72dpi.  As a result the page size is showing something like 46x35 inches.  I need to adjust these files so they register as 8.5 x 11, or whatever their natural size is, and I need to be able to script the process so I can leave this to churn on 80,000 documents (2-5 pages per document.)  </p>
  
  <p>I'd like to avoid resampling the image layer since that would potentially add loss, and slow the process down significantly.  I've tried:</p>
  
  <pre><code>convert -density 300x300 input.pdf output.pdf
  </code></pre>
  
  <p>But it resamples the images.  I've tried different variants on ghostscript such as</p>
  
  <pre><code>gs \
    -o output.pdf \
    -sDEVICE=pdfwrite \
    -dDownsampleMonoImages=false \
    -dMonoImageResolution=300 \
     input.pdf
  </code></pre>
  
  <p>That generates a file, but it seems unchanged, and and still registers as oversized.  Also, the pages are different sizes and orientations.  So forcing them all to one size/orientation won't work.</p>
  
  <p>(FYI, really I wouldn't care, but the next step is to have Acrobat Pro OCR all these files, and its OCR chokes on anything over 45 inches.)</p>