- promptForFilename setting (default true; env VERAE_PROMPT_FOR_FILENAME), 'verae-print config --prompt-for-filename', last Save As folder in ~/.verae/state.json - Windows helper: common file dialog (PDF filter, overwrite prompt, topmost owner) before stamping; macOS printer path: choose file name (NSSavePanel) via 'stamp -prompt-name -title'; cancel discards the job (no stamp/credit) - job.Options.OutPath: original saved at the chosen path, certificate and .verae.json next to it with the chosen base name (never overwritten) - held jobs keep the chosen path (pendingMeta.OutPath) - installer: 'Ask for a file name for each print' checkbox; removed the 'Open the user guide' finish-page checkbox; mac-key-setup asks too - auth test no longer touches the real macOS keychain (VERAE_SKIP_KEYCHAIN) - version 0.3.2
64 lines
2 KiB
Shell
Executable file
64 lines
2 KiB
Shell
Executable file
#!/bin/bash
|
|
# ippeveprinter -c handler: PDF (or PS) on stdin → Verae stamp with approved naming.
|
|
set -euo pipefail
|
|
|
|
LOG="${HOME}/Library/Logs/verae-print-ipp.log"
|
|
mkdir -p "$(dirname "$LOG")"
|
|
exec >>"$LOG" 2>&1
|
|
echo "$(date -u +%Y-%m-%dT%H:%MZ) IPP job start env=$(env | grep -E '^IPP_|^CONTENT_|^USER=' | tr '\n' ' ')"
|
|
|
|
VERAE_PRINT="${VERAE_PRINT_BIN:-$HOME/bin/verae-print}"
|
|
OUT_DIR="${HOME}/Documents/Verae Timestamps"
|
|
mkdir -p "$OUT_DIR"
|
|
|
|
# First-run: require customer xVerae- signing key (opens portal dialogs)
|
|
if ! "$VERAE_PRINT" setup; then
|
|
echo "ERROR: signing key setup required" >&2
|
|
osascript -e 'display notification "Create a Verae customer account to get your signing key" with title "Verae Timestamping"' || true
|
|
open "https://customer.verae.ai/portal/" 2>/dev/null || true
|
|
exit 1
|
|
fi
|
|
|
|
TITLE="${IPP_JOB_NAME:-${IPP_DOCUMENT_NAME:-document}}"
|
|
# Strip path / extension for stem
|
|
BASE="$(basename "$TITLE")"
|
|
STEM="${BASE%.*}"
|
|
STEM="$(echo "$STEM" | tr -cd 'A-Za-z0-9._ -' | head -c 80)"
|
|
STEM="${STEM:-document}"
|
|
|
|
TMPDIR="${TMPDIR:-/tmp}"
|
|
WORK="$(mktemp -d "${TMPDIR}/verae-ipp.XXXXXX")"
|
|
RAW="$WORK/job.bin"
|
|
PDF="$WORK/${STEM}.pdf"
|
|
|
|
# ippeveprinter may pass a spool file as argv[1], or feed bytes on stdin
|
|
if [[ $# -ge 1 && -f "${1:-}" ]]; then
|
|
echo "input file arg: $1"
|
|
cp "$1" "$RAW"
|
|
elif [[ ! -t 0 ]]; then
|
|
cat >"$RAW"
|
|
else
|
|
echo "ERROR: no document on stdin or argv" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -s "$RAW" ]]; then
|
|
echo "ERROR: empty document" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$(head -c 4 "$RAW")" == "%PDF" ]]; then
|
|
cp "$RAW" "$PDF"
|
|
elif command -v /usr/bin/pstopdf >/dev/null 2>&1; then
|
|
/usr/bin/pstopdf "$RAW" -o "$PDF" || cp "$RAW" "$PDF"
|
|
else
|
|
cp "$RAW" "$PDF"
|
|
fi
|
|
|
|
echo "stamping stem=$STEM pdf=$PDF"
|
|
# -prompt-name: Save As dialog first when promptForFilename is on (default);
|
|
# Cancel discards the job (nothing stamped, no credit used).
|
|
"$VERAE_PRINT" stamp -out-dir "$OUT_DIR" -name "$STEM" -title "${IPP_JOB_NAME:-${IPP_DOCUMENT_NAME:-}}" -prompt-name -open "$PDF"
|
|
echo "ATTR: job-impressions-completed=1" >&2
|
|
rm -rf "$WORK"
|
|
exit 0
|