14 Replies Latest reply: Mar 2, 2010 11:02 AM by handellphp
BenChase Level 1 Level 1 (10 points)
Is there a way to take a PDF that is 300dpi and convert it to 150 or 72dpi?
  • Mark Larsen Level 1 Level 1 (110 points)
    Do you have Adobe's Acrobat Pro app?
  • handellphp Level 1 Level 1 (10 points)
    Try resave from preview app
  • BenChase Level 1 Level 1 (10 points)
    Yes, I have Acro pro but this would be for a large group of files and batch processes and pdf optimizing are not scriptable by either applescript or javascript.

    Preview is also not scriptable.

    I was thinking there might be a way using image events but I don't know much about it.
  • Mark Larsen Level 1 Level 1 (110 points)
    It is possible via JavaScript as of Acrobat 9. You need to look at creating a Pre-Flight in the app then you can call upon that with JavaScript. You optimize as part of the Pre-Flight conditions. You can batch the files with AppleScript then use do JavaScript.
  • BenChase Level 1 Level 1 (10 points)
    I have Acro pro 7 and 8 but not 9. Is there a way to do it in 8?

    What about using "sips" in terminal, have you ever used that?
  • Mark Larsen Level 1 Level 1 (110 points)
    I too am stuck with versions 7 & 8 and its NOT possible to add the optimization to a Preflight. You can save Preflights as droplets (apps) and use then to open and check PDF's but thats about it. Sorry.
  • Chachi Level 4 Level 4 (2,525 points)
    Using sips works for single page pdfs. The usage would be as follows:

    *sips -s format pdf -s dpiHeight 72 -s dpiWidth 72 -s formatOptions low /path/to/pdf.pdf --out /path/to/converted/pdf.pdf*

    The formatOptions may be low, normal, high, best or a %. There are many different ways to adapt this to AppleScript using "*do shell script*".
  • BenChase Level 1 Level 1 (10 points)
    Thanks.

    This is what I tried...

    do shell script "sips -s format pdf -s dpiHeight 72 -s dpiWidth 72 -s formatOptions low Macintosh HD/Users/mkt/Desktop/HR PDF's/A22 351-00-7385 0310.pdf --out Macintosh HD/Users/mkt/Desktop/PA Folder/test.pdf"

    This is what I got...

    error "sh: -c: line 0: unexpected EOF while looking for matching `''
    sh: -c: line 1: syntax error: unexpected end of file" number 2
  • Chachi Level 4 Level 4 (2,525 points)
    The apostrophe in your "HR PDF's" folder name is throwing things off as well as the spaces and unnecessary "Macintosh HD". Try this instead:
    <pre style="width:630px;height:auto;overflow-x:auto;overflow-y:hidden;"
    title="Copy this text and paste it into your Script Editor application.">

    set inFile to quoted form of "/Users/mkt/Desktop/HR PDF's/A22 351-00-7385 0310.pdf"
    set outFile to quoted form of "/Users/mkt/Desktop/PA Folder/test.pdf"
    do shell script "sips -s format pdf -s dpiHeight 12 -s dpiWidth 12 -s formatOptions low " & ¬
    inFile & " --out " & outFile

    </pre>
    Hope this helps...
  • BenChase Level 1 Level 1 (10 points)
    Thanks Chachi that works now. The next problem is that this changes the actual size of the document so that when I open it in Acrobat or preview the size is no longer what it used to be. This messes up the following parts of the script. Is there a way to keep it the same size but lower the resolution?
  • handellphp Level 1 Level 1 (10 points)
    Usally the output resolution can be set when saving the file from the application.

    You can use AI to (script) convert if the PDF's are only one page. I strongly recommend getting Acrobat Pro though.

    Online I use Image Magick to convert files, It does a super job.
    good luck
  • Chachi Level 4 Level 4 (2,525 points)
    You can adjust the size using "-Z":
    <pre style="width:630px;height:auto;overflow-x:auto;overflow-y:hidden;" title="Copy this text and paste it into your Script Editor application.">

    set inFile to quoted form of "/Users/mkt/Desktop/HR PDF's/A22 351-00-7385 0310.pdf"
    set outFile to quoted form of "/Users/mkt/Desktop/PA Folder/test.pdf"
    do shell script "sips -s format pdf -s dpiHeight 12 -s dpiWidth 12 -s formatOptions low -Z 800 " & ¬
    inFile & " --out " & outFile

    </pre>
  • BenChase Level 1 Level 1 (10 points)
    Handellphp, what do you mean by AI? Also is Acrobat Pro 9 the only version that you can for sure do that in? I'd prefer to use Acrobat Pro too but can't find a way to script it in either v7 or 8.

    Chachi, Thanks, that works but it very difficult to get the page size to be exactly what it was before and really degrades the quality.
  • handellphp Level 1 Level 1 (10 points)
    AI = Adobe Illustrator.

    Since you are limited by software.
    have you tried to script the "System Events"


    example:
    tell application "Adobe Reader"
    activate


    tell application "System Events"
    -----do your menu or keyboard command here
    keystroke "+" using {command down}
    end tell


    end tell


    Are you able to PRINT/SAVE to a file as a smaller PDF doc.