Posts Tagged ‘acrobat’

Create a low resolution pdf of a LaTeX paper

Thursday, April 21st, 2016

Here’re the steps I use to create a low resolution version of a pdf created by LaTeX.

The simple thing to do is to follow the steps to create a camera ready (high res) pdf but replace the JPG settings to downsample the images and perhaps reduce the quality.

If you have a lot of raster images, this will work OK.

However, if you have a lot of vector graphics images or just a lot of images, this will not truly bring down the size of the final pdf.

For this I make sure that all of my \includegraphics commands in LaTeX are of the form:

\includegraphics[width=\linewidth]{\figs/figure-file-name}

Notice three things:

  1. the width is explicitly specified,
  2. the figure directory is a command/macro \figs, and
  3. the filename does not have an extension (figure-file-name instead of figure-file-name.pdf)

Then at the beginning of my file I have defined \figs. For the normal high resolution pdf I use:

\newcommand{\figs}{}
\def\figs/{figs/}

When I switch to low resolution I use

\newcommand{\figs}{}
%\def\figs/{figs/}
\def\figs/{figs/low-res/}

And before compiling I run the commands:

mkdir -p figs/low-res/
mogrify -colorspace RGB -resize 400x -background white -alpha remove -quality 100 -format jpg -path figs/low-res/ figs/*.{pdf,png}[0]

There are a couple import flags here to ensure that the background is white and only a single output is created for pdfs with accidentally multiple art-boards/pages.

Save As Optimized PDF using Acrobat Pro via the command line

Saturday, January 2nd, 2016

Here’s a tremendously hacky way to automate the procedure of optimizing a PDF using Acrobat Pro (with default settings) from the command line. It’s an applescript sending mouse clicks and keyboard signals so don’t get too excited.

However, I’m doing this all the time and it will hopefully save clicking through menus.

#!/usr/bin/osascript
on run argv
    if (count of argv) < 2 then
        do shell script "echo " & "\"optimizepdf path/to/input.pdf simple-output-name\""
    else
        set p to item 1 of argv
        set out_name to item 2 of argv
        set abs to do shell script "[[ \"" & p & "\" = /* ]] && echo \"" & p & "\" || echo \"$PWD/\"" & p & "\"\""
        set a to POSIX file abs
        tell application "Adobe Acrobat Pro"
            activate
            open a
            tell application "System Events"
                click menu item "Optimized PDF..." of ((process "Acrobat")'s (menu bar 1)'s ¬
                    (menu bar item "File")'s (menu "File")'s ¬
                    (menu item "Save As")'s (menu "Save As"))
                tell process "Acrobat"
                    keystroke return
                    keystroke out_name
                    keystroke return
                    keystroke "r" using {command down}
                end tell
            end tell
            close document 1
        end tell
    end if
end run

Then you can run this with something like:

optimizepdf path/to/input.pdf simple-output-name

overwrite warning: this will overwrite the output file (and potentially files named similarly if the keystrokes fail or get garbled).

Oddly, it seems to work fastest if the input document is not already open in acrobat pro.

This code above is written for Acrobat Pro Version 10.1.16.

Update: Here’s a legacy version for Acrobat Pro Version 9.5.1

#!/usr/bin/osascript
on run argv
    if (count of argv) < 2 then
        do shell script "echo " & "\"optimizepdf path/to/input.pdf simple-output-name\""
    else
        set p to item 1 of argv
        set out_name to item 2 of argv
        set abs to do shell script "[[ \"" & p & "\" = /* ]] && echo \"" & p & "\" || echo \"$PWD/\"" & p & "\"\""
        set a to POSIX file abs
        tell application "Adobe Acrobat Pro"
            activate
            open a
            tell application "System Events"
                click menu item "PDF Optimizer..." of ((process "Acrobat")'s (menu bar 1)'s ¬
                    (menu bar item "Advanced")'s (menu "Advanced"))
                tell process "Acrobat"
                    keystroke return
                    keystroke out_name
                    keystroke return
                    keystroke "r" using {command down}
                end tell
            end tell
            close document 1
        end tell
    end if
end run

Note: You may have to enable scripts to use keystrokes.

Compress PDFs for camera ready publications using Adobe Acrobat Pro

Tuesday, June 18th, 2013

Here’re the settings I use to optimize the size of PDF files for camera ready publications. I have used this for all my recent publications and it usually reduces my PDF files from ~100MB to ~20MB without any noticeable loss in quality:

  1. Open input.pdf in acrobat pro
  2. Make compatible with Acrobat 5.0 and later
  3. Check Images
  4. Color Images: Downsample Off
  5. Color Images: Compression JPEG
  6. Color Images: Quality Maximum
  7. Grayscale Images: Downsample Off
  8. Grayscale Images: Compression JPEG
  9. Grayscale Images: Quality Maximum
  10. Monochromatic Images: Downsample Off
  11. Monochromatic Images: Compression JPEG
  12. Monochromatic Images: Quality Maximum
  13. Uncheck Fonts
  14. Check Discard Objects
  15. Uncheck all except Discard all alternate images and Discard embedded print settings
  16. Check Discard User Data
  17. Uncheck all except Discard private data of other applications and Discard hidden layer content and flatten visible layers
  18. Check Clean Up
  19. Object compression options: Compress document structure
  20. Uncheck all
  21. Save these settings as “Camera Ready”
  22. Hit OK and save as opt.pdf

Add hidden, searchable text-layer to PDF via OCR with Adobe Acrobat

Friday, March 29th, 2013

Forgot that I knew how to do this.

Document > OCR Text Recognition > Recognize Text Using OCR …

Batch optimize all pdfs in Papers database

Friday, November 16th, 2012

I use Papers2 to organize the academic papers that I read. I store the Papers database on Dropbox. Currently I have quite a few papers and the size of the database is going close to my Dropbox allowance. Here’s what I did to reduce the database size by about 50% using Adobe Acrobat Pro 9:

  1. Back up using:
    zip -r Papers2.zip Papers2/
  2. In Acrobat open some PDF
  3. Select Advanced > PDF Optimizer...
  4. Set up your according to taste. I use:
    • Make compatible with: “Acrobat 5.0 and later”
    • Check Images: Downsample: “OFF”, Compression: “JPEG”, Quality: “Maximum”
    • Uncheck Fonts
    • Uncheck Transparency
    • Uncheck Discard Objects
    • Check Discard User Data: Uncheck all, except: “Discard private data of other applications” and “Discard hidden layer content and flatten visible layers”
    • Uncheck Clean up
  5. Save these settings as “camera”
  6. Close the pdf optimizer and the current PDF document
  7. Select Advanced > Document Processing > Batch Processing...
  8. Select “New sequence”
  9. Under Run commands on: choose “Selected Folder” and select your Papers2 folder
  10. Under Select output location: “Same folder as originals”
  11. Finally, select Output options... and:
    • Select Keep original filenames
    • Uncheck Fast web view
    • Check PDF Optimizer and under Settings... choose your “camera” preset.
  12. Save and hit Run sequence

Sign a PDF form with an image

Saturday, October 13th, 2012

I tried to sign a PDF form that was sent to me using Acrobat Pro but all the sign fields were greyed out. TO get around this I first opened the document in Preview.app, clicked Print > PDF > Open PDF in Preveiw. This opens up a copy of the document, but the forms have been converted to a plain document. Then I could open it up in Acrobat and dump in my signature image using Tools > Comment & Markup > Stamps > Paste Clipboard Image as Stamp Tool.

Preview.app dropping embedded images in PDFs

Thursday, May 5th, 2011

Recently I had a very annoying problem that Preview.app was not displaying images embedded in a pdf in the correct order or at all. The bug in Preview.app seems to be a computability issue. I used the following steps in Adobe Acrobat Pro to fix PDFs that were not displaying correctly in Preview.app:

  1. Open broken.pdf in Adobe Acrobat Pro
  2. Go to Advanced > PDF Optimizer…
  3. Under Make compatible with: choose Acrobat 5.0 or later
  4. Uncheck Images
  5. Uncheck Fonts
  6. Uncheck Transparency
  7. Uncheck Discard Objects
  8. Check Discard User Data
  9. Under Discard User Data make sure only Discard hidden layer content and flatten visible layers is checked. Update: May also check Discard private data of other applications
  10. Uncheck Clean Up
  11. Hit OK and save as fixed.pdf

This should fix your PDF.

If your PDF shows missing images in Preview only after optimizing with Acrobat pro then try using the above as a starting point before tweaking optimization settings. It seems the key is to be sure Discard Objects > Discard embedded print settings is unchecked and Discard User Data > Discard hidden layer content and flatten visible layers is checked when optimizing.

Convert PDF to grayscale and compress

Friday, July 16th, 2010

Recently I compressed a 25 MB color pdf to a 900 KB grayscale pdf. Here’s how I did it:

  1. Open the original.pdf in Preview. Select File > Save As… and choose Quartz Filter: Gray Tone. Save it as original_gray.pdf. My 25 MB color image was reduced to 13 MB by this step alone.
    Note: You could do this in Acrobat but it’s much harder to find in the UI and actually crashed the program on my pdf.
  2. Open original_gray.pdf in Acrobat. Select File > Save As… and choose Format: Acrobat PDF Files, Optimized. Then click Settings.
    Make sure Images is selected on the left.
    Change the color Downsample: line to Bicubic Downsampling to 200 ppi for images above 300 ppi
    Change the color Compression: line to JPEG, High
    Change the grayscale Downsample: line to Bicubic Downsampling to 200 ppi for images above 300 ppi
    Change the grayscale Compression: line to JPEG, High

    Change the monochromatic Downsample: line to Bicubic Downsampling to 72 ppi for images above 108 ppi
    Change the monochromatic Compression: line to CCITT Group 4
    Note: You could do this in Preview with Quartz Filter: Reduce File Size, but some of images got their colors inverted.

Before
pdf compressed before
—> After
pdf compressed after