Created
February 22, 2023 07:52
-
-
Save s417-lama/5d65627acbc5389280d7edbb244e0f5a to your computer and use it in GitHub Desktop.
A shell script to put an IEEE copyright notice at the bottom of the front page of the paper
This file contains 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 -euo pipefail | |
if [[ $# != 4 ]]; then | |
echo "Usage: $0 YEAR DOI INPUT.pdf OUTPUT.pdf" >&2 | |
echo "Example: $0 2023 XX.XXXX/XXXXX.XXXX.XXXXX INPUT.pdf OUTPUT.pdf" >&2 | |
exit 1 | |
fi | |
YEAR=$1 | |
DOI=$2 | |
INPUT_FILE=$3 | |
OUTPUT_FILE=$4 | |
CPDF_CMD=${CPDF_CMD:-cpdf} | |
if ! command -v $CPDF_CMD &> /dev/null; then | |
echo "The command '$CPDF_CMD' could not be found." | |
echo "Please install the 'cpdf' command or specify the correct binary location by the 'CPDF_CMD' environment variable." | |
exit | |
fi | |
STR="© $YEAR IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works. DOI: $DOI" | |
FMTSTR=$(echo "$STR" | fmt -160) | |
echo "The following copyright notice will be put:" | |
echo | |
echo "$FMTSTR" | |
echo | |
echo "Please be aware that this tool is NOT official. Please consult the latest information from IEEE: https://journals.ieeeauthorcenter.ieee.org/become-an-ieee-journal-author/publishing-ethics/guidelines-and-policies/post-publication-policies/" | |
echo | |
FMTSTR_IN=$(echo "$FMTSTR" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g') | |
$CPDF_CMD -add-text "$FMTSTR_IN" -bottom 8pt -font-size 8 -line-spacing 1.1 $INPUT_FILE 1 -o $OUTPUT_FILE | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment