Created
February 24, 2017 05:45
-
-
Save munepi/b64491790800a4025cc31688a61b3ccc to your computer and use it in GitHub Desktop.
a command line interface that can convert PDF to PDF/X-1a via Adobe PostScript with Adobe Acrobat X Pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
showHelp(){ | |
echo usage: $(basename $0) path/to/input.pdf | |
return 0 | |
} | |
if [ $# -ne 1 ]; then | |
showHelp | |
exit 1 | |
fi | |
file $1 | grep -q 'PDF document' | |
if [ ! $? ]; then | |
showHelp | |
exit 1 | |
fi | |
pdf2psx1a.applescript $(dirname $1)/$(basename $1) | |
open -a '/Applications/Adobe Acrobat X Pro/Acrobat Distiller.app' $(dirname $1)/$(basename $1 .pdf)_x1a.ps | |
exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript | |
-- This apple script is a command line interface | |
-- that can convert PDF to PDF/X-1a via Adobe PostScript with Adobe Acrobat X Pro. | |
on run argv | |
if (count of argv) < 1 then | |
-- do shell script "echo " & "\"pdf2pdfx1a.applescript path/to/input.pdf\"" | |
do shell script "echo " & "\"pdf2psx1a.applescript path/to/input.pdf\"" | |
else | |
set p to item 1 of argv | |
set pcurrentFile to do shell script "[[ \"" & p & "\" = /* ]] && echo \"" & p & "\" || echo \"$PWD/\"" & p & "\"\"" | |
set currentFile to POSIX file pcurrentFile as Unicode text | |
set currentFileName to do shell script "basename \"" & pcurrentFile & "\"" | |
set poutputFolder to do shell script "[[ \"" & pcurrentFile & "\" = /* ]] && dirname \"" & pcurrentFile & "\" || echo \"$PWD/\"" | |
set outputFolder to POSIX path of poutputFolder as Unicode text | |
set currentFileShortName to text 1 thru -5 of currentFileName | |
set PSFileName to (currentFileShortName & "_x1a.ps") as string | |
set pPSFilePath to (outputFolder & "/" & PSFileName) as string | |
set PSFilePath to POSIX file pPSFilePath as Unicode text | |
-- log currentFile | |
-- log currentFileShortName | |
-- log PSFileName | |
-- log PSFilePath | |
set PDFFileName to (currentFileShortName & "_x1a.pdf") as string | |
set pPDFFilePath to (outputFolder & "/" & PDFFileName) as string | |
set PDFFilePath to POSIX file pPDFFilePath as Unicode text | |
-- tell application "Acrobat Distiller" | |
-- launch | |
-- delay 3 | |
-- end tell | |
-- PDF -> PostScript via Adobe Acrobat X Pro | |
tell application "Adobe Acrobat Pro" | |
activate | |
log "Converting " & currentFile & "... " | |
open currentFile | |
save document currentFileName ¬ | |
to file PSFilePath using PostScript Conversion ¬ | |
with embedded fonts, images, preview, separations and annotation ¬ | |
without binary given postScript level:3 | |
close document currentFileName | |
log "done: " & PSFilePath | |
end tell | |
-- -- PostScript -> PDF/X-1a via Acrobat Distiller | |
-- -- Requirements: run Acrobat Distiller and set one of PDF/X-1a | |
-- tell application "Acrobat Distiller" | |
-- activate | |
-- delay 3 | |
-- log "Converting " & PSFilePath & "... " | |
-- open PSFilePath | |
-- -- Distill sourcePath PSFilePath ¬ | |
-- -- adobePDFSettingsPath POSIX path of ("/Users/munepi/Library/Application Support/Adobe/Adobe PDF/Settings/EQUIOS X1a 2001_1_J.joboptions") | |
-- log "done: " & PDFFilePath | |
-- quit | |
-- end tell | |
end if | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment