Browse Source

more changes to verbose messages, updated run examples on readme

master
Gustavo Neves 8 years ago
parent
commit
24ce32fef9
2 changed files with 41 additions and 35 deletions
  1. +25
    -26
      README.md
  2. +16
    -9
      pdfScale.sh

+ 25
- 26
README.md View File

@@ -154,55 +154,54 @@ Examples:

## Example Runs
```
pdfscale -v -r a0 -s 1.05 ../mixsync\ manual\ v1-2-3.pdf
$ pdfscale -v -r a0 -s 1.05 ../mixsync\ manual\ v1-2-3.pdf
pdfscale v2.0.0 - Verbose Execution
Input file: ../mixsync manual v1-2-3.pdf
Output file: ../mixsync manual v1-2-3.A0.SCALED.pdf
Mixed Tasks: Resize & Scale
Input File: ../mixsync manual v1-2-3.pdf
Output File: ../mixsync manual v1-2-3.A0.SCALED.pdf
Get Page Size: Adaptive Enabled
Method: Cat + Grep
Source Width: 842 postscript-points
Source Height: 595 postscript-points
Mixed Tasks: Resize & Scale
Scale factor: 1.05
Flip Detect: Wrong orientation!
Inverting Width <-> Height
Run Resizing: A0 ( 3370 x 2384 ) pts
New Width: 3370 postscript-points
New Height: 2384 postscript-points
Scale Factor: 1.05
Translation X: -80.236330
Translation Y: -56.760656
Run Scaling: 5 %
Final Status: File created successfully
```
```
$ pdfscale -v -v -s 0.9 ../input-nup.pdf "../my glorius PDF"
2017-05-14:23:16:05 | pdfscale v2.0.0 - Verbose Execution
2017-05-14:23:16:05 | Input file: ../input-nup.pdf
2017-05-14:23:16:05 | Output file: ../my glorius PDF.pdf
2017-05-14:23:16:05 | Get Page Size: Adaptive Enabled
2017-05-14:23:16:05 | Method: Cat + Grep
2017-05-14:23:16:05 | Failed
2017-05-14:23:16:05 | Method: Mac Quartz mdls
2017-05-14:23:16:05 | Source Width: 842 postscript-points
2017-05-14:23:16:05 | Source Height: 595 postscript-points
2017-05-14:23:16:05 | Single Task: Scale PDF Contents
2017-05-14:23:16:05 | Scale factor: 0.9 (manual)
2017-05-14:23:16:05 | Translation X: 46.777310
2017-05-14:23:16:05 | Translation Y: 33.055225
2017-05-14:23:16:05 | Run Scaling: -10 %
2017-05-14:23:16:05 | Final Status: File created successfully
$ pdfscale -v -v -s 0.9 ../input-nup.pdf "../My Glorius PDF"
2017-05-14:23:43:46 | pdfscale v2.0.0 - Verbose Execution
2017-05-14:23:43:46 | Input File: ../input-nup.pdf
2017-05-14:23:43:46 | Output File: ../My Glorius PDF.pdf
2017-05-14:23:43:46 | Get Page Size: Adaptive Enabled
2017-05-14:23:43:46 | Method: Cat + Grep
2017-05-14:23:43:46 | Failed
2017-05-14:23:43:46 | Method: Mac Quartz mdls
2017-05-14:23:43:46 | Source Width: 842 postscript-points
2017-05-14:23:43:46 | Source Height: 595 postscript-points
2017-05-14:23:43:46 | Scale Factor: 0.9 (manual)
2017-05-14:23:43:46 | Translation X: 46.777310
2017-05-14:23:43:46 | Translation Y: 33.055225
2017-05-14:23:43:46 | Run Scaling: -10 %
2017-05-14:23:43:47 | Final Status: File created successfully
```
```
pdfscale -v -r a2 ../input.pdf
$ pdfscale -v -r a2 ../input.pdf
pdfscale v2.0.0 - Verbose Execution
Input file: ../input.pdf
Output file: ../input.A2.pdf
Single Task: Resize PDF Paper
Input File: ../input.pdf
Output File: ../input.A2.pdf
Get Page Size: Adaptive Enabled
Method: Cat + Grep
Source Width: 595 postscript-points
Source Height: 842 postscript-points
Single Task: Resize PDF Paper
Scale factor: Disabled (resize only)
Scale Factor: Disabled (resize only)
Flip Detect: No change needed
Run Resizing: A2 ( 1191 x 1684 ) pts
Final Status: File created successfully


+ 16
- 9
pdfScale.sh View File

@@ -77,17 +77,14 @@ EXIT_INVALID_PAPER_SIZE=50

# Main function called at the end
main() {
printVersion 1 'verbose'
checkDeps
vprint " Input file: $INFILEPDF"
vprint " Output file: $OUTFILEPDF"
vprint " Input File: $INFILEPDF"
vprint " Output File: $OUTFILEPDF"
getPageSize
vPrintSourcePageSizes ' Source'
local finalRet=$EXIT_ERROR

if isMixedMode; then
vprint " Mixed Tasks: Resize & Scale"
vprint " Scale factor: $SCALE"
outputFile="$OUTFILEPDF" # backup outFile name
tempFile="${OUTFILEPDF%.pdf}.__TEMP__.pdf" # set a temp file name
OUTFILEPDF="$tempFile" # set output to tmp file
@@ -98,20 +95,19 @@ main() {
PGWIDTH=$RESIZE_WIDTH # we already know the new page size
PGHEIGHT=$RESIZE_HEIGHT # from the last command (Resize)
vPrintSourcePageSizes ' New'
vPrintScaleFactor
pageScale # scale the resized pdf
finalRet=$(($finalRet+$?))
# remove tmp file
rm "$tempFile" >/dev/null 2>&1 || printError "Error when removing temporary file: $tempFile"
elif isResizeMode; then
vprint " Single Task: Resize PDF Paper"
vprint " Scale factor: Disabled (resize only)"
vPrintScaleFactor "Disabled (resize only)"
pageResize
finalRet=$?
else
local scaleMode=""
vprint " Single Task: Scale PDF Contents"
isManualScaledMode && scaleMode='(manual)' || scaleMode='(auto)'
vprint " Scale factor: $SCALE $scaleMode"
vPrintScaleFactor "$SCALE $scaleMode"
pageScale
finalRet=$?
fi
@@ -206,12 +202,16 @@ getOptions() {
isPDF "$INFILEPDF" || initError "Input file is not a PDF file: $INFILEPDF" $EXIT_INPUT_NOT_PDF
isFile "$INFILEPDF" || initError "Input file not found: $INFILEPDF" $EXIT_FILE_NOT_FOUND
printVersion 1 'verbose'
if isEmpty "$2"; then
if isMixedMode; then
vprint " Mixed Tasks: Resize & Scale"
OUTFILEPDF="${INFILEPDF%.pdf}.$(uppercase $RESIZE_PAPER_TYPE).SCALED.pdf"
elif isResizeMode; then
vprint " Single Task: Resize PDF Paper"
OUTFILEPDF="${INFILEPDF%.pdf}.$(uppercase $RESIZE_PAPER_TYPE).pdf"
else
vprint " Single Task: Scale PDF Contents"
OUTFILEPDF="${INFILEPDF%.pdf}.SCALED.pdf"
fi
else
@@ -977,6 +977,13 @@ printVersion() {
fi
}

# Prints the scale factor to screen, or custom message
vPrintScaleFactor() {
local scaleMsg="$SCALE"
isNotEmpty "$1" && scaleMsg="$1"
vprint " Scale Factor: $scaleMsg"
}


# Prints help info
printHelp() {


Loading…
Cancel
Save