{ "info": { "author": "Allen Barker", "author_email": "Allen.L.Barker@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: End Users/Desktop", "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Utilities" ], "description": "\npdfCropMargins\n==============\n\nThe pdfCropMargins program is a command-line application to automatically crop\nthe margins of PDF files. Cropping the margins can make it easier to read the\npages of a PDF document -- whether the document is printed or displayed on a\nscreen -- because the display fonts are larger. This program is similar to the\nPerl script pdfcrop except with many more options.\n\nFeatures\n========\n\n- Automatically detects the margins and can crop a given percentage of them.\n- Can crop all the pages to the same size to give a uniform appearance (such as\n in two-up).\n- Works on Linux, Windows, Cygwin, and OS X/Darwin.\n- Has an optional graphical user interface (GUI) for interactive cropping.\n- Works with either the pdftoppm program or with Ghostscript.\n- A version of pdftoppm for Windows is included.\n- Renders and analyzes page images to find the bounding boxes, which allows it\n to deal with noisy scanned PDFs.\n- Ghostscript can optionally be used to find the bounding boxes directly.\n- Can automatically apply a Ghostscript repair operation to attempt to fix\n corrupt PDF files.\n- Crops rotated pages according to their appearance in the document viewer.\n- Can crop pages uniformly based on the nth smallest crop values, which helps\n with noisy images or documents where a few pages have unwanted markings in\n their margins.\n- Can uniformly crop even and odd pages separately.\n- Can automatically run a document previewer on the output file.\n- The format of automatically-generated output-file names is easily\n modifiable.\n- Preserves document catalog information such as outlines if possible.\n- Implements a rudimentary 'undo' capability by default. \n- Can deal with at least simple cases of password-encrypted files.\n- Works with Python 2 and Python 3.\n\nThis GIF shows the optional GUI, before and after cropping a document:\n\n.. image:: https://user-images.githubusercontent.com/1791335/63413846-9c9e3400-c3c8-11e9-90f5-6e429ae2d74b.gif\n :width: 350px\n :align: center\n :alt: [GIF of pdfCropMargins]\n\nRequirements\n============\n\nThis program depends on either the Ghostscript program or the pdftoppm program\nbeing installed (and locatable) on the system. For Window users a version of a\npdftoppm binary (xpdf 4.01.01) is packaged with the program and will be used as\na fallback if no other program can be found.\n \n* **pdftoppm**\n\n The pdftoppm program is standard in most Linux distributions and is easy to\n install in Cygwin. It is currently part of the Poppler PDF tools, so that\n package should be installed on Linux and Cygwin.\n\n In Windows pdftoppm is not as easy to install, but a collection of PDF tools\n `found here `_ includes pdftoppm.\n That version is bundled with the software and will be used as a fallback on\n Windows if neither Ghostscript nor the system pdftoppm program can be\n found.\n\n* **Ghostscript**\n\n Ghostscript is in the repos of most Linux distributions and is easy to\n install on Windows and in Cygwin.\n \n The Windows install page is `located here\n `_; the non-commercial GPL\n version on that page should work fine for most people. Add the directory of\n the executable ``gswin64c.exe`` (or the 32 bit version if you installed\n that) to your Windows system path so it is discoverable (and runnable from\n the command shell). On Window 10 the place to go is:: \n\n Start -> Control Panel -> System and security -> System -> Advanced system settings\n\n Now click \"Environment Variables\" and then double click on the user variable\n ``Path``. Click \"New\" and browse to the directory to add, something like\n ``C:\\Program Files\\gs\\gs9.27\\bin``. Restart your command shell for the\n change to be recognized.\n \nInstalling \n==========\n\nThe easiest way to install the pdfCropMargins program is by using pip.\n\nUbuntu/Mint\n-----------\n\nBe sure ``$HOME/.local/bin`` is in your system ``PATH`` if you are installing\nvia pip with the ``--user`` option. (To install system-wide without ``--user``\nthe ``pip3`` command below would also need to be run with ``sudo``.)\n\nHere is the plain install, without a GUI::\n\n sudo apt install python3-pip ghostscript poppler-utils\n pip3 install pdfCropMargins --user --upgrade\n\nThis is the install with the GUI::\n\n sudo apt install python3-pip ghostscript poppler-utils python3-setuptools python3-tk\n pip3 install pdfCropMargins[gui] --user --upgrade\n\nWindows\n-------\n\nAs noted above Ghostscript or pdftoppm should be installed or the program will\nfall back to a copy of pdftoppm that is bundled with it.\n\nThe ``pip`` program should be automatically installed along with Python. If\nyou cannot find the pip executable you can usually run it like this::\n\n python -m pip \n\nNote that on some Windows installs the executable for Python is ``py`` rather\nthan ``python``.\n\nTo install without the GUI use::\n\n pip install pdfCropMargins --upgrade\n\nTo install with the GUI use::\n\n pip install pdfCropMargins[gui] --upgrade\n\nIn order for the command ``pdf-crop-margins`` to be found, the ``bin``\ndirectory it is created in by the ``pip`` command must be on the Windows\n``Path``. The system-wide Python ``bin`` directory should already be there if\nyou checked the box to modify ``Path`` when you installed Python; otherwise it\nshould be added. (If you install with the ``--user`` option to pip then you\nneed to be sure that the *local* Python ``bin`` directory is in the Windows\n``Path``.)\n\nRunning from the source distribution\n------------------------------------\n\nThe pdfCropMargins program can also be run directly from its source code\ndirectory tree, provided the dependencies are installed. In that case the\nPyPDF2 package must also be installed and available in the Python distribution\nthat will be used to run pdfCropMargins. If Ghostscript is unavailable as a\nsystem command then the Pillow imaging package is also necessary in the Python\ndistribution. Pillow is also needed for certain advanced features which use\nexplicit image analysis, so it is a good idea to install it in Python.\nAssuming the dependencies are satisfied, run the program as\n``bin/pdfCropMargins.py``, where the path is relative to the top of the source\ndistribution. The GUI also has dependencies which can be seen in the\n`setup.py` file.\n\nRunning\n=======\n\nAfter installation via pip the program can be run with a command such as::\n\n pdf-crop-margins -v -s -u your-file.pdf\n\nFor help, run::\n\n pdf-crop-margins -h | more\n\nOn Windows you may need to explicitly put the Python distribution's ``Scripts``\ndirectory into your environment ``PATH`` in order to avoid having to use the\nfull pathname.\n\nTo diagnose unexpected crops, try running with the ``-v`` verbose argument. It\nwill tell you the page with the smallest crop amount for a margin. Running\nwithout the ``-u`` or ``-s`` options will crop each page separately, so you can\nsee which pages might be causing problems (such as pages with noise near the\nborders or margin text). To get cropped pages all the same size be sure to use\nboth ``-s`` to make pages the same size and ``-u`` to crop each page by the\nsame amount. Sometimes a small pre-crop is needed (``-ap`` or ``-ap4``) to get\npast small, unwanted markings near the edges of pages.\n\nDocumentation\n=============\n\n.. In vim use this to get output:\n :read !pdf-crop-margins -h\n\nTo see the documentation, run::\n\n pdf-crop-margins -h | more\n\nThe output of that command follows::\n\n Usage: pdf-crop-margins [-h] [-o OUTFILE_NAME] [-v] [-gui] [-p PCT]\n [-p4 PCT PCT PCT PCT] [-a BP] [-a4 BP BP BP BP]\n [-ap BP] [-ap4 BP BP BP BP] [-u] [-m INT]\n [-m4 INT INT INT INT] [-mp INT] [-s] [-ms INT] [-e]\n [-g PAGESTR] [-t BYTEVAL] [-nb INT] [-ns INT] [-gs]\n [-gsr] [-x DPI] [-y DPI] [-b [m|c|t|a|b]]\n [-f [m|c|t|a|b]] [-r] [-A] [-gsf] [-nc] [-pv PROG]\n [-mo] [-q] [-nco] [-pf] [-sc STR] [-su STR] [-ss STR]\n [-pw PASSWD] [-spr FLOAT:FLOAT]\n [-prw FLOAT FLOAT FLOAT FLOAT] [-dcb STR] [-dcw STR]\n [-i] [-pdl] [-gsp PATH] [-ppp PATH]\n PDF_FILE [PDF_FILE ...]\n \n Description:\n \n A command-line application to crop the margins of PDF files. Cropping\n the margins can make it easier to read the pages of a PDF document --\n whether the document is printed or displayed on a screen -- because the\n display fonts are larger. Margin-cropping is also sometimes useful when\n a PDF file is included in a document as a graphic.\n \n By default 10% of the existing margins will be retained; the rest will\n be eliminated. There are many options which can be set, however,\n including the percentage of existing margins to retain.\n \n Here is a simple example of cropping a file named document.pdf and\n writing the cropped output-document to a file named\n croppedDocument.pdf:\n \n pdf-crop-margins document.pdf -o croppedDocument.pdf\n \n If no destination is provided a filename will be automatically\n generated from the name of the source file (see below).\n \n The pdfCropMargins program works by changing the page sizes which are\n stored in the PDF file (and are interpreted by programs like Acrobat\n Reader). Both the CropBox and the MediaBox are set to the newly-\n computed cropped size. After this the view of the document in most\n programs will be the new, cropped view.\n \n When cropping a file not produced by the pdfCropMargins program the\n default is also to save the intersection of the MediaBox and any\n existing CropBox in the ArtBox. This saves the \"usual\" view of the\n original document in programs like Acrobat Reader. Subsequent crops of\n a file produced by pdfCropMargins do not by default alter the ArtBox.\n This allows for an approximate \"restore to original margin-sizes\"\n option ('--restore') which simply copies the saved values back to the\n MarginBox and CropBox. Note, though, that this assumes the ArtBox is\n unused (it is rarely used, and this feature can be turned off with the\n -A option).\n \n These defaults are designed to reduce the number of copies of a\n document which need to be saved. This is especially useful if\n annotations, highlighting, etc., are added to the document. If a\n document is cropped twice with this program it still stores the\n original margin settings. At least an approximate version of the\n original document's margin-formatting can be recovered by using the '--\n restore' option. Programs which change the \"Producer\" string in the PDF\n may interfere with this feature.\n \n Below are several examples using more of the command-line options, each\n applied to an input file called doc.pdf. The output filename is\n unspecified in these examples, so the program will automatically\n generate the filename (or an output filename can always be explicitly\n provided):\n \n Crop doc.pdf so that all the pages are set to the same size and the\n cropping amount is uniform across all the pages (this gives a nice two-up\n appearance). The default of retaining 10% of the existing margins is\n used. Note carefully that '-u' only makes the amount to be cropped uniform\n for each page; if the pages do not have the same size to begin with they\n will not have the same size afterward unless the '-s' option is also used.\n \n pdf-crop-margins -u -s doc.pdf\n \n Crop each page of doc.pdf individually (i.e., not uniformly), keeping 50%\n of the existing margins.\n \n pdf-crop-margins -p 50 doc.pdf\n \n Crop doc.pdf uniformly, keeping 50% of the left margin, 20% of the bottom\n margin, 40% of the right margin, and 10% of the top margin.\n \n pdf-crop-margins -u -p4 50 20 40 10 doc.pdf\n \n Crop doc.pdf retaining 20% of the margins, and then reduce the right page\n margins only by an absolute 12 points.\n \n pdf-crop-margins -p 20 -a4 0 0 12 0 doc.pdf\n \n Pre-crop the document by 5 points on each side before computing the\n bounding boxes. Then crop retaining 50% of the computed margins. This\n can be useful for difficult documents such as scanned books with page-edge\n noise or other \"features\" inside the current margins.\n \n pdf-crop-margins -ap 5 -p 50 doc.pdf\n \n Crop doc.pdf, re-naming the cropped output file doc.pdf and backing\n up the original file in a file named backup_doc.pdf.\n \n pdf-crop-margins -mo -pf -su \"backup\" doc.pdf\n \n Crop the margins of doc.pdf to 120% of their original size, increasing the\n margins. Use Ghostscript to find the bounding boxes (in general this is\n often faster if Ghostscript is available and no rendering operations are\n needed).\n \n pdf-crop-margins -p 120 -gs doc.pdf\n \n Crop the margins of doc.pdf ignoring the 10 largest margins on each edge\n (over the whole document). This is especially good for noisy documents\n where all the pages have very similar margins, or when you want to ignore\n marginal annotations which only occur on a few pages.\n \n pdf-crop-margins -m 10 doc.pdf\n \n Crop doc.pdf, launch the acroread viewer on the cropped output, and then\n query as to whether or not to rename the cropped file doc.pdf and back up\n the original file as doc_uncropped.pdf.\n \n pdf-crop-margins -mo -q doc.pdf\n \n Crop pages 1-100 of doc.pdf, cropping all even pages uniformly and all odd\n pages uniformly.\n \n pdf-crop-margins -g 1-100 -e doc.pdf\n \n Try to restore doc.pdf to its original margins, assuming it was cropped\n with pdfCropMargins previously. Note that the default output filename is\n still named doc_cropped.pdf, even though it is the recovered file.\n \n pdf-crop-margins -r doc.pdf\n \n There are many different ways to use this program. After finding a\n method which works well for a particular task or workflow pattern it is\n often convenient to make a simple shell script (batch file) which\n invokes the program with those particular options and settings. Simple\n template scripts for Bash and Windows are packaged with the program, in\n the bin directory.\n \n When printing a document with closely-cropped pages it may be necessary\n to use options such as \"Fit to Printable Area\". It may also be\n necessary to fine-tune the size of the retained margins if the edges of\n the text are being cut off.\n \n Sometimes a PDF file is corrupted or non-standard to the point where\n the routines used by this program raise an error and exit. In that case\n it can sometimes help to repair the PDF file before attempting to crop\n it. If it is readable by Ghostscript then the following command will\n often repair it sufficiently:\n \n gs -o repaired.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress corrupted.pdf\n \n This command can also be used to convert some PostScript (.ps) files to\n PDF. In Windows the executable would be something like \"gswin32c.exe\"\n rather than \"gs\". The option '--gsFix' (or '-gsf') will automatically\n attempt to apply this fix, provided Ghostscript is available. See the\n description of that option for more information.\n \n The pdfCropMargins program handles rotated pages (such as pages in\n landscape mode versus portrait mode) as follows. All rotated pages are\n un-rotated as soon as they are read in. All the cropping is then\n calculated. Finally, as the crops are applied to the pages, the\n rotation is re-applied. This may give unexpected results in documents\n which mix pages at different rotations, especially with the '--uniform'\n or '--samePageSize' options. The arguments of all the options which\n take four arguments, one for each margin, are shifted so the left,\n bottom, right, and top margins correspond to the screen appearance\n (regardless of any internal rotation).\n \n All the command-line options to pdfCropMargins are described below. The\n following definition is useful in precisely defining what several of\n the options do. Let the delta values be the absolute reduction lengths,\n in points, which are applied to each original page to get the final\n cropped page. There is a delta value for each margin, on each page. In\n the usual case where all the margin sizes decrease, all the deltas are\n positive. A delta value can, however, be negative (when percentRetain >\n 100 or when a negative absolute offset is used). When a delta value is\n negative the corresponding margin size will increase.\n \n \n Positional arguments:\n \n PDF_FILE The pathname of the PDF file to crop. Use quotes\n around any file or directory name which contains a\n space. If no filename is given for the cropped PDF\n output file via the '-o' flag then a default output\n filename will be generated. By default it is the same\n as the source filename except that the suffix \".pdf\"\n is replaced by \"_cropped.pdf\", overwriting by default\n if the file already exists. The file will be written\n to the working directory at the time when the program\n was run. If the input file has no extension or has an\n extension other than '.pdf' or '.PDF' then the suffix\n '.pdf' will be appended to the existing (possibly-\n null) extension. Globbing of wildcards is performed on\n Windows systems.\n \n \n Optional arguments:\n \n -h, --help Show this help message and exit.\n \n -o OUTFILE_NAME, --outfile OUTFILE_NAME\n An optional argument specifying the pathname of a file\n that the cropped output document should be written to.\n By default any existing file with the same name will\n be silently overwritten. If this option is not given\n the program will generate an output filename from the\n input filename. (By default \"_cropped\" is appended to\n the input filename before the file extension. If the\n extension is not '.pdf' or '.PDF' then '.pdf' is\n appended to the extension). Globbing of wildcards is\n performed on Windows systems.\n \n -v, --verbose Print more information about the program's actions and\n progress. Without this switch only warning and error\n messages are printed to the screen.\n \n -gui, --gui Run the graphical user interface. This mode allows you\n to interactively preview and test different cropping\n options without having to recalculate the bounding\n boxes each time (which can be slow). All the usual\n command-line options to the program are still\n respected.\n \n -p PCT, --percentRetain PCT\n Set the percent of margin space to retain in the\n image. This is a percentage of the original margin\n space. By default the percent value is set to 10.\n Setting the percentage to 0 gives a tight bounding\n box. Percent values greater than 100 increase the\n margin sizes from their original sizes, and negative\n values decrease the margins even more than a tight\n bounding box.\n \n -p4 PCT PCT PCT PCT, -pppp PCT PCT PCT PCT, --percentRetain4 PCT PCT PCT PCT\n Set the percent of margin space to retain in the\n image, individually for the left, bottom, right, and\n top margins, respectively. The four arguments should\n be percent values.\n \n -a BP, --absoluteOffset BP\n Decrease each margin size by an absolute floating\n point offset value, to be subtracted from each\n margin's size after the 'percentRetain' option is\n applied. The units are big points, bp, which is the\n unit used in PDF files. There are 72 bp in an inch. A\n single bp is approximately equal to a TeX point, pt\n (with 72.27pt in an inch). Negative values are\n allowed; positive numbers always decrease the margin\n size and negative numbers always increase it. Absolute\n offsets are always applied after any percentage change\n operations.\n \n -a4 BP BP BP BP, -aaaa BP BP BP BP, --absoluteOffset4 BP BP BP BP\n Decrease the margin sizes individually with four\n absolute offset values. The four floating point\n arguments should be the left, bottom, right, and top\n offset values, respectively. See the '--\n absoluteOffset' option for information on the\n units.\n \n -ap BP, --absolutePreCrop BP\n This option is like '--absoluteOffset' except that it\n is applied before any bounding box calculations (or\n any other operations). The argument is the same, in\n units of bp. All successive operations are then\n relative to this pre-crop box, considered to be the\n full-page box. Note that since this absolute crop is\n applied before any bounding boxes are computed it is\n relative to the original full-page boxes of the\n document (unlike 'absoluteOffset', which is a crop\n relative to the newly-cropped margin after\n 'percentRetain' is applied). As a consequence, the\n number of points may need to be larger than what would\n work for 'absoluteOffset'. This option can be used to\n ignore text and markings out at the edge of the\n margins by cropping it out before the bounding boxes\n are calculated.\n \n -ap4 BP BP BP BP, --absolutePreCrop4 BP BP BP BP\n This is the same as '--absolutePreCrop' except that\n four separate arguments can be given. The four\n floating point arguments should be the left, bottom,\n right, and top absolute pre-crop values,\n respectively.\n \n -u, --uniform Crop all the pages uniformly. This forces the\n magnitude of margin-cropping (absolute, not relative)\n to be the same on each page. This option is applied\n after all the delta values have been calculated for\n each page, individually. Then all the left-margin\n delta values, for each page, are set to the smallest\n left-margin delta value over every page. The bottom,\n right, and top margins are processed similarly. Note\n that this effectively adds some margin space (relative\n to the margins obtained by cropping pages\n individually) to some of the pages. If the pages of\n the original document are all the same size then the\n cropped pages will again all be the same size. The '--\n samePageSize' option can be used in combination with\n this option to force all pages to be the same size\n after cropping.\n \n -m INT, --uniformOrderStat INT\n Choosing this option implies the '--uniform' option,\n but the smallest delta value over all the pages is no\n longer chosen. Instead, for each margin the nth\n smallest delta value (with n numbered starting at\n zero) is chosen over all the pages. The argument is\n the integer n, for example '-m 4'. Choosing n to be\n half the number of pages gives the median delta value.\n This option is useful for cropping noisy scanned PDFs\n which have a common margin size on most of the pages,\n or for ignoring annotations which only appear in the\n margins of a few pages. This option essentially causes\n the program to ignores the n largest tight-crop\n margins when computing common delta values over all\n the pages. Increasing n always either increases the\n cropping amount or leaves it unchanged. Some trial-\n and-error may be needed to choose the best number.\n Using '-m 1' tends to work well with arXiv papers\n (which have a date in the margin of the first\n page).\n \n -m4 INT INT INT INT, -mmmm INT INT INT INT, --uniformOrderStat4 INT INT INT INT\n This option is the same as '--uniformOrderStat' (or\n '-m') except that separate values are specified for\n each margin individually. The margins are ordered as\n left, bottom, right, and top.\n \n -mp INT, --uniformOrderPercent INT\n This option is the same as '--uniformOrderStat' except\n that the order number n is automatically set to a\n given percentage of the number of pages which are set\n to be cropped (either the full number or the ones set\n with '--pages'). This option overrides '--\n uniformOrderStat' if both are set. The argument is a\n float percent value; rounding is done to get the final\n order-number. Setting the percent to 0 is equivalent\n to n=1, setting the percent to 100 is equivalent to\n setting n to the full number of pages, and setting the\n percent to 50 gives the median (for odd numbers of\n pages).\n \n -s, --samePageSize Set all the page sizes to be equal. This option only\n has an effect when the page sizes are different. The\n pages sizes are set to the size of the union of all\n the page regions, i.e., to the smallest bounding box\n which contains all the pages. This operation is always\n done before any others (except '--absolutePreCrop').\n The cropping is then done as usual, but note that any\n margin percentages (such as for '--percentRetain') are\n now relative to this new, possibly larger, page size.\n The resulting pages are still cropped independently by\n default, and will not necessarily all have the same\n size unless '--uniform' is also selected to force the\n cropping amounts to be the same for each page. If\n pages are selected with '--pages' then this option is\n only applied to those selected pages.\n \n -ms INT, --samePageSizeOrderStat INT\n Choosing this option implies the '--samePageSize'\n option, but the calculations for each edge of the\n smallest bounding box ignore the largest (or smallest\n for left and bottom edges) n values. The argument is\n the nonnegative number n. Each edge is calculated\n independently. This is an order statistic for\n selecting the uniform size to make the pages. Note\n that this will cut off parts of some pages if n>0.\n \n -e, --evenodd Crop all the odd pages uniformly, and all the even\n pages uniformly. The largest amount of cropping that\n works for all the pages in each group is chosen. If\n the '--uniform' ('-u') option is simultaneously set\n then the vertical cropping will be uniform over all\n the pages and only the horizontal cropping will differ\n between even and odd pages.\n \n -g PAGESTR, -pg PAGESTR, --pages PAGESTR\n Apply the cropping operation only to the selected\n pages. The argument should be a list of the usual form\n such as \"2-4,5,9,20-30\". The page-numbering is assumed\n to start at 1. Ordering in the argument list is\n unimportant, negative ranges are ignored, and pages\n falling outside the document are ignored. Note that\n restore information is always saved for all the pages\n (in the ArtBox) unless '--noundosave' is selected.\n \n -t BYTEVAL, --threshold BYTEVAL\n Set the threshold for determining what is background\n space (white). The value can be from 0 to 255, with\n 191 the default (75 percent). This option may not be\n available for some configurations since the PDF must\n be internally rendered as an image of pixels. In\n particular, it is ignored when '--gsBbox' is selected.\n Any pixel value over the threshold is considered to be\n background (white), and any value below it is\n considered to be text (black). Lowering the value\n should tend to make the bounding boxes smaller. The\n threshold may need to be lowered, for example, for\n scanned images with greyish backgrounds.\n \n -nb INT, --numBlurs INT\n When PDF files are explicitly rendered to image files,\n apply a blur operation to the resulting images this\n many times. This can be useful for noisy images.\n \n -ns INT, --numSmooths INT\n When PDF files are explicitly rendered to image files,\n apply a smoothing operation to the resulting images\n this many times. This can be useful for noisy\n images.\n \n -gs, --gsBbox Use Ghostscript to find the bounding boxes for the\n pages. The alternative is to explicitly render the PDF\n pages to image files and calculate bounding boxes from\n the images. This method tends to be much faster, but\n it does not work with scanned PDF documents. It also\n does not allow for choosing the threshold value,\n applying blurs, etc. Any resolution options are passed\n to the Ghostscript bbox device. This option requires\n that Ghostscript be available in the PATH as\n \"gswin32c.exe\" or \"gswin64c.exe\" on Windows, or as\n \"gs\" on Linux. When this option is set the PIL image\n library for Python is not required.\n \n -gsr, --gsRender Use Ghostscript to render the PDF pages to images. By\n default the pdftoppm program will be preferred for the\n rendering, if it is found. Note that this option has\n no effect if '--gsBbox' is chosen, since then no\n explicit rendering is done.\n \n -x DPI, --resX DPI The x-resolution in dots per inch to use when the\n image is rendered to find the bounding boxes. The\n default is 150. Higher values produce more precise\n bounding boxes.\n \n -y DPI, --resY DPI The y-resolution in dots per inch to use when the\n image is rendered to find the bounding boxes. The\n default is 150. Higher values produce more precise\n bounding boxes.\n \n -b [m|c|t|a|b], --boxesToSet [m|c|t|a|b]\n By default the pdfCropMargins program sets both the\n MediaBox and the CropBox for each page of the cropped\n PDF document to the new, cropped page size. This\n default setting is usually sufficient, but this option\n can be used to select different PDF boxes to set. The\n option takes one argument, which is the first letter\n (lowercase) of a type of box. The choices are MediaBox\n (m), CropBox (c), TrimBox (t), ArtBox (a), and\n BleedBox (b). This option overrides the default and\n can be repeated multiple times to set several box\n types.\n \n -f [m|c|t|a|b], --fullPageBox [m|c|t|a|b]\n By default the program first (before any cropping is\n calculated) sets the MediaBox and CropBox of each page\n in (a copy of) the document to the intersection of its\n previous MediaBox and CropBox. This ensures that the\n cropping is relative to the usual document-view in\n programs like Acrobat Reader. This essentially defines\n what is assumed to be the full size of pages in the\n document, and all cropping is then performed relative\n to that full-page size. This option can be used to\n alternately use the MediaBox, the CropBox, the\n TrimBox, the ArtBox, or the BleedBox in defining the\n full-page size. The option takes one argument, which\n is the first letter (lowercase) of the type of box to\n use. If the option is repeated then the intersection\n of all the box arguments is used. Only one choice is\n allowed in combination with the '-gs' option since\n Ghostscript does its own internal rendering when\n finding bounding boxes. The default with '-gs' is the\n CropBox.\n \n -r, --restore This is a simple undo operation which essentially\n undoes all the crops ever made by pdfCropMargins and\n returns to the original margins (provided no other\n program modified the Producer metadata or ArtBoxes).\n By default, whenever this program crops a file for the\n first time it saves the MediaBox intersected with the\n CropBox as the new ArtBox (since the ArtBox is rarely\n used). The Producer metadata is checked to see if this\n was the first time. If so, the ArtBox for each page is\n simply copied to the MediaBox and the CropBox for the\n page. This restores the earlier view of the document,\n such as in Acrobat Reader (but does not completely\n restore the previous condition in cases where the\n MediaBox and CropBox differed or the ArtBox had a\n previous value). Any options such as '-u', '-p', and\n '-a' which do not make sense in a restore operation\n are ignored. Note that as far as default filenames the\n operation is treated as just another crop operation\n (the default-generated output filename still has a\n \"_cropped.pdf\" suffix). The '--modifyOriginal' option\n (or its query variant) can be used with this option.\n Saving in the ArtBoxes can be disabled by using the '\n --noundosave' option.\n \n -A, --noundosave Do not save any restore data in the ArtBox. This\n option will need to be selected if the document\n actually uses the ArtBox for anything important (which\n is rare). Note that the '--restore' operation will not\n work correctly for the cropped document if this option\n is included in the cropping command. (The program does\n not currently check for this when doing a restore.)\n \n -gsf, --gsFix Attempt to repair the input PDF file with Ghostscript\n before it is read-in with PyPdf. This requires that\n Ghostscript be available. (See the general description\n text above for the actual command that is run.) This\n can also be used to automatically convert some\n PostScript files (.ps) to PDF for cropping. The\n repaired PDF is written to a temporary file; the\n original PDF file is not modified. The original\n filename is treated as usual as far as automatic name-\n generation, the '--modify-original' option, and so\n forth. This option is often helpful if the program\n hangs or raises an error due to a corrupted PDF file.\n Note that when re-cropping a file already cropped by\n pdfCropMargins this option is probably not be\n necessary, and if it is used in a re-crop (at least\n with current versions of Ghostscript) it will reset\n the Producer metadata which the pdfCropMargins program\n uses to tell if the file was already cropped by the\n program (the '--restore' option will then restore to\n the previous cropping, not the original cropping). So\n this option is not recommended as something to use by\n default unless you encounter many corrupted PDF files\n and do not need to restore back to the original\n margins.\n \n -nc, --noclobber Never overwrite an existing file as the output\n file.\n \n -pv PROG, --preview PROG\n Run a PDF viewer on the cropped PDF output. The viewer\n process is run in the background. The viewer is\n launched after pdfCropMargins has finished all the\n other. The only exception is when the '--\n queryModifyOriginal' option is also selected. In that\n case the viewer is launched before the query so that\n the user can look at the output before deciding\n whether or not to modify the original. (Note that\n answering 'y' will then move the file out from under\n the running viewer; close and re-open the file before\n adding annotations, highlighting, etc.) The single\n argument should be the path of the executable file or\n script to run the chosen viewer. The viewer is assumed\n to take exactly one argument, a PDF filename. For\n example, on Linux the Acrobat Reader could be chosen\n with /usr/bin/acroread or, if it is in the PATH,\n simply acroread. A shell script or batch file wrapper\n can be used to set any additional options for the\n viewer.\n \n -mo, --modifyOriginal\n This option moves (renames) the original file to a\n backup filename and then moves the cropped file to the\n original filename. Thus it effectively modifies the\n original file and makes a backup copy of the original,\n unmodified file. The backup filename for the original\n document is always generated from the original\n filename; any prefix or suffix which would be added by\n the program to generate a filename (by default a\n \"_cropped\" suffix) is modified accordingly (by default\n to \"_uncropped\"). The '--usePrefix', '--\n stringUncropped', and '--stringSeparator' options can\n all be used to customize the generated backup\n filename. This operation is performed last, so if a\n previous operation fails the original document will be\n unchanged. Be warned that running pdfCropMargins twice\n on the same source filename will modify the original\n file; the '-noclobberOriginal' option can be used to\n avoid this.\n \n -q, --queryModifyOriginal\n This option selects the '--modifyOriginal' option, but\n queries the user about whether to actually do the\n final move operation. This works well with the '--\n preview' option: if the preview looks good you can opt\n to modify the original file (keeping a copy of the\n original). If you decline then the files are not\n swapped (and are just as if the '--modifyOriginal'\n option had not been set).\n \n -nco, --noclobberOriginal\n If the '--modifyOriginal' option is selected, do not\n ever overwrite an existing file as the backup copy for\n the original file. This essentially does the move\n operations for the '--modifyOriginal' option in\n noclobber mode, and prints a warning if it fails. On\n failure the result is exactly as if the '--\n modifyOriginal' option had not been selected. This\n option is redundant if the ordinary '--noclobber'\n option is also set.\n \n -pf, --usePrefix Prepend a prefix-string when generating default file\n names rather than appending a suffix-string. The same\n string value is used, either the default or the one\n set via the '--stringCropped' or '--stringUncropped'\n option. With the default values for the other options\n and no output file specified, this option causes the\n cropped output for the input file \"document.pdf\" to be\n written to the file named \"cropped_document.pdf\"\n (instead of to the default filename\n \"document_cropped.pdf\").\n \n -sc STR, --stringCropped STR\n This option can be used to set the string which will\n be appended (or prepended) to the document filename\n when automatically generating the output filename for\n a cropped file. The default value is \"cropped\".\n \n -su STR, --stringUncropped STR\n This option can be used to set the string which will\n be appended (or prepended) to the document filename\n when automatically generating the output filename for\n the original, uncropped file. The default value is\n \"uncropped\".\n \n -ss STR, --stringSeparator STR\n This option can be used to set the separator string\n which will be used when appending or prependeding\n string values to automatically generate filenames. The\n default value is \"_\".\n \n -pw PASSWD, --password PASSWD\n Specify a password to be used to decrypt an encrypted\n PDF file. Note that decrypting with an empty password\n is always tried, so this option is only needed for\n non-empty passwords. The resulting cropped file will\n not be encrypted, so use caution if important data is\n involved.\n \n -spr FLOAT:FLOAT, --setPageRatios FLOAT:FLOAT\n Force all the cropped page ratios to equal the set\n ratio. All crops are calculated and applied as usual,\n but either the left and right margins will be\n increased equally or else the top and bottom margins\n will be increased equally in order to make the ratio\n of width to height equal the set value. Margins are\n only ever increased. The format for the ratio is\n either a string width-to-height ratio such as '4.5:3'\n or else a floating point number like '0.75' which is\n the width divided by the height. This option can be\n useful in some PDF viewers.\n \n -prw FLOAT FLOAT FLOAT FLOAT, --pageRatioWeights FLOAT FLOAT FLOAT FLOAT\n This option weights any whitespace added by the '--\n setPageRatios' argument. It takes four weight\n arguments, one per margin. The four floating point\n arguments should be the left, bottom, right, and top\n weights, respectively. The weights determine what\n proportion of the total height(width) increase\n necessary to achieve the target page ratio is added to\n the corresponding margin. All weights must be greater\n than zero.\n \n -dcb STR, --docCatBlacklist STR\n Data associated with the full document, such as\n outlines, bookmarks, and modes, is saved in the\n document catalog of the PDF file. By default it is all\n copied over to the cropped document if possible (with\n some exceptions, e.g., \"/Pages\" will be modified by\n cropping). If this is not wanted, or if it causes\n problems for a document, this option specifies a\n blacklist of document catalog items that will never be\n copied. The arguments should be passed as a single,\n quoted, whitespace-separated string, for example\n \"/Outlines /PageMode /OpenAction\". The special value\n \"ALL\" blacklists everything. An empty string\n blacklists nothing, and is the default. As an example,\n it can be useful to blacklist \"/OpenAction\" if on\n opening the PDF it does something like zooming which\n is not desired. Blacklisting `/PageMode` can also be\n useful to, for example, not open the outline by\n default. Running in verbose mode '-v' will show which\n document catalog items are and are not being copied\n for a document.\n \n -dcw STR, --docCatWhitelist STR\n See the '--docCatBlacklist' option. This is just a\n whitelist that essentially works the same way. The\n whitelist takes precedence over the blacklist. It\n specifies a list of items which will always be copied\n over even if they are in the blacklist. Useful\n combined with setting the blacklist to \"ALL\" if you\n only want one or two of the items. The default value\n is the empty string, which whitelists nothing and so\n only the blacklist is used. Setting to \"ALL\"\n guarantees that everything possible is copied over.\n \n -i, --showImages When explicitly rendering PDF files to image files,\n display the inverse image files that are used to find\n the bounding boxes. Useful for debugging and for\n choosing some of the other parameters (such as the\n threshold). This option requires a default external\n viewer program selected by the Pillow image\n manipulation package (xv on Unix, and usually Paint on\n Windows).\n \n -pdl, --pdftoppmLocal\n Use a locally-packaged pdftoppm executable rather than\n the system version. This option is only available on\n Windows machines; it is ignored otherwise. By default\n the first pdftoppm executable found in the directories\n in the PATH environment variable is used. On Windows\n the program will revert to this option if PDF image-\n rendering is required and no system pdftoppm or\n Ghostscript executable can be found. The locally-\n packaged pdftoppm executable is a few years old, but\n for page-cropping it only needs to get the margins\n right.\n \n -gsp PATH, --ghostscriptPath PATH\n Pass in a pathname to the ghostscript executable that\n the program should use. No globbing is done. Useful\n when the program is in a nonstandard location.\n \n -ppp PATH, --pdftoppmPath PATH\n Pass in a pathname to the pdftoppm executable that the\n program should use. No globbing is done. Useful when\n the program is in a nonstandard location.\n \n \n The pdfCropMargins program is Copyright (c) 2014 by Allen Barker.\n Released under the GNU GPL license, version 3 or later.\n \n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/abarker/pdfCropMargins", "keywords": "pdf", "license": "GPL", "maintainer": "", "maintainer_email": "", "name": "pdfCropMargins", "package_url": "https://pypi.org/project/pdfCropMargins/", "platform": "", "project_url": "https://pypi.org/project/pdfCropMargins/", "project_urls": { "Homepage": "https://github.com/abarker/pdfCropMargins" }, "release_url": "https://pypi.org/project/pdfCropMargins/0.2.6/", "requires_dist": null, "requires_python": "", "summary": "A command-line program to crop the margins of PDF files, with many options.", "version": "0.2.6" }, "last_serial": 5801667, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "3049ff46d8ea8a416c7dbcad41f802a9", "sha256": "af04d578f40a70d18777576023e3943cefc62e7cc92fc2db9e6e204ddff089f5" }, "downloads": -1, "filename": "pdfCropMargins-0.1.0.tar.gz", "has_sig": false, "md5_digest": "3049ff46d8ea8a416c7dbcad41f802a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1608048, "upload_time": "2017-02-27T23:25:15", "url": "https://files.pythonhosted.org/packages/7d/18/fa402d4173830349304a11845fb05dfdd94d9109ae0943ee97fd1e5dfa56/pdfCropMargins-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "4b984518c5b787cb34332dd9f7d409c1", "sha256": "c19aad492a2e9c80464dfcc2264b083a0fd86b62cdecb08829a17ea9a4ec8c09" }, "downloads": -1, "filename": "pdfCropMargins-0.1.1.tar.gz", "has_sig": false, "md5_digest": "4b984518c5b787cb34332dd9f7d409c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1607709, "upload_time": "2017-02-27T23:57:23", "url": "https://files.pythonhosted.org/packages/ca/11/0088e2d4e0bdd141b2887b73b1e9e386569ce5246c043a9254abae445934/pdfCropMargins-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "67870246bb1b36c49514ceef43cda033", "sha256": "75a290e945799477607a7cded7a85770641f957e44fc7929ab94a7f053b70fb3" }, "downloads": -1, "filename": "pdfCropMargins-0.1.2.tar.gz", "has_sig": false, "md5_digest": "67870246bb1b36c49514ceef43cda033", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1609114, "upload_time": "2017-03-14T22:38:00", "url": "https://files.pythonhosted.org/packages/95/14/cf56925c83628775bf850ac318024c66f98a80f63fc67e6ecee74bbff0fb/pdfCropMargins-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "4d1680e557bcce43112812fc553ff864", "sha256": "7dae0eebb85b5a1a0ec8f04a281b3c0b3c0b5b12f95abf671d2effeaa532bcf2" }, "downloads": -1, "filename": "pdfCropMargins-0.1.3.tar.gz", "has_sig": false, "md5_digest": "4d1680e557bcce43112812fc553ff864", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1616165, "upload_time": "2017-04-09T16:24:08", "url": "https://files.pythonhosted.org/packages/9c/58/fe2ea9d7a5f6822aa66c475c13f54a09249066ab49a54b6f3f9b11cb408c/pdfCropMargins-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "1e21af81456381c87e82a54ee83ab7de", "sha256": "91649dd9b07e376205964d6fbef599df868b55481f6a20676095f1bff9eea464" }, "downloads": -1, "filename": "pdfCropMargins-0.1.4.tar.gz", "has_sig": false, "md5_digest": "1e21af81456381c87e82a54ee83ab7de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1615801, "upload_time": "2019-02-08T01:59:50", "url": "https://files.pythonhosted.org/packages/1c/52/136bf2a46189584dde91c598e5d3a1d5ad4bb1e70cc9a58be4b36b450e4e/pdfCropMargins-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "210bd60184218f3c8a10664b90f4c2c6", "sha256": "b3270b416af85ba73a8db935416d7a7c8a79f20748b39ef88da81747cdeb01a7" }, "downloads": -1, "filename": "pdfCropMargins-0.1.5.tar.gz", "has_sig": false, "md5_digest": "210bd60184218f3c8a10664b90f4c2c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1632109, "upload_time": "2019-08-20T01:48:40", "url": "https://files.pythonhosted.org/packages/a8/5c/ec63ca92f142447c41d5ff98f45ab8b1f01fa54cece68f6286a131e8b54a/pdfCropMargins-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "8cbe539dc11b8d30ef1b43ace657c934", "sha256": "8b1ade412ab815249d297516eb40ff10f1b2568b74e87f7269961d7d7bb177b3" }, "downloads": -1, "filename": "pdfCropMargins-0.1.6.tar.gz", "has_sig": false, "md5_digest": "8cbe539dc11b8d30ef1b43ace657c934", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1632172, "upload_time": "2019-08-20T02:53:37", "url": "https://files.pythonhosted.org/packages/fb/65/3d0538fbcb7411e444449e110cca3154c67942080e7d43e65dabe231aadf/pdfCropMargins-0.1.6.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "e3f7330e5f3f6d9063c77bb9b8b461a3", "sha256": "9206032cd21376e726bc003bf250c85135ab68a586f50e77ed354ae82486556a" }, "downloads": -1, "filename": "pdfCropMargins-0.2.0.tar.gz", "has_sig": false, "md5_digest": "e3f7330e5f3f6d9063c77bb9b8b461a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1632266, "upload_time": "2019-08-20T09:33:06", "url": "https://files.pythonhosted.org/packages/0a/9d/e029f809515c981ecd252acb558757c3e5ad19cf006a9b67364d644f82df/pdfCropMargins-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "9e985023941ff99a6ec56f26b388fe67", "sha256": "a1552c76e8620c89f4e1d7828d022d96422a9d27e05bcbd6674ca6acc88a1a0f" }, "downloads": -1, "filename": "pdfCropMargins-0.2.1.tar.gz", "has_sig": false, "md5_digest": "9e985023941ff99a6ec56f26b388fe67", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1632952, "upload_time": "2019-08-21T08:28:31", "url": "https://files.pythonhosted.org/packages/dc/ce/29f3a7b00867473b3830f53eee7b157f524fac7c34e5104dca8225f796ff/pdfCropMargins-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "06012aca2943727535fd0b65d85b0e36", "sha256": "e1cf8f09da71599167a2d1982a7b11d2e1f6827079b4b3fa46c7ae1805e2c825" }, "downloads": -1, "filename": "pdfCropMargins-0.2.2.tar.gz", "has_sig": false, "md5_digest": "06012aca2943727535fd0b65d85b0e36", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1632945, "upload_time": "2019-08-21T09:05:35", "url": "https://files.pythonhosted.org/packages/9c/d3/fca96c6f566d908ffe1793c4b7c55aa4daff7a753115117dceb703afb65d/pdfCropMargins-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "f9591bbbf7cfefddafb46268c329670e", "sha256": "44373f8fd0ae96c999dd831e86edd9be149cfeb594d92b1acd9849e2e2842a95" }, "downloads": -1, "filename": "pdfCropMargins-0.2.3.tar.gz", "has_sig": false, "md5_digest": "f9591bbbf7cfefddafb46268c329670e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1633218, "upload_time": "2019-09-09T00:00:13", "url": "https://files.pythonhosted.org/packages/b6/0a/a9cb7d34deae650fe386748c04ecc3d2bfb0a86bd7703abe39077f3b3df1/pdfCropMargins-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "39be0c622d05fcf83d918155e40dd065", "sha256": "e63a45fa60810bf3833bcfa324c8420b4be598cbcbeeda912da9e1ea2f343535" }, "downloads": -1, "filename": "pdfCropMargins-0.2.4.tar.gz", "has_sig": false, "md5_digest": "39be0c622d05fcf83d918155e40dd065", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3358656, "upload_time": "2019-09-09T01:20:02", "url": "https://files.pythonhosted.org/packages/41/2b/c9855513d9819ffeae4d821ef24cd593d3a35c5fb988c93ae4a8b5a49eef/pdfCropMargins-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "724b1f634acd3cef8eab1283f7038ff8", "sha256": "430d98f40bb7093544f528e3a10a15ff104480d7306fb81604694c8d03542e2e" }, "downloads": -1, "filename": "pdfCropMargins-0.2.5.tar.gz", "has_sig": false, "md5_digest": "724b1f634acd3cef8eab1283f7038ff8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3359067, "upload_time": "2019-09-09T03:03:45", "url": "https://files.pythonhosted.org/packages/d1/ae/3cb5de295ca7a0226d5e92c64dfe68ad0963a24b701ccd61eee136e011f5/pdfCropMargins-0.2.5.tar.gz" } ], "0.2.6": [ { "comment_text": "", "digests": { "md5": "ec662f0d5ebc99a9d97a63526fefbbfd", "sha256": "f4f8f58460638bdd972b81bc8d8e4a6077865e41a43d605eb3943366c6e943ea" }, "downloads": -1, "filename": "pdfCropMargins-0.2.6.tar.gz", "has_sig": false, "md5_digest": "ec662f0d5ebc99a9d97a63526fefbbfd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3359993, "upload_time": "2019-09-09T04:31:47", "url": "https://files.pythonhosted.org/packages/c2/33/622baca4910c48c9d4b29d804b4690389dff6b0d6730d31a7b4d9ed9fd66/pdfCropMargins-0.2.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ec662f0d5ebc99a9d97a63526fefbbfd", "sha256": "f4f8f58460638bdd972b81bc8d8e4a6077865e41a43d605eb3943366c6e943ea" }, "downloads": -1, "filename": "pdfCropMargins-0.2.6.tar.gz", "has_sig": false, "md5_digest": "ec662f0d5ebc99a9d97a63526fefbbfd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3359993, "upload_time": "2019-09-09T04:31:47", "url": "https://files.pythonhosted.org/packages/c2/33/622baca4910c48c9d4b29d804b4690389dff6b0d6730d31a7b4d9ed9fd66/pdfCropMargins-0.2.6.tar.gz" } ] }