Last active
December 27, 2016 10:43
-
-
Save eyalroz/9b3bb9ad3507cf7204ecc597c76572a3 to your computer and use it in GitHub Desktop.
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 | |
# | |
# sgn2pdf | |
# by Eyal Rozenberg <[email protected]> | |
# version: 2016-12-27 | |
# | |
# Extracts a PDF file from an Israeli courts' .sgn PDF document envelope | |
# | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# The text of the GNU General Public License is available at: | |
# <http://www.gnu.org/licenses/>. | |
# | |
# | |
# TODO: Support taking the input and output filenames from the command-line arguments | |
exec 3<&0 # tie (new) file descriptor 3 to what is currently the standard input | |
exec 4>&1 # tie (new) file descriptor 4 to what is currently the standard output | |
if [[ $# > 0 ]]; then | |
exec 3<$1 | |
shift | |
fi | |
if [[ $# > 0 ]]; then | |
exec 4>$1 | |
shift | |
fi | |
exec <&3 >&4 | |
sed -r 's/^.*<DocumentContent[^>]*>//; s/<\/Document.*$//;' | base64 -d -i >&4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment