[185] | 1 | #! /usr/bin/env python |
---|
| 2 | # -*- coding: ISO-8859-15 -*- |
---|
| 3 | # |
---|
| 4 | # pkpgcounter : a generic Page Description Language parser |
---|
| 5 | # |
---|
[303] | 6 | # (c) 2003, 2004, 2005, 2006 Jerome Alet <alet@librelogiciel.com> |
---|
[185] | 7 | # This program is free software; you can redistribute it and/or modify |
---|
| 8 | # it under the terms of the GNU General Public License as published by |
---|
| 9 | # the Free Software Foundation; either version 2 of the License, or |
---|
| 10 | # (at your option) any later version. |
---|
| 11 | # |
---|
| 12 | # This program is distributed in the hope that it will be useful, |
---|
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | # GNU General Public License for more details. |
---|
| 16 | # |
---|
| 17 | # You should have received a copy of the GNU General Public License |
---|
| 18 | # along with this program; if not, write to the Free Software |
---|
[222] | 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
[185] | 20 | # |
---|
| 21 | # $Id$ |
---|
| 22 | # |
---|
| 23 | # |
---|
| 24 | |
---|
[211] | 25 | import sys |
---|
[235] | 26 | from pkpgpdls.version import __version__, __author__, __authoremail__, \ |
---|
[223] | 27 | __years__, __gplblurb__ |
---|
[235] | 28 | from pkpgpdls import analyzer |
---|
[186] | 29 | |
---|
[223] | 30 | __doc__ = """pkpgcounter v%(__version__)s (c) %(__years__)s %(__author__)s |
---|
| 31 | |
---|
| 32 | pkpgcounter is a generic Page Description Language parser. |
---|
| 33 | |
---|
| 34 | pkpgcounter parses any number of input files and/or its standard input |
---|
| 35 | and outputs the number of pages needed to print these documents. |
---|
| 36 | |
---|
[369] | 37 | pkpgcounter can also compute the percent of ink coverage in different |
---|
| 38 | colorspaces for several file formats. |
---|
[223] | 39 | |
---|
[375] | 40 | pkpgcounter currently recognizes the following document formats : |
---|
[369] | 41 | |
---|
[223] | 42 | * PostScript (both DSC compliant and binary) |
---|
| 43 | * PDF |
---|
| 44 | * PCLXL (aka PCL6) |
---|
| 45 | * PCL3/4/5 (mostly) |
---|
| 46 | * DVI |
---|
| 47 | * TIFF |
---|
| 48 | * ESC/P2 |
---|
[346] | 49 | * OpenDocument (ISO/IEC DIS 26300) |
---|
[329] | 50 | * Zenographics ZjStream |
---|
[223] | 51 | |
---|
[375] | 52 | The three latter ones, as well as some TIFF documents, are currently |
---|
| 53 | only supported in page counting mode. |
---|
[369] | 54 | |
---|
[223] | 55 | command line usage : |
---|
| 56 | |
---|
| 57 | pkpgcounter [options] [files] |
---|
| 58 | |
---|
| 59 | options : |
---|
| 60 | |
---|
[369] | 61 | -v | --version Prints pkpgcounter's version number then exits. |
---|
| 62 | -h | --help Prints this message then exits. |
---|
[223] | 63 | |
---|
[369] | 64 | -d | --debug Activate debug mode. |
---|
[223] | 65 | |
---|
[369] | 66 | -cCOLORSPACE, --colorspace=COLORSPACE |
---|
| 67 | Activate the computation of ink usage, and defines the |
---|
| 68 | colorspace to use. Supported values are 'BW', 'RGB', |
---|
| 69 | 'CMYK', and 'CMY'. |
---|
| 70 | |
---|
| 71 | -rRESOLUTION, --resolution=RESOLUTION |
---|
| 72 | The resolution in DPI to use when checking ink usage. |
---|
| 73 | Lower resolution is faster but less accurate. Default |
---|
| 74 | is 72 dpi. |
---|
| 75 | |
---|
[223] | 76 | examples : |
---|
| 77 | |
---|
| 78 | $ pkpgcounter file1.ps file2.escp2 file3.pclxl <file4.pcl345 |
---|
| 79 | |
---|
| 80 | Will launch pkpgcounter and will output the total number of pages |
---|
| 81 | needed to print all the documents specified. |
---|
| 82 | |
---|
[369] | 83 | $ pkpgcounter --colorspace bw --resolution 150 file1.ps |
---|
| 84 | |
---|
| 85 | Will output the percent of black ink needed on each page of |
---|
[374] | 86 | the file1.ps file rendered at 150 dpi. |
---|
[369] | 87 | |
---|
[223] | 88 | %(__gplblurb__)s |
---|
| 89 | |
---|
| 90 | Please e-mail bugs to: %(__authoremail__)s""" |
---|
| 91 | |
---|
[199] | 92 | if __name__ == "__main__" : |
---|
[211] | 93 | if (len(sys.argv) >= 2) and (sys.argv[1] in ("-h", "--help")) : |
---|
[223] | 94 | print __doc__ % globals() |
---|
[211] | 95 | else : |
---|
| 96 | analyzer.main() |
---|