Initial public release of pdf-tools
Command-line tools for marked-up PDFs and scanned handwritten notes: pdf-scrub, pdf-notes-md, scan-notes-md (Ollama by default, Claude on request), scan-notes-index (per-page search metadata), and scan-notes-stats. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011ZSvbNaLhgFuTm7wmkgbWs
This commit is contained in:
commit
e464871b69
29 changed files with 5296 additions and 0 deletions
49
scripts/scrub-and-mail.sh
Executable file
49
scripts/scrub-and-mail.sh
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bash
|
||||
# scrub-and-mail.sh — scrub a PDF and open a new Mail.app message with it attached.
|
||||
#
|
||||
# Usage:
|
||||
# scrub-and-mail.sh /path/to/file.pdf
|
||||
#
|
||||
# Designed to be called from a macOS Quick Action / Service / Shortcut
|
||||
# with the selected PDF passed as $1.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo "usage: $0 <pdf>" >&2
|
||||
exit 64
|
||||
fi
|
||||
|
||||
IN="$1"
|
||||
if [[ ! -f "$IN" ]]; then
|
||||
echo "error: not a file: $IN" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Write the scrubbed copy to a temp dir so we don't pollute Dropbox.
|
||||
TMPDIR_OUT="$(mktemp -d -t pdfscrub)"
|
||||
BASENAME="$(basename "$IN" .pdf)"
|
||||
OUT="$TMPDIR_OUT/${BASENAME}_clean.pdf"
|
||||
|
||||
# Resolve the CLI. Prefer the installed entry point; fall back to
|
||||
# `uv run` from the project directory if you keep it ephemeral.
|
||||
if command -v pdf-scrub >/dev/null 2>&1; then
|
||||
pdf-scrub "$IN" -o "$OUT" >/dev/null
|
||||
else
|
||||
: "${PDF_TOOLS_DIR:?set PDF_TOOLS_DIR to the project path or install pdf-scrub}"
|
||||
(cd "$PDF_TOOLS_DIR" && uv run pdf-scrub "$IN" -o "$OUT" >/dev/null)
|
||||
fi
|
||||
|
||||
# Hand off to Mail.app. POSIX path -> HFS path for AppleScript's `file`.
|
||||
osascript <<APPLESCRIPT
|
||||
set theAttachment to POSIX file "$OUT"
|
||||
tell application "Mail"
|
||||
set theMessage to make new outgoing message with properties {visible:true, subject:"$BASENAME"}
|
||||
tell theMessage
|
||||
make new attachment with properties {file name:theAttachment} at after last paragraph
|
||||
end tell
|
||||
activate
|
||||
end tell
|
||||
APPLESCRIPT
|
||||
|
||||
echo "opened Mail with: $OUT" >&2
|
||||
Loading…
Add table
Add a link
Reference in a new issue