Ver código fonte

v2.3.6 - fix grep detection method fail on some rare cases, would make execution fail instead of fail-safing

master
Gustavo Arnosti Neves 7 anos atrás
pai
commit
c679b863e9
1 arquivos alterados com 13 adições e 6 exclusões
  1. +13
    -6
      pdfScale.sh

+ 13
- 6
pdfScale.sh Ver arquivo

@@ -1359,8 +1359,10 @@ getPageSizeCatGrep() {
# Get MediaBox data if possible # Get MediaBox data if possible
local mediaBox="$("$GREPBIN" -a -e '/MediaBox' -m 1 "$INFILEPDF" 2>/dev/null)" local mediaBox="$("$GREPBIN" -a -e '/MediaBox' -m 1 "$INFILEPDF" 2>/dev/null)"


mediaBox="${mediaBox##*/MediaBox[}"
mediaBox="${mediaBox##*/MediaBox}"
mediaBox="${mediaBox##*[}"
mediaBox="${mediaBox%%]*}" mediaBox="${mediaBox%%]*}"
#echo "mediaBox=$mediaBox"


# No page size data available # No page size data available
if isEmpty "$mediaBox" && isNotAdaptiveMode; then if isEmpty "$mediaBox" && isNotAdaptiveMode; then
@@ -1369,15 +1371,11 @@ getPageSizeCatGrep() {
return $FALSE return $FALSE
fi fi


# remove chars [ and ]
#mediaBox="${mediaBox//[}"
#mediaBox="${mediaBox//]}"

mediaBox=($mediaBox) # make it an array mediaBox=($mediaBox) # make it an array
mbCount=${#mediaBox[@]} # array size mbCount=${#mediaBox[@]} # array size


# sanity # sanity
if [[ $mbCount -lt 4 ]] || ! isFloat "${mediaBox[2]}" || ! isFloat "${mediaBox[3]}"; then
if [[ $mbCount -lt 4 ]] || ! isFloat "${mediaBox[2]}" || ! isFloat "${mediaBox[3]}" || isZero "${mediaBox[2]}" || isZero "${mediaBox[3]}"; then
if isNotAdaptiveMode; then if isNotAdaptiveMode; then
notAdaptiveFailed $'Error when reading the page size!\nThe page size information is invalid!' notAdaptiveFailed $'Error when reading the page size!\nThe page size information is invalid!'
fi fi
@@ -1388,9 +1386,18 @@ getPageSizeCatGrep() {
PGWIDTH=$(printf '%.0f' "${mediaBox[2]}") # Get Round Width PGWIDTH=$(printf '%.0f' "${mediaBox[2]}") # Get Round Width
PGHEIGHT=$(printf '%.0f' "${mediaBox[3]}") # Get Round Height PGHEIGHT=$(printf '%.0f' "${mediaBox[3]}") # Get Round Height


#echo "PGWIDTH=$PGWIDTH // PGHEIGHT=$PGHEIGHT"
return $TRUE return $TRUE
} }


isZero() {
[[ "$1" == "0" ]] && return $TRUE
[[ "$1" == "0.0" ]] && return $TRUE
[[ "$1" == "0.00" ]] && return $TRUE
[[ "$1" == "0.000" ]] && return $TRUE
return $FALSE
}

# Prints error message and exits execution # Prints error message and exits execution
notAdaptiveFailed() { notAdaptiveFailed() {
local errProgram="$2" local errProgram="$2"


Carregando…
Cancelar
Salvar