瀏覽代碼

Merge pull request #1 from boillodmanuel/add-fit-page-option

Add fit page option
master
Manuel Boillod 6 年之前
committed by GitHub
父節點
當前提交
2a2e5b79e1
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 2 個檔案被更改,包括 35 行新增2 行删除
  1. +5
    -0
      README.md
  2. +30
    -2
      pdfScale.sh

+ 5
- 0
README.md 查看文件

@@ -195,6 +195,11 @@ Parameters:
n, none Retains orientation of each page
a, all Rotates all pages (or none) depending
on a kind of "majority decision"
--fit-page <mode>
Use of GS option dPDFFitPage, used by default
This option is only valid in resize mode
Modes: f, fit Fit page
n, no Do not fit page
--hor-align, --horizontal-alignment <left|center|right>
Where to translate the scaled page
Default: center


+ 30
- 2
pdfScale.sh 查看文件

@@ -56,6 +56,7 @@ CUSTOM_RESIZE_PAPER=$FALSE # If we are using a custom-defined paper
FLIP_DETECTION=$TRUE # If we should run the Flip-detection
FLIP_FORCE=$FALSE # If we should force Flipping
AUTO_ROTATION='/PageByPage' # GS call auto-rotation setting
FIT_PAGE='-dPDFFitPage' # GS call resize fit page setting
PGWIDTH="" # Input PDF Page Width
PGHEIGHT="" # Input PDF Page Height
RESIZE_WIDTH="" # Resized PDF Page Width
@@ -333,7 +334,7 @@ gsPageResize() {
-dSubsetFonts=true -dEmbedAllFonts=true \
-dDEVICEWIDTHPOINTS=$RESIZE_WIDTH -dDEVICEHEIGHTPOINTS=$RESIZE_HEIGHT \
-dAutoRotatePages=$AUTO_ROTATION \
-dFIXEDMEDIA -dPDFFitPage \
-dFIXEDMEDIA $FIT_PAGE \
-sOutputFile="$OUTFILEPDF" \
-f "$INFILEPDF"
return $?
@@ -354,7 +355,7 @@ gsPrintPageResize() {
-dSubsetFonts=true -dEmbedAllFonts=true \
-dDEVICEWIDTHPOINTS=$RESIZE_WIDTH -dDEVICEHEIGHTPOINTS=$RESIZE_HEIGHT \
-dAutoRotatePages=$AUTO_ROTATION \
-dFIXEDMEDIA -dPDFFitPage \
-dFIXEDMEDIA $FIT_PAGE \
-sOutputFile="$OUTFILEPDF" \
-f "$INFILEPDF"
_EOF_
@@ -518,6 +519,11 @@ getOptions() {
parseAutoRotationMode "$1"
shift
;;
--fit-page)
shift
parseFitPageMode "$1"
shift
;;
--background-gray)
shift
parseGrayBackground $1
@@ -1073,6 +1079,23 @@ parseAutoRotationMode() {
esac
}

# Parses and validates the resize fit page
parseFitPageMode() {
local param="$(lowercase $1)"
case "${param}" in
n|no)
FIT_PAGE=''
;;
f|fit)
FIT_PAGE='-dPDFFitPage'
;;
*)
initError "Invalid Resize Fit Page Mode: \"$1\"" $EXIT_INVALID_OPTION
return $FALSE
;;
esac
}

# Validades the a paper resize CLI option and sets the paper to $RESIZE_PAPER_TYPE
parsePaperResize() {
isEmpty "$1" && initError 'Invalid Paper Type: (empty)' $EXIT_INVALID_PAPER_SIZE
@@ -2095,6 +2118,11 @@ Parameters:
n, none Retains orientation of each page
a, all Rotates all pages (or none) depending
on a kind of \"majority decision\"
--fit-page <mode>
Use of GS option dPDFFitPage, used by default
This option is only valid in resize mode
Modes: f, fit Fit page
n, no Do not fit page
--hor-align, --horizontal-alignment <left|center|right>
Where to translate the scaled page
Default: center


Loading…
取消
儲存