tavinus / pdfScale

Bash Script to Scale and Resize PDFs using Ghostscript
MIT License
242 stars 36 forks source link

Tested Systems Reporting #2

Open tavinus opened 7 years ago

tavinus commented 7 years ago

Tested Systems

Relevant commands

$ cat /etc/*release 2>/dev/null
$ uname -s -r -v -m -p -i -o
$ bc --version
$ gs --version
$ pdfinfo -v 2>dev/null || echo 'No pdf-info'
$ identify --version 2>/dev/null || echo 'No identify'

Template for reporting a system:

Just copy and paste this into your answer and then copy and paste each code block on its place.

# Enter Distro / System name here
#### release
```
$ cat /etc/*release 2>/dev/null
# contents...
```
#### uname
```
$ uname -s -r -v -m -p -i -o
# contents...
```
#### bcmath
```
$ bc --version
# contents...
```
#### ghostscript
```
$ gs --version
# contents...
```
#### pdfinfo
```
$ pdfinfo -v 2>/dev/null || echo 'NO PDFINFO'
# contents...
```
#### identify
```
$ identify --version 2>/dev/null || echo 'NO IDENTIFY'
# contents...
```
#### main use
**Use for resizing:** YES/NO - what papers?
**Use for scaling:** UP/DOWN - printing margins?
**Use for auto-rotation:** YES/NO - which option?
**Use flip-detection:** YES/NO, which option?
**Use adaptive-mode:** YES/NO (why on earth NO?)

Feel free to add/omit stuff, most important thing is to know the distro you are running

Examples below

tavinus commented 7 years ago

Windows 10 64 bits - CygWin64

release

$ cat /etc/*release 2>/dev/null
# cygwin has no such thing

uname

$ uname -s -r -v -m -p -i -o
CYGWIN_NT-10.0 2.6.0(0.304/5/3) 2016-08-31 14:32 x86_64 unknown unknown Cygwin

bcmath

bc --version
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.

ghostscript

$ gs --version
9.19

pdfinfo

$ pdfinfo -v 2>/dev/null || echo 'NO PDFINFO'
NO PDFINFO

identify

$ identify --version 2>/dev/null || echo 'NO IDENTIFY'
Version: ImageMagick 6.9.5-7 Q16 x86_64 2016-12-23 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC OpenMP

main use

Use for resizing: YES, A4 and other International STD papers Use for scaling: UP and DOWN, for printing margins and fitting Use auto-rotation: YES, usually PageByPage Use flip-detection: YES, usually auto Use adaptive-mode: YES, it is awesome!

PS: You know someone lost it when he talks to himself in github issues comments.

tavinus commented 7 years ago

Windows 10 64bit - Bash on Ubuntu on Windows

release

$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"
NAME="Ubuntu"
VERSION="14.04.5 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.5 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

uname

$ uname -s -r -v -m -p -i -o
Linux 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/Linux

bcmath

$ bc --version
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.

ghostscript

$ gs --version
9.10

pdfinfo

$ pdfinfo -v 2>/dev/null || echo 'NO PDFINFO'
pdfinfo version 0.24.5
Copyright 2005-2013 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011 Glyph & Cog, LLC

identify

$ identify --version 2>/dev/null || echo 'NO IDENTIFY'
Version: ImageMagick 6.7.7-10 2017-03-14 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

main use

Was just testing on this system, tested all functions.

Ghostscript complained about fonts and pdfScale showed an error, but the file was (NOT, sic) created successfully in all cases. EDIT: The error was actually on the PDF file and this execution failed to generate a valid PDF file. Seems like the native PDF generator from Microsoft is incompatible with ghostscript. When I tried on a valid PDF from another system, all went fine. If you get this error, you will probably need to fix/regenerate your PDF to use it with pdfScale.

Error run:

$ ./pdfScale.sh -v /mnt/c/Users/tavinus/Documents/pdfScale-linuxmagazin.pdf -r a1 -s 1.05
pdfScale.sh v2.1.2 - Verbose Execution
   Mixed Tasks: Resize & Scale
    Input File: /mnt/c/Users/tavinus/Documents/pdfScale-linuxmagazin.pdf
   Output File: /mnt/c/Users/tavinus/Documents/pdfScale-linuxmagazin.A1.SCALED.pdf
 Get Page Size: Adaptive Enabled
        Method: Grep
  Source Width: 612 postscript-points
 Source Height: 792 postscript-points
   Auto Rotate: PageByPage
   Flip Detect: No change needed
  Run Resizing: A1 ( 1684 x 2384 ) pts
     New Width: 1684 postscript-points
    New Height: 2384 postscript-points
  Scale Factor: 1.05
 Translation X: -40.094356
 Translation Y: -56.760656
   Run Scaling: 5 %
  Final Status: Error detected. Exit status: 0
PdfScale: ERROR!
Ghostscript Debug Info:
   **** Warning: can't process font stream, loading font by the name.
   **** Error reading a content stream. The page may be incomplete.
   **** File did not complete the page properly and may be damaged.

   **** This file had errors that were repaired or ignored.
   **** The file was produced by:
   **** >>>> Microsoft: Print To PDF <<<<
   **** Please notify the author of the software that produced this
   **** file that it does not conform to Adobe's published PDF
   **** specification.
jhnc commented 5 years ago

Ubuntu 18.04 LTS

release

$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

uname

$ uname -s -r -v -m -p -i -o
Linux 4.15.0-47-generic #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

bcmath

$ bc --version
bc 1.07.1
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.

ghostscript

$ gs --version
9.26

pdfinfo

$ pdfinfo -v
pdfinfo version 0.62.0
Copyright 2005-2017 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011 Glyph & Cog, LLC

identify

$ identify -version 2>/dev/null
GraphicsMagick 1.3.28 2018-01-20 Q16 http://www.GraphicsMagick.org/
Copyright (C) 2002-2018 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.

Feature Support:
  Native Thread Safe       yes
  Large Files (> 32 bit)   yes
  Large Memory (> 32 bit)  yes
  BZIP                     yes
  DPS                      no
  FlashPix                 no
  FreeType                 yes
  Ghostscript (Library)    no
  JBIG                     yes
  JPEG-2000                no
  JPEG                     yes
  Little CMS               yes
  Loadable Modules         no
  OpenMP                   yes (201511)
  PNG                      yes
  TIFF                     yes
  TRIO                     no
  UMEM                     no
  WebP                     yes
  WMF                      yes
  X11                      yes
  XML                      yes
  ZLIB                     yes

Host type: x86_64-pc-linux-gnu

Configured using the command:
  ./configure  '--build' 'x86_64-linux-gnu' '--enable-shared' '--enable-static' '--enable-libtool-verbose' '--prefix=/usr' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--docdir=${prefix}/share/doc/graphicsmagick' '--with-gs-font-dir=/usr/share/fonts/type1/gsfonts' '--with-x' '--x-includes=/usr/include/X11' '--x-libraries=/usr/lib/X11' '--without-dps' '--without-modules' '--without-frozenpaths' '--with-webp' '--with-perl' '--with-perl-options=INSTALLDIRS=vendor' '--enable-quantum-library-names' '--with-quantum-depth=16' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-Wall -g -fno-strict-aliasing -O2' 'LDFLAGS=' 'CXXFLAGS=-Wall -g -fno-strict-aliasing -O2'

Final Build Parameters:
  CC       = gcc
  CFLAGS   = -fopenmp -Wall -g -fno-strict-aliasing -O2 -Wall -pthread
  CPPFLAGS = -I/usr/include/X11 -I/usr/include/freetype2 -I/usr/include/libxml2
  CXX      = g++
  CXXFLAGS = -Wall -g -fno-strict-aliasing -O2 -pthread
  LDFLAGS  = -L/usr/lib/X11
  LIBS     = -ljbig -lwebp -lwebpmux -llcms2 -ltiff -lfreetype -ljpeg -lpng16 -lwmflite -lXext -lSM -lICE -lX11 -llzma -lbz2 -lxml2 -lz -lm -lgomp -lpthread

main use

Use for resizing: NO Use for scaling: UP - reducing whitespace margins Use for auto-rotation: NO Use flip-detection: NO Use adaptive-mode: YES

tavinus commented 5 years ago

Thanks for the report! 👍

Hopefully I will be able to implement the pending changes next month.
Then I will need to re-test it on all sorts of systems and files.
This version is pretty stable though. Been like this for a while.

Adaptive mode will become kind of obsolete then. I will probably keep all modes just in case someone wants to force a detection mode for performance sake (if transforming thousands/millions of files in a batch script). Also, can't hurt to keep it fail-safe.