-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added three small helper scripts, versions to pandoc
- Loading branch information
1 parent
95e0a96
commit 38644c5
Showing
5 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
|
||
# Make a pdf File Smaller by downscaling all included images | ||
|
||
# strict error handling | ||
set -o pipefail # trace ERR through pipes | ||
set -o errtrace # trace ERR through 'time command' and other functions | ||
set -o nounset # set -u : exit the script if you try to use an uninitialized variable | ||
set -o errexit # set -e : exit the script if any statement returns a non-true return value | ||
|
||
|
||
echo "Make a pdf File Smaller by downscaling all included images." | ||
|
||
source="$1" | ||
name="${source%%.*}" | ||
dest="$name.pdf" | ||
|
||
if [ -f "$dest" ]; then | ||
useSource="$name.original.pdf" | ||
echo "Creating backup '$useSource' of '$dest'." | ||
cp "$dest" "$useSource" | ||
else | ||
useSource="$source" | ||
fi | ||
|
||
resolution=${2:-} | ||
|
||
if [[ -n "$resolution" ]] | ||
then | ||
echo "The resolution '$resolution' was specified." | ||
else | ||
resolution=192 | ||
echo "No resolution was specified, using '$resolution'." | ||
fi | ||
|
||
echo "Downscaling '$useSource' to '$dest'." | ||
|
||
gs -q -dEmbedAllFonts=true -dSubsetFonts=true -dCompressFonts=true \ | ||
-dOptimize=true \ | ||
-dPreserveCopyPage=false -dPreserveEPSInfo=false -dPreserveHalftoneInfo=false \ | ||
-dPreserveOPIComments=false -dPreserveOverprintSettings=false \ | ||
-dPreserveSeparation=false -dPreserveDeviceN=false \ | ||
-dMaxBitmap=2147483647 \ | ||
-dDownsampleMonoImages=true -dDownsampleGrayImages=true -dDownsampleColorImages=true \ | ||
-dColorImageDownsampleType=/Bicubic -dGrayImageDownsampleType=/Bicubic \ | ||
-dMonoImageDownsampleType=/Bicubic \ | ||
-dColorImageResolution=$resolution -dGrayImageResolution=$resolution -dMonoImageResolution=$resolution \ | ||
-dFastWebView=false \ | ||
-dNOPAUSE -dQUIET -dBATCH -dSAFER -sDEVICE=pdfwrite -dAutoRotatePages=/PageByPage \ | ||
-sOutputFile="$dest" "$useSource" \ | ||
-c .setpdfwrite "<</NeverEmbed [ ]>> setdistillerparams" | ||
|
||
|
||
chmod 777 "$dest" || true | ||
|
||
echo "Finished creating downsampled, smaller version." | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash - | ||
|
||
# This script filters a PDF file and attempts to include | ||
# as many fonts as possible. It works like filterPdf, but | ||
# avoids image re-encoding. | ||
|
||
# strict error handling | ||
set -o pipefail # trace ERR through pipes | ||
set -o errtrace # trace ERR through 'time command' and other functions | ||
set -o nounset # set -u : exit the script if you try to use an uninitialized variable | ||
set -o errexit # set -e : exit the script if any statement returns a non-true return value | ||
|
||
scriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
"$scriptDir/__filterPdf.sh" "$1" "-dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode -dColorConversionStrategy=/LeaveColorUnchanged" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# strict error handling | ||
set -o pipefail # trace ERR through pipes | ||
set -o errtrace # trace ERR through 'time command' and other functions | ||
set -o nounset # set -u : exit the script if you try to use an uninitialized variable | ||
set -o errexit # set -e : exit the script if any statement returns a non-true return value | ||
|
||
# Find non-ASCII characters which may cause problems in tex documents. | ||
grep --color='auto' -P -n '[^\x00-\x7F]' "$1" |