diff options
author | Norbert Preining <norbert@preining.info> | 2024-12-18 03:02:50 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-12-18 03:02:50 +0000 |
commit | 3dab3cbf606a8a72e941ccb8f4f72a21acab9ceb (patch) | |
tree | 661e80b88455c36f709196a8540e04df558e599e /support | |
parent | c51810a531aaf05470b88038a71c64e995b06ae3 (diff) |
CTAN sync 202412180302
Diffstat (limited to 'support')
-rw-r--r-- | support/pdfjam/COPYING | 44 | ||||
-rw-r--r-- | support/pdfjam/README.md | 291 | ||||
-rw-r--r-- | support/pdfjam/VERSION | 1 | ||||
-rw-r--r-- | support/pdfjam/VERSION-4.00 | 1 | ||||
-rwxr-xr-x | support/pdfjam/bin/pdfjam | 1653 | ||||
-rw-r--r-- | support/pdfjam/man/pdfjam.1 | 50 | ||||
-rw-r--r-- | support/pdfjam/man1/pdfjam.1 | 53 | ||||
-rw-r--r-- | support/pdfjam/pdfjam.conf | 22 | ||||
-rw-r--r-- | support/texshop/README.txt | 2 | ||||
-rw-r--r-- | support/texshop/texshop547.html | 31 | ||||
-rw-r--r-- | support/texshop/texshop548.html | 52 |
11 files changed, 1069 insertions, 1131 deletions
diff --git a/support/pdfjam/COPYING b/support/pdfjam/COPYING index d60c31a97a..9efa6fbc96 100644 --- a/support/pdfjam/COPYING +++ b/support/pdfjam/COPYING @@ -1,12 +1,12 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to +the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not @@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. - - GNU GENERAL PUBLIC LICENSE + + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains @@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions: License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - + These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in @@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - + 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is @@ -225,7 +225,7 @@ impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - + 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License @@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN @@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -303,17 +303,15 @@ the "copyright" line and a pointer to where the full notice is found. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - + You should have received a copy of the GNU General Public License along + with this program; if not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. @@ -330,11 +328,11 @@ necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice + <signature of Moe Ghoul>, 1 April 1989 + Moe Ghoul, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General +library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. diff --git a/support/pdfjam/README.md b/support/pdfjam/README.md index 50c65255f2..347a412402 100644 --- a/support/pdfjam/README.md +++ b/support/pdfjam/README.md @@ -1,11 +1,13 @@ - -# pdfjam + -_Reuben Thomas_ <https://rrt.sc3d.org/> +pdfjam +=== -A snapshot of this page is included as _README.md_ -in the distributed package. The most up-to-date version is maintained online at -<https://github.com/rrthomas/pdfjam>. +_Reuben Thomas_ <https://rrt.sc3d.org>, _Markus Kurtz_ <_anything_ at mgkurtz.de> + +A snapshot of this page is included as _README.md_ +in the distributed package. The most up-to-date version is maintained online at +<https://github.com/pdfjam/pdfjam>. 1. [Overview](#overview) - [What is pdfjam?](#whatis) @@ -20,24 +22,24 @@ in the distributed package. The most up-to-date version is maintained online at 9. [Version history](#history) -# <a name="overview"> Overview +# <a name="overview"> Overview ## <a name="whatis"> What is pdfjam? -The **pdfjam** package makes available the `pdfjam` shell script that provides a -simple interface to much of the functionality of the excellent -[pdfpages](https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages) -package (by Andreas Matthias) for _LaTeX_. The `pdfjam` script takes one -or more PDF files (and/or JPG/PNG graphics files) as input, and produces -one or more PDF files as output. It is useful for joining files together, +The **pdfjam** package makes available the `pdfjam` shell script that provides a +simple interface to much of the functionality of the excellent +[pdfpages](https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages) +package (by Andreas Matthias) for _LaTeX_. The `pdfjam` script takes one +or more PDF files (and/or JPG/PNG graphics files) as input, and produces +one or more PDF files as output. It is useful for joining files together, selecting pages, reducing several source pages onto one output page, etc., etc. -A potential drawback of `pdfjam` and other scripts based upon it is that any -hyperlinks in the source PDF are lost. +A potential drawback of `pdfjam` and other scripts based upon it is that any +hyperlinks in the source PDF are lost. -`pdfjam` is designed for Unix-like systems, including Linux and Mac OS X. -It seems that it will work also on Windows computers with a suitable -installation of [Cygwin](https://www.cygwin.com) (with TeX Live +`pdfjam` is designed for Unix-like systems, including Linux and Mac OS X. +It seems that it will work also on Windows computers with a suitable +installation of [Cygwin](https://www.cygwin.com) (with TeX Live installed), but this has not been thoroughly tested. Alternatives to `pdfjam` which are widely packaged in GNU/Linux distributions and other free software collections include: @@ -49,27 +51,27 @@ Alternatives to `pdfjam` which are widely packaged in GNU/Linux distributions an Those alternatives do many of the same things as `pdfjam`, and maybe quite a bit more too. -The **pdfjam** software is made available free, under GPL version 2 (see the -file named `COPYING` that is included with the package). +The **pdfjam** software is made available free, under GPL version 2 (see the +file named `COPYING` that is included with the package). It comes with **ABSOLUTELY NO WARRANTY** of fitness for any purpose whatever. ## <a name="wrappers"> Wrapper scripts no longer included here Previous versions of **pdfjam** (before 3.02) included some _other_ scripts too, in addition to the `pdfjam` script iteslf. -Those other scripts are simple wrappers for calls to `pdfjam`, designed to perform -some common tasks such as joining or n-upping PDF files or to illustrate -other features; they are not very elaborate, and nor are they extensively tested. -They are probably best viewed as simple templates that can be used for -constructing more elaborate wrapper scripts as required. - -Those 'wrapper' scripts are **no longer maintained**. I continue to make -them available in a separate repository -<https://github.com/rrthomas/pdfjam-extras>, -in case anyone wants to see them, to use them, or to improve and maintain +Those other scripts are simple wrappers for calls to `pdfjam`, designed to perform +some common tasks such as joining or n-upping PDF files or to illustrate +other features; they are not very elaborate, and nor are they extensively tested. +They are probably best viewed as simple templates that can be used for +constructing more elaborate wrapper scripts as required. + +Those 'wrapper' scripts are **no longer maintained**. I continue to make +them available in a separate repository +<https://github.com/pdfjam/pdfjam-extras>, +in case anyone wants to see them, to use them, or to improve and maintain them independently as a separate project. -The specific wrapper scripts that were removed from the **pdfjam** package +The specific wrapper scripts that were removed from the **pdfjam** package at version 3.02 are: - `pdfnup`, `pdfpun` @@ -80,26 +82,26 @@ at version 3.02 are: - `pdfjam-pocketmod` - `pdfjam-slides3up`, `pdfjam-slides6up` -For those scripts and for more information on them, please now see -<https://github.com/rrthomas/pdfjam-extras>. +For those scripts and for more information on them, please now see +<https://github.com/pdfjam/pdfjam-extras>. # <a name="prereq"> Pre-requisites - A Unix-like operating system (Linux, Mac OS X, FreeBSD, etc.; possibly Cygwin) -- A working, up-to-date installation of LaTeX (including at least one of +- A working, up-to-date installation of LaTeX (including at least one of `pdflatex`, `lualatex` or `xelatex`) -- A working installation of the LaTeX package +- A working installation of the LaTeX package [**pdfpages**](https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages) (version 0.4f or later) and [**geometry**](https://www.ctan.org/tex-archive/macros/latex/contrib/geometry). -With [libpaper](https://github.com/rrthomas/libpaper) version 2 or later installed, `pdfjam` will be able to find your default paper size, which you can configure if desired. +With [libpaper](https://github.com/rrthomas/libpaper) installed, `pdfjam` will be able to find your default paper size, which you can configure if desired. -For some years now, **pdfjam** has been included in the _TeX Live_ distribution, +For some years now, **pdfjam** has been included in the _TeX Live_ distribution, which includes all the necessary programs and packages to make `pdfjam` run smoothly. -If you have the necessary bandwidth and disk space for it, I do recommend installing +If you have the necessary bandwidth and disk space for it, I do recommend installing [_TeX Live_](https://tug.org/texlive/). # <a name="documentation"></a> Documentation @@ -111,16 +113,16 @@ via the command pdfjam --help ``` -This gives information on the arguments to `pdfjam`, and the default settings -that apply at your installation. In addition to the arguments that are explicitly -documented there, `pdfjam` provides access to all of the options of the -**pdfpages** package: that's a large number of options, and it's a set of options -that might change, so users are referred to the current +This gives information on the arguments to `pdfjam`, and the default settings +that apply at your installation. In addition to the arguments that are explicitly +documented there, `pdfjam` provides access to all of the options of the +**pdfpages** package: that's a large number of options, and it's a set of options +that might change, so users are referred to the current [pdfpages manual (PDF)](https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages/pdfpages.pdf) to see what's available. In case you want to look at the `pdfjam --help` text template online, for example before you decide whether to install **pdfjam**, the source is available at -<https://github.com/rrthomas/pdfjam/blob/master/pdfjam-help.txt>. +<https://github.com/pdfjam/pdfjam/blob/master/pdfjam-help.txt>. There is also a (very basic) `man` page, accessed in the usual way (after installation) by @@ -133,79 +135,79 @@ man pdfjam There are two main ways: -1. Install the [current _TeX Live_ distribution](https://tug.org/texlive/) +1. Install the [current _TeX Live_ distribution](https://tug.org/texlive/) (how you do this will depend on details of your operating system). -_TeX Live_ will already contain a recent release of **pdfjam**. +_TeX Live_ will already contain a recent release of **pdfjam**. Many thanks to Karl Berry -for setting up and maintaining **pdfjam** as a _CTAN_ package that is part of +for setting up and maintaining **pdfjam** as a _CTAN_ package that is part of _TeX Live_. 2. Install it yourself (e.g., if you don't want _TeX Live_, or if you want a later -release of **pdfjam** than the one that's currently in _TeX Live_). +release of **pdfjam** than the one that's currently in _TeX Live_). Download the latest packaged release of **pdfjam** from -<https://github.com/rrthomas/pdfjam/releases>. +<https://github.com/pdfjam/pdfjam/releases>. If for some reason you don't want the latest released version, or even a recently released version, you can still get older versions too: see <https://davidfirth.github.io/pdfjam>. **The first way, via _TeX Live_, is recommended** as the easiest way for most users. If you go the second way, then you will have a bit more to do: -- The `pdfjam` shell script in the _bin_ sub-directory of the released package +- The `pdfjam` shell script in the _bin_ sub-directory of the released package should be placed on the `PATH` of anyone who needs to use it. -- The `man` file in the _man1_ sub-directory should be installed on the `MANPATH` +- The `man` file in the _man1_ sub-directory should be installed on the `MANPATH` of all who might need to read it. # <a name="config"></a> Configuration -On many unix-like systems `pdfjam` should run without any further configuration, -provided that the pre-requisite TeX installation (such as _TeX Live_) is present. -If you want to check (e.g., prior to installation) that `pdfjam` will work on -your system, then +On many unix-like systems `pdfjam` should run without any further configuration, +provided that the pre-requisite TeX installation (such as _TeX Live_) is present. +If you want to check (e.g., prior to installation) that `pdfjam` will work on +your system, then - unzip the `tests.zip` archive (inside the package) - `cd` to your newly made `tests` sub-directory and follow the instructions that appear there in `README_tests.md`. -If configuration _is_ needed, this can be done through a site-wide or -user-specific configuration file. This might be necessary if, for example, your -site has a non-standard TeX installation, or a non-standard location for -temporary files, or a specific paper size for output PDFs --- +If configuration _is_ needed, this can be done through a site-wide or +user-specific configuration file. This might be necessary if, for example, your +site has a non-standard TeX installation, or a non-standard location for +temporary files, or a specific paper size for output PDFs --- or some other reason. -The file -[pdfjam.conf](https://github.com/rrthomas/pdfjam/raw/master/pdfjam.conf) -is a sample configuration file which can be edited as needed. After editing, -either install the file for site-wide use (at `/etc/pdfjam.conf`, -`/usr/share/etc/pdfjam.conf`, `/usr/local/share/pdfjam.conf`, or -`/usr/local/etc/pdfjam.conf`) or as a user-defaults file at `~/.pdfjam.conf`. -User settings made at `~/.pdfjam.conf` override corresponding settings made +The file +[pdfjam.conf](https://github.com/pdfjam/pdfjam/raw/master/pdfjam.conf) +is a sample configuration file which can be edited as needed. After editing, +either install the file for site-wide use (at `/etc/pdfjam.conf`, +`/usr/share/etc/pdfjam.conf`, `/usr/local/share/pdfjam.conf`, or +`/usr/local/etc/pdfjam.conf`) or as a user-defaults file at `~/.pdfjam.conf`. +User settings made at `~/.pdfjam.conf` override corresponding settings made in a site-wide configuration file. -For example, if you prefer to use `/usr/bin/xelatex` as your default LaTeX engine +For example, if you prefer to use `/usr/bin/xelatex` as your default LaTeX engine (in place of the standard `pdflatex`), and you want your output page size to be -"US letter" size paper by default, you would simply include the lines +"US letter" size paper by default, you would simply include the lines ``` latex=/usr/bin/xelatex paper=letterpaper ``` -in a plain text file named '`.pdfjam.conf`' in your home directory. +in a plain text file named '`.pdfjam.conf`' in your home directory. The path `usr/bin/xelatex` specifies exactly _which_ LaTeX program will be -used: it could be a path to any one of the `pdflatex`, `lualatex` or -`xelatex` executables. (You can get the full path to an executable +used: it could be a path to any one of the `pdflatex`, `lualatex` or +`xelatex` executables. (You can get the full path to an executable by, for example, the command `which xelatex`.) The code word `letterpaper` is how LaTeX refers to that particular page size. -For other available paper sizes, and all the many +For other available paper sizes, and all the many other options that could be set as defaults if you want, please see the output of ``` pdfjam --help ``` -On some systems it might even be necessary to change the list of places -(i.e., `/etc/pdfjam.conf` and others as listed above) that is searched for -site-wide configuration files. This can only be done by editing the -`pdfjam` script itself. To see which directories on _your_ system are +On some systems it might even be necessary to change the list of places +(i.e., `/etc/pdfjam.conf` and others as listed above) that is searched for +site-wide configuration files. This can only be done by editing the +`pdfjam` script itself. To see which directories on _your_ system are searched for a file named `pdfjam.conf`, look at the output of ``` @@ -214,23 +216,23 @@ pdfjam --configpath # <a name="using"></a> Using pdfjam -For a full overview of what `pdfjam` can do, the importance of the -[pdfpages manual (PDF)](https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages/pdfpages.pdf) -cannot be stressed enough! +For a full overview of what `pdfjam` can do, the importance of the +[pdfpages manual (PDF)](https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages/pdfpages.pdf) +cannot be stressed enough! The following examples merely serve as a brief introduction. ### Example 1: Batch 2-upping of documents -Consider converting each of two documents to a side-by-side "2-up" format. -Since we want the two documents to be processed separately, we'll use the +Consider converting each of two documents to a side-by-side "2-up" format. +Since we want the two documents to be processed separately, we'll use the `--batch` option: ``` pdfjam --batch --nup 2x1 --suffix 2up --landscape file1.pdf file2.pdf ``` -This will produce new files `file1-2up.pdf` and `file2-2up.pdf` in the current -working directory. +This will produce new files `file1-2up.pdf` and `file2-2up.pdf` in the current +working directory. ### Example 2: Merging pages from 2 documents @@ -240,35 +242,35 @@ Suppose we want a single new document which puts together selected pages from tw pdfjam file1.pdf '{},2-' file2.pdf '10,3-6' --outfile ../myNewFile.pdf ``` -The new file `myNewFile.pdf`, in the parent directory of the current one, -contains an empty page, followed by all pages of `file1.pdf` except the first, +The new file `myNewFile.pdf`, in the parent directory of the current one, +contains an empty page, followed by all pages of `file1.pdf` except the first, followed by pages 10, 3, 4, 5 and 6 from `file2.pdf`. -The resulting PDF page size will be whatever is the default paper size for -you at your site. If instead you want to preserve the page size of +The resulting PDF page size will be whatever is the default paper size for +you at your site. If instead you want to preserve the page size of (the first included page from) `file1.pdf`, use the option `--fitpaper true`. -**All pages in an output file from `pdfjam` will have the same size and -orientation.** For joining together PDF files while preserving _different_ page +**All pages in an output file from `pdfjam` will have the same size and +orientation.** For joining together PDF files while preserving _different_ page sizes and orientations, `pdfjam` is not the tool to use. ### Example 3: A 4-up document with frames -To make a portrait-oriented 4-up file from the pages of three input files, +To make a portrait-oriented 4-up file from the pages of three input files, with a thin-line frame around the input pages: ``` pdfjam file1.pdf file2.pdf file3.pdf --no-landscape --frame true --nup 2x2 --suffix 4up --outfile ~/Documents ``` -Here a _directory_ was specified at `--outfile`: the resultant file in this -case will be `~/Documents/file3-4up.pdf`. -(Note that **if there's a writeable file with that name already, it will be +Here a _directory_ was specified at `--outfile`: the resultant file in this +case will be `~/Documents/file3-4up.pdf`. +(Note that **if there's a writeable file with that name already, it will be overwritten**: no check is made, and no warning given.) ### Example 4: Convert a 'US letter' document to A4 -Suppose we have a document made up of 'US letter' size pages, +Suppose we have a document made up of 'US letter' size pages, and we want to convert it to A4: ``` @@ -277,45 +279,45 @@ pdfjam 'my US letter file.pdf' --a4paper --outfile 'my A4 file.pdf' ### Example 5: Handouts from presentation slides -A useful application of `pdfjam` is for producing a handout from a file of -presentation slides. For slides made with the standard 4:3 aspect ratio a +A useful application of `pdfjam` is for producing a handout from a file of +presentation slides. For slides made with the standard 4:3 aspect ratio a nice 6-up handout on A4 paper can be made by ``` pdfjam --nup 2x3 --frame true --noautoscale false --delta "0.2cm 0.3cm" --scale 0.95 myslides.pdf --outfile myhandout.pdf ``` -The `--delta` option here comes from the pdfpages package; the `--scale` -option is passed to LaTeX's `\includegraphics` command. +The `--delta` option here comes from the pdfpages package; the `--scale` +option is passed to LaTeX's `\includegraphics` command. -Slides made by LaTeX's _beamer_ package, using the `handout` class option, +Slides made by LaTeX's _beamer_ package, using the `handout` class option, work especially nicely with this! The example wrapper scripts `pdfjam-slides3up` -and `pdfjam-slides6up`, in the -[pdfjam-extras](https://github.com/rrthomas/pdfjam-extras) repository, +and `pdfjam-slides6up`, in the +[pdfjam-extras](https://github.com/pdfjam/pdfjam-extras) repository, are for 3-up and 6-up handouts, respectively. ### Example 6: Trimming pages; and piped output -Suppose we want to trim the pages of our input file prior to n-upping. -This can be done by using a pipe: +Suppose we want to trim the pages of our input file prior to n-upping. +This can be done by using a pipe: ``` pdfjam myfile.pdf --trim '1cm 2cm 1cm 2cm' --clip true --outfile /dev/stdout | pdfjam --nup 2x1 --frame true --outfile myoutput.pdf ``` -The `--trim` option specifies an amount to trim from the left, bottom, right and -top sides respectively; to work as intended here it needs also `--clip true`. -These (i.e., `trim` and `clip`) are in fact options to LaTeX's +The `--trim` option specifies an amount to trim from the left, bottom, right and +top sides respectively; to work as intended here it needs also `--clip true`. +These (i.e., `trim` and `clip`) are in fact options to LaTeX's `\includegraphics` command (in the standard _graphics_ package). -Thanks go to Christophe Lange and Christian Lohmaier for suggesting +Thanks go to Christophe Lange and Christian Lohmaier for suggesting an example on this. ### Example 7: Output pages suitable for binding -To offset the content of double-sided printed pages so that they are -suitable for binding with a -[Heftstreifen](https://de.wikipedia.org/wiki/Heftstreifen), use +To offset the content of double-sided printed pages so that they are +suitable for binding with a +[Heftstreifen](https://de.wikipedia.org/wiki/Heftstreifen), use the `--twoside` option: ``` @@ -324,32 +326,32 @@ pdfjam --twoside myfile.pdf --offset '1cm 0cm' --suffix 'offset' ### Example 8: Input file with nonstandard name -To use PDF input files whose names do not end in '`.pdf`', you will need to use -the `--checkfiles` option. This depends on the availability of the `file` +To use PDF input files whose names do not end in '`.pdf`', you will need to use +the `--checkfiles` option. This depends on the availability of the `file` utility, with support for the options `-Lb`; this can be checked by trying ``` file -Lb 'my PDF file' ``` -where `'my PDF file'` is the name of a PDF file on your system. -The result should be something like '`PDF document, version 1.4`' +where `'my PDF file'` is the name of a PDF file on your system. +The result should be something like '`PDF document, version 1.4`' (possibly with a different version number). -With '`file -Lb`' available, we can use PDF files whose names lack the usual -'`.pdf`' extension. For example, +With '`file -Lb`' available, we can use PDF files whose names lack the usual +'`.pdf`' extension. For example, ``` pdfjam --nup 2x1 --checkfiles 'my PDF file' ``` -will result in a file named '`my PDF file-2x1.pdf`' +will result in a file named '`my PDF file-2x1.pdf`' in the current working directory. ### Example 9: Rotate every 2nd page -If you want to print a landscape-oriented PDF document on both sides of the paper, -using a duplex printer that does not have 'tumble' capability, make a new version +If you want to print a landscape-oriented PDF document on both sides of the paper, +using a duplex printer that does not have 'tumble' capability, make a new version with every second page rotated for printing: ``` @@ -362,46 +364,49 @@ pdfjam --landscape --doublepagestwistodd true my-landscape-document.pdf **1. The script runs but the output doesn't look the way it should. Why?** -Most likely either your pdfTeX or your pdfpages installation is an old version. -You could check also that `pdftex.def`, typically to be found in -`.../texmf/tex/latex/graphics/`, -is up to date. If the problem persists even with up-to-date versions of pdfTeX, -`pdftex.def` and pdfpages, then please do report it. +Most likely either your pdfTeX or your pdfpages installation is an old version. +You could check also that `pdftex.def`, typically to be found in +`.../texmf/tex/latex/graphics/`, +is up to date. If the problem persists even with up-to-date versions of pdfTeX, +`pdftex.def` and pdfpages, then please do report it. **2. What can I do to solve a 'Too many open files' error?** -This error has been reported to occur sometimes, when dealing with large numbers of -documents/pages. A suggested solution, if this happens, +This error has been reported to occur sometimes, when dealing with large numbers of +documents/pages. A suggested solution, if this happens, is to include additionally (in the call to `pdfjam`): ``` - -- preamble '\let\mypdfximage\pdfximage \def\pdfximage{\immediate\mypdfximage}' +--preamble '\let\mypdfximage\pdfximage \def\pdfximage{\immediate\mypdfximage}' ``` -See for example +See for example <https://stackoverflow.com/questions/1715677/error-too-many-open-files-in-pdflatex> for this suggestion and links to more information. # <a name="bugs"></a> Reporting bugs -Please report any bugs found in `pdfjam`, either +Please report any bugs found in `pdfjam` by reporting as an issue at GitHub: +<https://github.com/pdfjam/pdfjam/issues> + +# Developing -- by reporting as an issue at GitHub, <https://github.com/rrthomas/pdfjam/issues> -- by email (see <https://warwick.ac.uk/dfirth> for my email address) +This project uses [l3build](https://ctan.org/pkg/l3build). See the header of +`build.lua` for more information. ### Some known problems: -- Sometimes font information (such as ligatures) is lost from the output of +- Sometimes font information (such as ligatures) is lost from the output of `pdfjam`. It seems that a fairly simple fix when this happens is to add the option `--preamble '\pdfinclusioncopyfonts=1'` in your call to `pdfjam`. -- In _Cygwin_, using `pdfjam` in a pipeline does not seem to work. - The problem seems to be with _Cygwin_'s handling of file descriptors +- In _Cygwin_, using `pdfjam` in a pipeline does not seem to work. + The problem seems to be with _Cygwin_'s handling of file descriptors within pipelines. -- The `--preamble` option can sometimes clash with other elements of the LaTeX +- The `--preamble` option can sometimes clash with other elements of the LaTeX preamble. Some specific things to watch out for: + If the preamble needs to set further options to the _geometry_ package, be sure to use the `\geometry{}` command for that. - + If options to the _color_ package are to be specified in the preamble, - do not at the same time use the `--pagecolor` option to `pdfjam`. + + If options to the _color_ package are to be specified in the preamble, + do not at the same time use the `--pagecolor` option to `pdfjam`. # <a name="history"> Version history @@ -409,11 +414,11 @@ Please report any bugs found in `pdfjam`, either ### Overview of the history This all grew originally from a script named `pdfnup`. That was later joined, -in a published package called 'PDFjam', by two further scripts `pdfjoin` and +in a published package called 'PDFjam', by two further scripts `pdfjoin` and `pdf90`. At version 2.00, everything was unified through a single script `pdfjam`, with -many more options. Along with `pdfjam` various 'wrapper' scripts --- i.e., +many more options. Along with `pdfjam` various 'wrapper' scripts --- i.e., other scripts that use `pdfjam` in different ways --- were provided, mainly as examples. @@ -421,10 +426,10 @@ From version 3.02, the extra 'wrapper' scripts are removed from the package, mainly because they are hard to maintain: different users want different things, and `pdfjam` itself provides all the options in any case. So I have broken out the wrapper scripts into a separate repository, _unsupported_ --- -so that people can still see and use/adapt them if they want. -And maybe even someone else will +so that people can still see and use/adapt them if they want. +And maybe even someone else will want to take on the task of improving and maintaining some of them, -who knows? The wrapper scripts (**no longer maintained**) can now be found at -<https://github.com/rrthomas/pdfjam-extras>. +who knows? The wrapper scripts (**no longer maintained**) can now be found at +<https://github.com/pdfjam/pdfjam-extras>. _Releases up to version 2.08 are still available at <https://davidfirth.github.io/pdfjam>._ diff --git a/support/pdfjam/VERSION b/support/pdfjam/VERSION deleted file mode 100644 index cd7061f818..0000000000 --- a/support/pdfjam/VERSION +++ /dev/null @@ -1 +0,0 @@ -This is pdfjam 3.12 diff --git a/support/pdfjam/VERSION-4.00 b/support/pdfjam/VERSION-4.00 new file mode 100644 index 0000000000..806a3a3aba --- /dev/null +++ b/support/pdfjam/VERSION-4.00 @@ -0,0 +1 @@ +This is pdfjam 4.00 diff --git a/support/pdfjam/bin/pdfjam b/support/pdfjam/bin/pdfjam index ff9a0123cd..ca68667c76 100755 --- a/support/pdfjam/bin/pdfjam +++ b/support/pdfjam/bin/pdfjam @@ -1,13 +1,14 @@ #!/bin/sh -version=3.12 +version=4.00 ######################################################################### ## ## ## pdfjam: A shell-script interface to the "pdfpages" LaTeX package ## ## ------ ## ## ## ## Author: David Firth (https://warwick.ac.uk/dfirth) ## +## Maintainer: Markus Kurtz ## ## ## -## Usage: see https://github.com/rrthomas/pdfjam ## +## Usage: see https://github.com/pdfjam/pdfjam ## ## or "pdfjam --help" ## ## ## ## Relies on: ## @@ -30,101 +31,124 @@ version=3.12 ## PRELIMINARIES ## ## First determine: -## --- whether verbose commentary should be provided (not if --quiet -# or --configpath was specified); -## --- whether this call to pdfjam is a "batch" call; -## --- whether just the help text is required; +## --- whether verbose commentary should be provided (not if --quiet +## or --configpath was specified); +## --- whether this call to pdfjam is a "batch" call; +## --- whether just the help text is required; ## --- or whether all configuration files should be ignored. ## verbose=true -for arg -do - case $arg in +for arg; do + case $arg in --quiet | -q | --configpath) - verbose=false ; - ;; + verbose=false;; --version | -V) - echo "$version" - exit 0 ; - ;; + echo "$version" + exit 0;; --batch) - batch=true ; - ;; + batch=true;; --vanilla) - vanilla=true ; - ;; - *) - ;; - esac + vanilla=true;; + *) ;; + esac done ## ## Check to see whether this is a "secondary" call to pdfjam: ## -if test -z "$PDFJAM_CALL_NUMBER" ## not a secondary call -then - PDFJAM_CALL_NUMBER=0 +if test -z "$PDFJAM_CALL_NUMBER"; then ## not a secondary call + PDFJAM_CALL_NUMBER=0 fi ## ## Keep a copy of the internal file separator, so we can change it safely ## OIFS="$IFS" ## -## Record the full filename of the current working diractory +## Record the full filename of the current working directory ## pwd=$(pwd) ## ## Trap interrupts so that they kill everything: ## -trap 'IFS=$OIFS; exit 1' 1 2 15 +trap 'IFS=$OIFS; exit 1' HUP INT TERM ## ## The following will be useful for readability of the script: ## newline=' ' ## -## Define a function to escape tricky characters in file names etc: +## Functions to massage input ## -escape_chars () { - (printf "%s" "${1}" | sed 's/[^a-zA-Z0-9._/\-]/\\&/g') +## Use '' to escape string with multiple tricky characters and \ otherwise +enquote() { + case "$1" in + *$newline*) escape_quote "$1" ;; + '' | *) + if printf %s "$1"|grep -Eq '([ !"#$&()*<>?\^`{|}~].*){2}'; then + escape_quote "$1" ## ^-- matched twice due to --^ + else + escape_chars "$1" + fi + esac +} +escape_quote() { ## Put everything in '' and care for actual ' + printf %s "'$(printf %s "$1" | sed "s/'/'\\\\''/g")'" +} +escape_chars() { ## Prefix tricky characters with \ + printf %s "$1" | sed 's/[ !"#$&-*;<>?[-^`{|}~]/\\&/g' +} +## Put argument in {} if necessary for parsing inside a key value list +embrace() { + value="$1" + case "$value" in + \{*\}) ;; + *,* | *\]*) value="{$value}" ;; + esac + printf %s "$value" +} +## Strip legacy surrounding {}; add bp if no units given +to_papersize() { + value="$1" + case "$value" in + \{*\}) value="${value#\{}"; value="${value%\}}" + esac + printf %s "$value" | sed -E 's/([0-9]{1,}\.{0,1}[0-9]*)(,|$)/\1bp\2/g' } ## ## Define a function to output verbose comments: ## -prattle () { ## second argument here is non-null for continuation lines - if test $verbose = true; then - prefix1=" pdfjam:" ; - prefix2=$(printf "%s" "$prefix1" | sed 's/pdfjam:/ /') ; - indent="" ; - if test "$PDFJAM_CALL_NUMBER" -gt 0 && - test "$batch" != true - then - indent=" " - fi - IFS="$newline" ; - lineCounter=0 ; - for line in ${1} - do - lineCounter=$((lineCounter + 1)) ; - if test $lineCounter -eq 1 && test ! -n "${2}" ; - then - if test -w "$PDFJAM_MESSAGES_FILE" - then printf "$prefix1$indent %s\n" "$line" >> \ - "$PDFJAM_MESSAGES_FILE" - else messages="$messages$prefix1$indent $line$newline" - ## msg file not made yet - fi - else - if test -w "$PDFJAM_MESSAGES_FILE" - then printf "$prefix2$indent %s\n" "$line" >> \ - "$PDFJAM_MESSAGES_FILE" - else messages="$messages$prefix2$indent $line$newline" - ## msg file not made yet +prattle() { ## second argument here is non-null for continuation lines + if test $verbose = true; then + prefix1=" pdfjam:" + prefix2=$(printf "%s" "$prefix1" | sed 's/pdfjam:/ /') + indent="" + if test "$PDFJAM_CALL_NUMBER" -gt 0 && test "$batch" != true; then + indent=" " fi - fi ; - done ; - IFS="$OIFS" ; - fi ; - return ; + IFS="$newline" + lineCounter=0 + for line in ${1}; do + lineCounter=$((lineCounter + 1)) + if test $lineCounter -eq 1 && test ! -n "${2}"; then + if test -w "$PDFJAM_MESSAGES_FILE"; then + printf "$prefix1$indent %s\n" "$line" >> \ + "$PDFJAM_MESSAGES_FILE" + else + messages="$messages$prefix1$indent $line$newline" + ## msg file not made yet + fi + else + if test -w "$PDFJAM_MESSAGES_FILE"; then + printf "$prefix2$indent %s\n" "$line" >> \ + "$PDFJAM_MESSAGES_FILE" + else + messages="$messages$prefix2$indent $line$newline" + ## msg file not made yet + fi + fi + done + IFS="$OIFS" + fi + return } ## ## And here's the first piece of verbose commentary: @@ -147,7 +171,7 @@ prattle "This is pdfjam version ${version}." ## once, the last instance prevails.) ## ## An example configuration file can be found at -## https://github.com/rrthomas/pdfjam +## https://github.com/pdfjam/pdfjam ## ## The path searched for site-wide configuration files can be changed ## by editing the variable 'configpath' at the top of this file. @@ -156,113 +180,121 @@ prattle "This is pdfjam version ${version}." ## First get the full path (if it exists) to pdflatex: ## latex=$(command -v pdflatex) -if [ -z "$latex" ] ; then latex="not found" ; fi +if [ -z "$latex" ]; then latex="not found"; fi ## ## Likewise for the pdfinfo and iconv (only needed for `--keepinfo'): ## pdfinfo=$(command -v pdfinfo) -if [ -z "$pdfinfo" ] ; then pdfinfo="not found"; fi +if [ -z "$pdfinfo" ]; then pdfinfo="not found"; fi iconv=$(command -v iconv) -if [ -z "$iconv" ] ; then iconv="not found"; fi -## -## -## Next a permitted location for temporary files on your system: -## -tempfileDir=${TMPDIR:-'/tmp'} ## /tmp is standard on most unix systems -## -## -## Default for the output file location: -## -outFile="$pwd" ## Output to the current working directory -## -## -## A few more default settings for pdfjam: -## -shortedge='true' ## Default paper is rotated shortedge when doing book -## -runs=1 ## Run latex just once -## -tidy='true' ## Delete all temporary files at the end -## -keepinfo='false' ## Don't try to preserve "pdfinfo" data -## -checkfiles='false' ## Don't use the Unix 'file -Lb' utility to -## identify PDF files from their contents; -## rely on the .pdf or .PDF extension instead. -## -suffix='pdfjam' ## Default filename suffix to be used when -## --outfile is either (a) a directory, or (b) -## not specified in a --batch call. -## -preamble='' ## Default LaTeX preamble string. -## +if [ -z "$iconv" ]; then iconv="not found"; fi +## +## +## Defaults +## +outFile="$pwd" ## Output to the current working directory +suffix=pdfjam ## Default filename suffix to be used when +## --outfile is either (a) a directory, or (b) +## not specified in a --batch call. +checkfiles= ## Don't use the Unix 'file -Lb' utility to +## identify PDF files from their contents; +## rely on the .pdf or .PDF extension instead. +keepinfo= ## Don't try to preserve "pdfinfo" data +landscape= ## Use portrait./Do not switch width and height. +twoside= ## No "twoside" option to documentclass +tidy=tidy ## Delete all temporary files at the end +runs=1 ## Run latex just once +builddir= ## Directory to use instead of temporary one +enc= ## Have `iconv` guess command line encoding +preamble= ## Default LaTeX preamble string. ## END OF SETTINGS MADE DIRECTLY WITHIN THE SCRIPT ## ## Now read the site's or user's configuration file(s) if such exist, ## unless '--vanilla' was specified. ## -if test "$vanilla" != true -then - if test "$PDFJAM_CALL_NUMBER" = 0 ## not a secondary call to pdfjam - then - configFiles=$(printf "%s" "$configpath" | \ - sed 's/:/\/pdfjam.conf:/g; s/$/\/pdfjam.conf/') - configFiles="${configFiles}:$HOME/.pdfjam.conf" - PDFJAM_CONFIG="" - prattle "Reading any site-wide or user-specific defaults..." - IFS=':' - for d in $configFiles - do - if test -f "$d"; then - change=$(sed '/^ *#.*/d ; s/ *#.*//; s/^ *//' "$d") - comment="## ${newline}## From ${d}: ${newline}##" - PDFJAM_CONFIG="$PDFJAM_CONFIG$comment$newline$change$newline" - fi - done - IFS="$OIFS" - PDFJAM_CONFIG=$(printf "%s" "$PDFJAM_CONFIG" | sed 's/^/ /') - if test "$batch" = true ; then export PDFJAM_CONFIG ; fi - if test -z "$PDFJAM_CONFIG" - then - prattle "(none found)" 1 - else - prattle "$PDFJAM_CONFIG" 1 +configpath="$configpath:${XDG_CONFIG_HOME:-$HOME/.config}" +if test "$vanilla" != true; then + if test "$PDFJAM_CALL_NUMBER" = 0; then ## not a secondary call to pdfjam + configFiles=$(printf "%s" "$configpath" | + sed 's/:/\/pdfjam.conf:/g; s/$/\/pdfjam.conf/') + configFiles="${configFiles}:$HOME/.pdfjam.conf" + PDFJAM_CONFIG="" + prattle "Reading any site-wide or user-specific defaults..." + IFS=':' + for d in $configFiles; do + if test -f "$d"; then + change=$(sed '/^ *#.*/d ; s/ *#.*//; s/^ *//' "$d") + comment="## ${newline}## From ${d}: ${newline}##" + PDFJAM_CONFIG="$PDFJAM_CONFIG$comment$newline$change$newline" + fi + done + IFS="$OIFS" + PDFJAM_CONFIG=$(printf "%s" "$PDFJAM_CONFIG" | sed 's/^/ /') + if test "$batch" = true; then export PDFJAM_CONFIG; fi + if test -z "$PDFJAM_CONFIG"; then + prattle "(none found)" 1 + else + prattle "$PDFJAM_CONFIG" 1 + fi fi - fi - if test -n "$PDFJAM_CONFIG" ; then eval "$PDFJAM_CONFIG" ; fi + if test -n "$PDFJAM_CONFIG"; then eval "$PDFJAM_CONFIG"; fi else - if test $PDFJAM_CALL_NUMBER -eq 0 - then - prattle "Called with '--vanilla': no user or site configuration" - prattle "files will be read." 1 - fi + if test "$PDFJAM_CALL_NUMBER" -eq 0; then + prattle "Called with '--vanilla': no user or site configuration" + prattle "files will be read." 1 + fi +fi +if [ -n "$paper" ] && [ -n "$papersize" ]; then + prattle "Both paper and papersize configured, ignoring papersize" 1 + papersize= fi ## For backwards compatibility, check here for a $pdflatex setting in the config file -if [ -n "${pdflatex:-}" ] ; then latex="$pdflatex" ; fi +if [ -n "${pdflatex:-}" ]; then latex="$pdflatex"; fi ## -## If paper size is not set, get default paper size from libpaper >= 2 if +## If paper size is not set, get default paper size from libpaper if ## possible, otherwise guess A4. ## +paperformats=:a0:a1:a2:a3:a4:a5:a6:b0:b1:b2:b3:b4:b5:b6:c0:c1:c2:c3:c4:c5:c6\ +:ansia:ansib:ansic:ansid:ansie:letter:legal:executive:b0j:b1j:b2j:b3j:b4j:b5j:b6j: +to_paper() { + printf %s "$1"|grep -q '^[A-Za-z0-9]*$' || return 2 # make sure input is harmless + paper=$(echo "$1" | tr A-Z a-z) + paper=${paper%paper} + echo $paperformats|grep -q ":$paper:" || return 1 + case $paper in + b?j) ;; + *) paper="$paper"paper + esac + echo "$paper" +} paperspec= if test -z "$paper"; then - if command -v paper >/dev/null ; then - paperspec=$(paper) - if echo "$paperspec" | grep -q '^.*: '; then - paperdimensions=$(echo "$paperspec" | cut -f 2 -d " ") - paperunit=$(echo "$paperspec" | cut -f 3 -d " ") - if test "$paperunit" = "pt"; then paperunit=bp; fi - paperwidth=$(echo "$paperdimensions" | cut -f 1 -d "x") - paperheight=$(echo "$paperdimensions" | cut -f 2 -d "x") - papersize="papersize={$paperwidth$paperunit,$paperheight$paperunit}" - paper='' ## We might not have a LaTeX-compatible name - else - echo "The 'paper' program seems not to be working; not using it" + if command -v paper >/dev/null; then ## provided by libpaper>=2 + paperspec=$(paper) + if echo "$paperspec" | grep -q ': '; then + if ! paper=$(to_paper "${paperspec%%: *}"); then + paperdimensions=$(echo "$paperspec" | cut -f 2 -d " ") + paperunit=$(echo "$paperspec" | cut -f 3 -d " ") + if test "$paperunit" = "pt"; then paperunit=bp; fi + paperwidth=$(echo "$paperdimensions" | cut -f 1 -d "x") + paperheight=$(echo "$paperdimensions" | cut -f 2 -d "x") + papersize="$paperwidth$paperunit,$paperheight$paperunit" + fi + else + prattle "The 'paper' program seems not to be working; not using it" 1 + fi + fi + if test -z "$paper$papersize"; then + if command -v paperconf >/dev/null; then ## provided by libpaper>=1 + paper=$(to_paper "$(paperconf)") \ + || papersize=$(paperconf -s \ + | sed -nE '1s/^([0-9]*(\.[0-9]+)?) ([0-9]*(\.[0-9]+)?)$/\1bp,\3bp/p') + fi ## the above did not work + if test -z "$paper$papersize"; then + paper='a4paper' ## fallback paper size is ISO A4 + papersize='' ## clear papersize + fi fi - fi - if test -z "$paperspec"; then - paper='a4paper' ## fallback paper size is ISO A4 - papersize='' ## clear papersize - fi fi ## ## END OF CONFIGURATION BLOCK @@ -279,11 +311,11 @@ https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages Usage: pdfjam [OPTIONS] [--] [FILE1 [SEL1]] [FILE2 [SEL2]]... where -* 'FILE1' etc. are PDF files (JPG and PNG files are also allowed). For - input from /dev/stdin, use the special name '/dev/stdin' in place of any - of FILE1, FILE2, etc: this can be mixed with 'real' files as needed, to - allow input through a pipe (note that if /dev/stdin is connected to tty, - an error results). If 'FILE1' is absent, pdfjam will use '/dev/stdin' +* 'FILE1' etc. are PDF files (JPG and PNG files are also allowed). For + input from /dev/stdin, use the special name '/dev/stdin' in place of any + of FILE1, FILE2, etc: this can be mixed with 'real' files as needed, to + allow input through a pipe (note that if /dev/stdin is connected to tty, + an error results). If 'FILE1' is absent, pdfjam will use '/dev/stdin' (and will use '-' for the page selection -- see next item). * 'SEL1' is a page selection for FILE1, etc. To select all pages (the default) use '-'. See the pdfpages manual for @@ -297,8 +329,8 @@ where ... file1 file2 2- file3 1-7 ... would apply the page selection '2-' to file1 and file2, and '1-7' to file3. A page selection applies to all the files *immediately* - preceding it in the argument list. A missing page selection defaults to - '-'; this includes the case where 'FILE1' is absent and so /dev/stdin gets + preceding it in the argument list. A missing page selection defaults to + '-'; this includes the case where 'FILE1' is absent and so /dev/stdin gets used by default. * 'options' are pdfpages specifications in the form '--KEY VALUE' (see below), or @@ -325,9 +357,9 @@ where existing directory, pdfjam will attempt to write its output PDF file(s) there, with name(s) derived from the input file name(s) and the --suffix option (see below). - Otherwise the output file will be PATH. If '/dev/stdin' + Otherwise the output file will be PATH. If '/dev/stdin' is the only or last input file, PATH cannot be a directory. - Your current default PATH for output is: + Your current default PATH for output is: $outFile --suffix STRING Specifies a suffix for output file names, to be used when @@ -356,12 +388,12 @@ where line. An example: pdfjam --nup 2x2 myfile.pdf -o myfile-4up.pdf \\ --preamble '\usepackage{fancyhdr} \pagestyle{fancy}' - The '--preamble' option can be used, for example, to load + The '--preamble' option can be used, for example, to load LaTeX packages and/or to set global options. If '--preamble' - is used more than once in the call, the supplied preamble + is used more than once in the call, the supplied preamble strings are simply concatenated. For a note on avoiding clashes, see the README file, also available at - https://github.com/rrthomas/pdfjam + https://github.com/pdfjam/pdfjam --keepinfo --no-keepinfo Preserve (or not) Title, Author, Subject and Keywords @@ -377,11 +409,10 @@ where Provide text for the Title, Author, Subject and Keywords in the output PDF file. Requires the LaTeX 'hyperref' package. These options, individually, over-ride --keepinfo. - --longedge - --shortedge - Specify the direction in which double-sided pages are - flipped. It may not work correctly in all cases, so if every - other page is rotated 180°, flip this switch. + --otheredge + --no-otheredge + Rotate every odd page by 180 degrees (or not). Thus changes + along which edge the pages are flipped in duplex printing. --landscape --no-landscape Specify landscape page orientation (or not) in the @@ -393,20 +424,22 @@ where [Default for you at this site: twoside=$twoside] --paper PAPERSPEC (or simply --PAPERSPEC) Specify a LaTeX paper size, for example - '--paper a4paper' or simply '--a4paper' for ISO A4 paper. + '--paper a4' or simply '--a4paper' for ISO A4 paper. A wide range of paper sizes is available thanks to the LaTeX 'geometry' package. For details see documentation for LaTeX and/or the 'geometry' package. If no default value is set and libpaper is not available, A4 is used. [Default for you at this site: paper=$paper] - --papersize '{WIDTH,HEIGHT}' - Specify a custom paper size, e.g., - --papersize '{10in,18cm}' - (Note the braces, and the comma!) - [Libpaper default: $papersize] + --papersize 'WIDTH,HEIGHT' + Specify a custom paper size in points = 1/72 inch (known as + bp in LaTeX and as pt in other software), e.g. + --papersize 612,792 + Units may also be specified explicitly, e.g. + --papersize 10in,18cm + [Default for you at this site: papersize=$papersize] --pagecolor RGBSPEC - Specify a background colour for the output pages. The + Specify a background colour for the output pages. The RGBSPEC must be a comma-separated trio of integers between 0 and 255. An example: --pagecolor 150,200,150 @@ -414,17 +447,20 @@ where --tidy --no-tidy Specify whether the temporary directory created by - pdfjam should be deleted. Use '--no-tidy' to help debug - most errors. + pdfjam should be deleted. Use '--no-tidy' or '--builddir' + below to help debug most errors. [Default for you at this site: tidy=$tidy] + --builddir PATH + Specifies a build directory to be used in place of a + temporary one. Existing files inside will be overwritten. --latex PATHTOLATEX Specify the LaTeX engine to be used (one of pdflatex, - xelatex, lualatex). The PATHTOLATEX string must be - the full path to a suitable LaTeX executable (for example - /usr/bin/xelatex on many unix systems). - [Default for you at this site: latex=$latex] + xelatex, lualatex). The PATHTOLATEX string must be + the full path to a suitable LaTeX executable (for example + /usr/bin/xelatex on many unix systems). + [Default for you at this site: latex=$latex] --runs N - Run latex N times, for each output document made. + Run latex N times, for each output document made. [Default for you at this site: runs=$runs] --vanilla Suppress the reading of any pdfjam configuration files. @@ -445,17 +481,17 @@ where --frame true (to put a frame round each input page) --booklet true (to reorder the pages in signatures, generally useful with --nup) - --signature N (specify the signature size, as the + --signature N (specify the signature size, as the number of original pages in a signature in the final document. Caveat: booklet - is a short form for signature, so if + is a short form for signature, so if you use booklet true, signature will be ignored) --trim '1cm 2cm 1cm 2cm' --clip true (to trim those amounts from left, bottom, - right and top, respectively, of input - pages) - --angle NNN (The angle of rotation in degrees. Angles + right and top, respectively, of input + pages) + --angle NNN (The angle of rotation in degrees. Angles that are not either 90, 180 or 270 will still create straight rectangular pages, only the content will be rotated.) @@ -464,7 +500,7 @@ where https://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages * '--' can be used to signal that there are no more options to come. -Defaults for the options '--suffix', '--keepinfo', '--paper', '--outfile', +Defaults for the options '--suffix', '--keepinfo', '--paper', '--outfile', '--landscape', '--twoside', '--tidy', '--latex', '--runs', '--checkfiles' and '--preamble' can be set in site-wide or user-specific configuration files. The path that is searched for site-wide configuration files (named pdfjam.conf) @@ -476,7 +512,7 @@ necessary. Any user-specific configuration should be put in a file named if the '--vanilla' argument is used.) For more information, including a sample configuration file, see -https://github.com/rrthomas/pdfjam. +https://github.com/pdfjam/pdfjam. " ## ## END OF HELP TEXT @@ -486,16 +522,13 @@ https://github.com/rrthomas/pdfjam. # If --help is given, print help and exit. We do this here so that the # configuration files have already been read, and default values can be # shown in the help -for arg -do - case $arg in +for arg; do + case $arg in --help | -u | -h) - printf "%s\n" "$helptext" ; - exit 0 ; - ;; - *) - ;; - esac + printf "%s\n" "$helptext" + exit 0;; + *) ;; + esac done ######################################################################### ## @@ -511,13 +544,14 @@ E_CONFIG=78 # configuration error ## ## Define a function to print an error message and exit: ## -error_exit () { - if [ -r "$PDFJAM_MESSAGES_FILE" ] - then cat "$PDFJAM_MESSAGES_FILE" >&2 - else printf "%s" "$messages" 1>&2 - fi - printf " pdfjam ERROR: %s\n" "$1" 1>&2 ; - exit "$2" ; +error_exit() { + if [ -r "$PDFJAM_MESSAGES_FILE" ]; then + cat "$PDFJAM_MESSAGES_FILE" >&2 + else + printf "%s" "$messages" 1>&2 + fi + printf " pdfjam ERROR: %s\n" "$1" 1>&2 + exit "$2" } ## ######################################################################### @@ -526,10 +560,9 @@ error_exit () { ## ## In case of NO argument supplied, mention 'pdfjam --help': ## -if test $# -eq 0 -then - prattle "No arguments supplied; continuing anyway. (See" - prattle "'pdfjam --help' for information on usage.)" 1 +if test $# -eq 0; then + prattle "No arguments supplied; continuing anyway. (See" + prattle "'pdfjam --help' for information on usage.)" 1 fi ## ## Now do the argument loop. @@ -541,291 +574,209 @@ optionsFinished="" ## ## First note any '--checkfiles' or '--no-checkfiles' option ## -for arg -do - case $arg in +for arg; do + case $arg in --checkfiles) - checkfiles=true ; - callOptions="$callOptions --checkfiles" ; - ;; + checkfiles=checkfiles + callOptions="$callOptions $1";; --no-checkfiles) - checkfiles=false ; - callOptions="$callOptions --no-checkfiles" ; - ;; - esac + checkfiles= + callOptions="$callOptions $1";; + esac done -while test -n "${1}${2}"; do - argUnmatched="" - if test "$optionsFinished" != true - then - case ${1} in - --) ## signals end of command-line options - optionsFinished=true ; - shift ; - continue ; - ;; - --configpath) - printf "%s\n" "$configpath" ; - exit 0;; - --* | -q | -o) - if test "$pageSpecAwaited" = true ; then - ## fill in any missing page specs before continuing - fileSpec=$(printf "%s" "$fileSpec" | sed 's/|awaited/|-/g') - pageSpecAwaited=false - fi - case ${1} in - --latex) - latex="${2}" ; - callOptions="$callOptions --latex ${2}" ; - shift ;; - --batch) - batch=true ; - ;; - --vanilla) - callOptions="$callOptions ${1}" ; +while test -n "$1$2"; do + argUnmatched="" + if test "$optionsFinished" != true; then + case "$1" in + --) ## signals end of command-line options + optionsFinished=true + shift + continue ;; - --quiet | -q) - verbose=false ; - callOptions="$callOptions ${1}" ; + --configpath) + printf "%s\n" "$configpath" + exit 0 ;; - --outfile | -o) - outFile="${2}" ; - if test "$batch" = true - then - outFile=$(escape_chars "$outFile") - fi - callOptions="$callOptions --outfile $outFile" ; - shift ;; - --suffix) - if test -n "${2}" - then - suffix="${2}" ; - if test "$batch" = true - then - suffix=$(escape_chars "$suffix") - fi - callOptions="$callOptions --suffix $suffix" - shift - else - error_exit \ - "'--suffix' string has zero length" \ - $E_USAGE ; + --* | -q | -o) + if test "$pageSpecAwaited" = true; then + ## fill in any missing page specs before continuing + fileSpec=$(printf "%s" "$fileSpec" | sed 's/|awaited/|-/g') + pageSpecAwaited=false fi + case "$1" in + --checkfiles | --no-checkfiles | --batch) ;; ## already done above + --vanilla) + callOptions="$callOptions $1" + ;; + --quiet | -q) + verbose=false + callOptions="$callOptions --quiet" + ;; + --outfile | -o) + outFile="$2" + callOptions="$callOptions --outfile $(enquote "$2")" + shift + ;; + --suffix) + if test -n "$2"; then + suffix="$2" + callOptions="$callOptions $1 $(enquote "$2")" + shift + else + error_exit \ + "'--suffix' string has zero length" \ + $E_USAGE + fi + ;; + --runs) + runs="$2" + ## check if the argument is a number > 0 + if [ "$runs" -lt 1 ] 2>/dev/null; then + error_exit \ + "'--runs' number must be at least 1" \ + $E_USAGE + fi + callOptions="$callOptions $1 $2" + shift + ;; + --paper) + if ! paper=$(to_paper "$2"); then + paper="$2" + prattle "Paper '$paper' unknown to pdfjam." + fi + papersize='' + callOptions="$callOptions $1 $(enquote "$paper")" + shift + ;; + --a?paper | --b?paper | --c?paper | --ansi?paper | \ + --letterpaper | --legalpaper | --executivepaper | \ + --b0j | --b1j | --b2j | --b3j | --b4j | --b5j | --b6j) + paper=$(to_paper "${1#--}") \ + || error_exit "Bad paper option '$1'." $E_USAGE + papersize='' + callOptions="$callOptions --paper $paper" + ;; + --papersize) + paper='' + papersize=$(to_papersize "$2") + callOptions="$callOptions $1 $(enquote "$papersize")" + shift + ;; + --preamble) + preamble="$preamble$newline$2" + shift + ;; + --latex | --builddir | --enc | --pagecolor | \ + --pdftitle | --pdfauthor | --pdfsubject | --pdfkeywords) + eval "${1#--}=$(escape_quote "$2")" + callOptions="$callOptions $1 $(enquote "$2")" + shift + ;; + --tidy | --keepinfo | --landscape | --twoside | --otheredge) + eval "${1#--}=${1#--}" + callOptions="$callOptions $1" + ;; + --no-tidy | --no-keepinfo | --no-landscape | --no-twoside | \ + --no-otheredge) + eval "$(echo "${1#--no-}"|tr - _)=" + callOptions="$callOptions $1" + ;; + --longedge) ## legacy + otheredge=otheredge + callOptions="$callOptions --otheredge" + ;; + --shortedge) ## legacy + otheredge= + callOptions="$callOptions --no-otheredge" + ;; + --*) ## miscellaneous options for \includepdfmerge + miscOptions="$miscOptions,${1#--}=$(embrace "$2")" + callOptions="$callOptions ${1} $(enquote "$2")" + shift + ;; + esac ;; - --runs) - runs="${2}" ; - ## check if the argument is a number > 0 - if [ "$runs" -lt 1 ] 2> /dev/null; then - error_exit \ - "'--runs' number must be at least 1" \ - $E_USAGE ; - fi - callOptions="$callOptions --runs ${2}" ; - shift ;; - --tidy) - tidy=true ; - callOptions="$callOptions --tidy" ; - ;; - --no-tidy) - tidy=false ; - callOptions="$callOptions --no-tidy" ; + '' | *) + argUnmatched=true ;; - --shortedge) - shortedge=true ; - callOptions="$callOptions --shortedge" ; - ;; - --longedge) - shortedge=false ; - callOptions="$callOptions --longedge" ; - ;; - --keepinfo) - keepinfo=true ; - callOptions="$callOptions --keepinfo" ; + esac + fi + if test "$optionsFinished" = true || test "$argUnmatched" = true; then + case "$1" in + "" | /dev/stdin) + fileSpec="$fileSpec$newline/dev/stdin|awaited" + pageSpecAwaited=true + inputFromStdin=true ;; - --no-keepinfo) - keepinfo=false ; - callOptions="$callOptions --no-keepinfo" ; - ;; - --checkfiles) - ;; ## already done above - --no-checkfiles) - ;; ## already done above - --pdftitle) - pdfTitle="${2}" ; - if test "$batch" = true - then - pdfTitle=$(escape_chars "$pdfTitle") - fi - callOptions="$callOptions --pdftitle $pdfTitle" ; - shift ;; - --pdfauthor) - pdfAuthor="${2}" ; - if test "$batch" = true - then - pdfAuthor=$(escape_chars "$pdfAuthor") - fi - callOptions="$callOptions --pdfauthor $pdfAuthor" ; - shift ;; - --pdfsubject) - pdfSubject="${2}" ; - if test "$batch" = true - then - pdfSubject=$(escape_chars "$pdfSubject") - fi - callOptions="$callOptions --pdfsubject $pdfSubject" ; - shift ;; - --pdfkeywords) - pdfKeywords="${2}" ; - if test "$batch" = true - then - pdfKeywords=$(escape_chars "$pdfKeywords") + -) + if test "$pageSpecAwaited" = true; then + fileSpec=$(printf %s "$fileSpec" | sed 's/|awaited/|-/g') + pageSpecAwaited=false + else + error_exit "no PDF/JPG/PNG file found at ${1}" \ + $E_NOINPUT fi - callOptions="$callOptions --pdfkeywords $pdfKeywords" ; - shift ;; - --paper) - paper="${2}" - papersize='' ## clear papersize - callOptions="$callOptions ${1} ${2}" ; - shift ;; - --pagecolor) - pagecolor="${2}" ; - callOptions="$callOptions ${1} ${2}" ; - shift ;; - --a0paper | --a1paper | --a2paper | --a3paper | \ - --a4paper | --a5paper | --a6paper | \ - --b0paper | --b1paper | --b2paper | \ - --b3paper | --b4paper | --b5paper | --b6paper | \ - --c0paper | --c1paper | --c2paper | \ - --c3paper | --c4paper | --c5paper | --c6paper | \ - --b0j | --b1j | --b2j | --b3j | --b4j | --b5j | --b6j | \ - --ansiapaper | --ansibpaper | --ansicpaper | \ - --ansidpaper | --ansiepaper | \ - --letterpaper | --legalpaper | --executivepaper) - paper=$(printf "%s" "${1}" | sed 's/^--//') ; - papersize='' ## clear papersize - callOptions="$callOptions ${1}" ; - ;; - --papersize) - paper='' ## clear paper - papersize="papersize=${2}" ; - callOptions="$callOptions ${1} '${2}'" ; - shift ;; - --landscape) - landscape=true ; - callOptions="$callOptions --landscape" ; - ;; - --no-landscape) - landscape=false ; - callOptions="$callOptions --no-landscape" ; - ;; - --twoside) - twoside=true ; - callOptions="$callOptions --twoside" ; - ;; - --no-twoside) - twoside=false ; - callOptions="$callOptions --no-twoside" ; ;; - --preamble) - preamble="$preamble${2}" ; - shift ;; - --enc) # command line encoding - enc="${2}" - callOptions="$callOptions ${1} ${2}" - shift ;; - --*) - ## options for \includepdfmerge - argName=$(printf "%s" "${1}" | sed 's/^--//'); - value="${2}" - miscOptions=$miscOptions,"$argName=$value" ; - ## saved for possible use in LaTeX file - callOptions="$callOptions ${1} '$value'" ; - ## saved for possible use in a further call to pdfjam - shift ; - ;; - esac ;; - '' | *) - argUnmatched=true - ;; - esac - fi - if test "$optionsFinished" = true || test "$argUnmatched" = true - then - case ${1} in - "" | /dev/stdin) - fileSpec="${fileSpec}${newline}/dev/stdin|awaited" - pageSpecAwaited=true - inputFromStdin=true ;; - -) - if test "$pageSpecAwaited" = true ; then - fileSpec=$(printf "%s" "$fileSpec" | \ - sed 's/|awaited/|-/g') - pageSpecAwaited=false - else - error_exit "no PDF/JPG/PNG file found at ${1}" \ - $E_NOINPUT - fi ;; - *) ## All other args should be PDF (or JPG/PNG) - ## source files and page selections; if not, we'll quit - if test "$checkfiles" = true ; ## not always available - then - case $(file -Lb "${1}") in - "PDF document"*|"JPEG image data"*|"PNG image"*) - ## it's a PDF file (or JPG/PNG) as expected - fileSpec="$fileSpec${newline}${1}|awaited" - pageSpecAwaited=true - ;; - *) - case ${1} in + *) ## All other args should be PDF (or JPG/PNG) + ## source files and page selections; if not, we'll quit + if test -n "$checkfiles"; then ## not always available + case $(file -Lb -- "$1") in + "PDF document"* | "JPEG image data"* | "PNG image"*) + ## it's a PDF file (or JPG/PNG) as expected + fileSpec="$fileSpec$newline$1|awaited" + pageSpecAwaited=true + ;; + *) + case ${1} in + *.[pP][dD][fF] | *.[jJ][pP][eE][gG] | \ + *.[jJ][pP][gG] | *.[pP][nN][gG]) + ## should be PDF/JPG/PNG file, but isn't + error_exit "no PDF/JPG/PNG file found at ${1}" \ + $E_NOINPUT + ;; + *) ## if page spec needed, assume this is it; + ## otherwise something is wrong + if test "$pageSpecAwaited" = true; then + escapedFilePath=$(printf '%s' "$1" | sed -e 's#/#\\/#g') + fileSpec=$(printf "%s" "$fileSpec" \ + | sed "s/|awaited/|${escapedFilePath}/g") + pageSpecAwaited=false + else + error_exit "no PDF/JPG/PNG file found at ${1}" \ + $E_NOINPUT + fi + ;; + esac + ;; + esac + else ## no checking of file contents; rely on .pdf extension + case ${1} in *.[pP][dD][fF] | *.[jJ][pP][eE][gG] | \ - *.[jJ][pP][gG] | *.[pP][nN][gG]) - ## should be PDF/JPG/PNG file, but isn't - error_exit "no PDF/JPG/PNG file found at ${1}" \ - $E_NOINPUT - ;; + *.[jJ][pP][gG] | *.[pP][nN][gG]) + ## assume it's a PDF/JPG/PNG file + test -f "${1}" || error_exit \ + "${1} not found" $E_NOINPUT + fileSpec="$fileSpec"$newline${1}"|"awaited + pageSpecAwaited=true + ;; *) ## if page spec needed, assume this is it; - ## otherwise something is wrong - if test "$pageSpecAwaited" = true ; then - escapedFilePath=$(printf '%s' "$1" | sed -e 's#/#\\/#g') - fileSpec=$(printf "%s" "$fileSpec" | \ - sed "s/|awaited/|${escapedFilePath}/g") - pageSpecAwaited=false - else - error_exit "no PDF/JPG/PNG file found at ${1}" \ - $E_NOINPUT - fi - ;; - esac - ;; - esac - else ## no checking of file contents; rely on .pdf extension - case ${1} in - *.[pP][dD][fF] | *.[jJ][pP][eE][gG] \ - | *.[jJ][pP][gG] | *.[pP][nN][gG]) - ## assume it's a PDF/JPG/PNG file - test -f "${1}" || error_exit \ - "${1} not found" $E_NOINPUT - fileSpec="$fileSpec"$newline${1}"|"awaited - pageSpecAwaited=true - ;; - *) ## if page spec needed, assume this is it; - ## otherwise something is wrong - if test "$pageSpecAwaited" = true ; then - escapedFilePath=$(printf '%s' "$1" | sed -e 's#/#\\/#g') - fileSpec=$(printf "%s" "$fileSpec" | \ - sed "s/|awaited/|${escapedFilePath}/g") - pageSpecAwaited=false - else - error_exit "no PDF/JPG/PNG file found at ${1}" \ - $E_NOINPUT - fi - ;; - esac - fi - ;; - esac - fi - shift + ## otherwise something is wrong + if test "$pageSpecAwaited" = true; then + escapedFilePath=$(printf '%s' "$1" | sed -e 's#/#\\/#g') + fileSpec=$(printf "%s" "$fileSpec" \ + | sed "s/|awaited/|${escapedFilePath}/g") + pageSpecAwaited=false + else + error_exit "no PDF/JPG/PNG file found at ${1}" \ + $E_NOINPUT + fi + ;; + esac + fi + ;; + esac + fi + shift done ## ## Use the default page spec for any that remain unspecified: @@ -833,53 +784,39 @@ done fileSpec=$(printf "%s" "$fileSpec" | sed '/^$/d; s/^ //; s/|awaited$/|-/') ## ## Check whether input from stdin should be used by default: -if test $PDFJAM_CALL_NUMBER -eq 0 && test "$inputFromStdin" != true -then - ## the special argument '/dev/stdin' was not used - if test -z "$fileSpec" ; then - ## no argument specifying a PDF source was given - inputFromStdin=true - fileSpec="/dev/stdin|-" - prattle "No PDF/JPG/PNG source specified: input is from stdin." - fi +if test "$PDFJAM_CALL_NUMBER" -eq 0 && test "$inputFromStdin" != true; then + ## the special argument '/dev/stdin' was not used + if test -z "$fileSpec"; then + ## no argument specifying a PDF source was given + inputFromStdin=true + fileSpec="/dev/stdin|-" + prattle "No PDF/JPG/PNG source specified: input is from stdin." + fi fi -## -## Delete leading comma from $miscOptions: -## -miscOptions=$(printf "%s" "$miscOptions" | sed 's/^,//') -## -if test -n "$preamble" -then callOptions="$callOptions --preamble '$preamble'" +## Massage options +[ "${paper:+set}" = "${papersize:+set}" ] && error_exit "Exactly one of \ +\$paper='$paper' and \$papersize='$papersize' must be set." $E_SOFTWARE +miscOptions="${miscOptions#,}" +if test -n "$preamble"; then + callOptions="$callOptions --preamble $(enquote "${preamble#"$newline"}")" fi -## Delete leading space from $callOptions: -## -callOptions=$(printf "%s" "$callOptions" | sed 's/^ //') -## -## Set up a document options variable: -## -case $landscape in - true) - orientation=landscape - if test -n "$papersize"; then - papersize="papersize={$paperheight$paperunit,$paperwidth$paperunit}" - fi ;; - *) - orientation="" ;; -esac -case $twoside in - true) - twoside=twoside ;; - *) - twoside="" ;; -esac -case $shortedge in - true) - shortedge="" ;; - *) - shortedge='\usepackage{everyshi}\makeatletter\EveryShipout{\ifodd\c@page\pdfpageattr{/Rotate 180}\fi}\makeatother' ;; -esac -documentOptions="$paper","$orientation","$twoside" -documentOptions=$(printf "%s" "$documentOptions" | sed 's/^,//' | sed 's/,$//') +callOptions="${callOptions# }" +if [ -n "$otheredge" ]; then + otheredge=' +{\makeatletter\AddToHook{shipout/before}{\ifodd\c@page\pdfpageattr{/Rotate 180}\fi}}' +fi +if [ -n "$papersize" ]; then + if [ -n "$landscape" ]; then + ## geometry package ignores landscape, thus swap x,y → y,x manually + papersize="${papersize#*,},${papersize%%,*}" + fi + papersize="papersize={$papersize}" +fi + +documentOptions= +for i in "$paper" "$landscape" "$twoside"; do + [ -n "$i" ] && documentOptions="$documentOptions$i," +done ## ## END OF ARGUMENT PROCESSING ## @@ -889,100 +826,88 @@ documentOptions=$(printf "%s" "$documentOptions" | sed 's/^,//' | sed 's/,$//') ## ## These checks are not repeated in secondary calls. ## -if test $PDFJAM_CALL_NUMBER -eq 0 ## not a secondary call -then - ## Check whether there's a suitable latex to use: - case "$latex" in +if test "$PDFJAM_CALL_NUMBER" -eq 0; then ## not a secondary call + ## Check whether there's a suitable latex to use: + case "$latex" in "not found") - error_exit "can't find pdflatex!" $E_UNAVAILABLE - ;; - *) ## - if test ! -x "$latex" - then - error_exit \ - "configuration error, $latex is not an executable file" \ - $E_CONFIG - fi - ;; - esac - ## - ## Check that necessary LaTeX packages are installed: - ## - modifyPath=$(printf "%s" "$latex" | sed 's/\/[^\/]*$//') - if [ -n "$modifyPath" ] ; then - PATH="$modifyPath:$PATH" - export PATH - fi - case "$latex" in - *tectonic*) ;; - *) - (kpsewhich pdfpages.sty >/dev/null) || - error_exit \ - "LaTeX package pdfpages.sty is not installed" \ - $E_UNAVAILABLE - ;; - esac + error_exit "can't find pdflatex!" $E_UNAVAILABLE + ;; + *) ## + if test ! -x "$latex"; then + error_exit \ + "configuration error, $latex is not an executable file" \ + $E_CONFIG + fi + ;; + esac + ## + ## Check that necessary LaTeX packages are installed: + ## + modifyPath=$(printf "%s" "$latex" | sed 's/\/[^\/]*$//') + if [ -n "$modifyPath" ]; then + PATH="$modifyPath:$PATH" + export PATH + fi + case "$latex" in + *tectonic*) ;; + *) + (kpsewhich pdfpages.sty >/dev/null) \ + || error_exit \ + "LaTeX package pdfpages.sty is not installed" \ + $E_UNAVAILABLE + ;; + esac fi -if test "$keepinfo" = true -then - case "$pdfinfo" in +if test -n "$keepinfo"; then + case "$pdfinfo" in "not found") - if test $PDFJAM_CALL_NUMBER -eq 0 - then - prattle \ - "The pdfinfo utility was not found, so --keepinfo is ignored." - fi - keepinfo=false - ;; - pdfinfo) - ;; - *) ## $pdfinfo was set in a configuration file - if test ! -x "$pdfinfo" - then - if test $PDFJAM_CALL_NUMBER -eq 0 - then - prattle \ - "No pdfinfo utility at $pdfinfo, so --keepinfo is ignored." - keepinfo=false - fi - fi - ;; - esac - case "$iconv" in + if test "$PDFJAM_CALL_NUMBER" -eq 0; then + prattle \ + "The pdfinfo utility was not found, so --keepinfo is ignored." + fi + keepinfo= + ;; + pdfinfo) ;; + *) ## $pdfinfo was set in a configuration file + if test ! -x "$pdfinfo"; then + if test "$PDFJAM_CALL_NUMBER" -eq 0; then + prattle \ + "No pdfinfo utility at $pdfinfo, so --keepinfo is ignored." + keepinfo= + fi + fi + ;; + esac + case "$iconv" in "not found") - if test $PDFJAM_CALL_NUMBER -eq 0 - then - prattle \ - "The iconv utility was not found, so --keepinfo is ignored." - fi - keepinfo=false - ;; - iconv) - ;; - *) ## $iconv was set in a configuration file - if test ! -x "$iconv" - then - if test $PDFJAM_CALL_NUMBER -eq 0 - then - prattle \ - "No iconv utility at $iconv, so --keepinfo is ignored." - keepinfo=false - fi - fi - ;; - esac + if test "$PDFJAM_CALL_NUMBER" -eq 0; then + prattle \ + "The iconv utility was not found, so --keepinfo is ignored." + fi + keepinfo= + ;; + iconv) ;; + *) ## $iconv was set in a configuration file + if test ! -x "$iconv"; then + if test "$PDFJAM_CALL_NUMBER" -eq 0; then + prattle \ + "No iconv utility at $iconv, so --keepinfo is ignored." + keepinfo= + fi + fi + ;; + esac fi -## A function to check if using non-Cygwin "${latex}" from Cygwin -using_non_cygwin_latex_from_cygwin () { - if [ -z "${__cache__using_non_cygwin_latex_from_cygwin}" ]; then - if uname | grep -q CYGWIN \ - && "${latex}" -version | head -1 | grep -qv Cygwin; then - __cache__using_non_cygwin_latex_from_cygwin=0 - else - __cache__using_non_cygwin_latex_from_cygwin=1 +using_non_cygwin_latex_from_cygwin() { + if [ -z "${__cache__using_non_cygwin_latex_from_cygwin}" ]; then + if uname | grep -q CYGWIN \ + && "${latex}" -version | head -1 | grep -qv Cygwin; then + __cache__using_non_cygwin_latex_from_cygwin=0 + else + __cache__using_non_cygwin_latex_from_cygwin=1 + fi fi - fi - return "${__cache__using_non_cygwin_latex_from_cygwin}" + return "${__cache__using_non_cygwin_latex_from_cygwin}" } ## ## END OF CHECKING THE SETUP @@ -997,44 +922,54 @@ using_non_cygwin_latex_from_cygwin () { ## Use mktemp if possible; otherwise fall back on mkdir, ## with random name to make file collisions less likely. ## -original_umask=$(umask) -umask 177 -if test $PDFJAM_CALL_NUMBER = 0 ## don't repeat this work for secondary calls -then - PDFJAM_TEMP_DIR='' - trap 'IFS="$OIFS"; \ - if test $tidy != false ; then cd "$pwd"; rm -rf "$PDFJAM_TEMP_DIR"; fi; exit 1' \ - 1 2 15 - trap 'IFS="$OIFS"; \ - if test $tidy != false ; then cd "$pwd"; rm -rf "$PDFJAM_TEMP_DIR"; fi' 0 - { - PDFJAM_TEMP_DIR=$( (umask 077 && mktemp -d "$tempfileDir/pdfjam-XXXXXX") 2>/dev/null) && - test -n "$PDFJAM_TEMP_DIR" && test -d "$PDFJAM_TEMP_DIR" - } || { - ## We'll use awk to make random number, for portability - random=$(awk 'END { srand(); printf ("%d\n", rand()*1000000); }' /dev/null) - PDFJAM_TEMP_DIR="$tempfileDir"/pdfjam"$$"-"$random" - (umask 077 && mkdir "$PDFJAM_TEMP_DIR") - } || exit $? -## - export PDFJAM_TEMP_DIR ## so that same dir is used in secondary calls - if test $tidy = false ; then - prattle "Temporary directory for this job is - $PDFJAM_TEMP_DIR" - fi - PDFJAM_MESSAGES_FILE="$PDFJAM_TEMP_DIR"/messages.txt - export PDFJAM_MESSAGES_FILE - ## so that secondary calls can write messages there as well - printf "%s" "$messages" > "$PDFJAM_MESSAGES_FILE" ## initial file contents - messages="" ## we won't be using this variable again! +if test "$PDFJAM_CALL_NUMBER" = 0; then ## don't repeat this work for secondary calls + if test -z "$builddir"; then + PDFJAM_TEMP_DIR='' + tidycode=$([ -n "$tidy" ] && echo ';cd "$pwd";rm -rf "$PDFJAM_TEMP_DIR"') + trap "IFS='$OIFS'$tidycode;exit 1" HUP INT TERM + trap "IFS='$OIFS'$tidycode" EXIT + get_tempfile_dir() { + for i in "$TMPDIR" "$TMP" /tmp /var/tmp .; do + [ -d "$i" ] && [ -w "$i" ] && printf %s "$i" && return + done + return 1 + } + tempfileDir="$(get_tempfile_dir)" || error_exit \ + 'Cannot determine directory for temporary files. + Fix your installation or provide --builddir PATH.' $E_SOFTWARE + ## Try mktemp. If this fails, portably make up a random number. + PDFJAM_TEMP_DIR=$( (umask 077 && mktemp -d "$tempfileDir/pdfjam-XXXXXX") 2>/dev/null) \ + || { + random=$(awk 'END { srand(); printf ("%d\n", rand()*1000000); }' /dev/null) + PDFJAM_TEMP_DIR="$tempfileDir/pdfjam$$-$random" + (umask 077 && mkdir "$PDFJAM_TEMP_DIR") + } && [ -d "$PDFJAM_TEMP_DIR" ] && [ -w "$PDFJAM_TEMP_DIR" ] \ + || error_exit 'Failed to create a temporary directory. + Fix your installation or provide --builddir PATH.' $E_SOFTWARE + if [ -z "$tidy" ]; then + prattle "Temporary directory for this job is + $PDFJAM_TEMP_DIR" + fi + else + tidy= + (umask 077 && mkdir -p "$builddir") || error_exit \ + "Cannot create build directory '$builddir'." $E_USAGE + PDFJAM_TEMP_DIR="$(realpath -- "$builddir")" + fi + export PDFJAM_TEMP_DIR ## so that same dir is used in secondary calls + PDFJAM_MESSAGES_FILE="$PDFJAM_TEMP_DIR"/messages.txt + export PDFJAM_MESSAGES_FILE + ## so that secondary calls can write messages there as well + printf "%s" "$messages" >"$PDFJAM_MESSAGES_FILE" ## initial file contents + messages="" ## we won't be using this variable again! else - PDFJAM_TEMP_DIR="$PDFJAM_TEMP_DIR/file$PDFJAM_CALL_NUMBER" - (umask 077 && mkdir "$PDFJAM_TEMP_DIR") + [ -d "$PDFJAM_TEMP_DIR" ] || error_exit \ + "Temporary directory $PDFJAM_TEMP_DIR missing." $E_SOFTWARE + PDFJAM_TEMP_DIR="$PDFJAM_TEMP_DIR/file$PDFJAM_CALL_NUMBER" + (umask 077 && mkdir -p "$PDFJAM_TEMP_DIR") fi -umask "$original_umask" -## Next is from the Cygwin patch contributed by Lucas if using_non_cygwin_latex_from_cygwin; then - PDFJAM_TEMP_DIR=$(cygpath -w "$PDFJAM_TEMP_DIR") + PDFJAM_TEMP_DIR=$(cygpath -w "$PDFJAM_TEMP_DIR") fi ## ## TEMPORARY DIRECTORY ALL DONE @@ -1046,34 +981,34 @@ fi ## If --batch was used, we'll call pdfjam separately on each input ## file. ## -if test "$batch" = true ; then - if test "$fileSpec" = "" ; then - error_exit "--batch was used, but no PDF/JPG/PNG source file(s) specified" \ - $E_USAGE - fi - if test "$inputFromStdin" = true ; then - error_exit "--batch cannot be used with input from stdin" \ - $E_USAGE - fi - IFS="$newline" - for k in $fileSpec ; do - sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//') - pageSpec=$(printf "%s" $k | sed 's/.*|//') - callNumber=$((PDFJAM_CALL_NUMBER + 1)) - prattle "--" - prattle "Processing file ${callNumber}, '$sourcePath'..." - prattle "Page spec is '$pageSpec'." - sourcePath=$(escape_chars "$sourcePath") - PDFJAM_EFFECTIVE_CALL="$0 $callOptions -- $sourcePath $pageSpec" - export PDFJAM_EFFECTIVE_CALL - PDFJAM_CALL_NUMBER=$callNumber - export PDFJAM_CALL_NUMBER - eval "$PDFJAM_EFFECTIVE_CALL" - ## i.e., call pdfjam again with one input file - done - if [ "$verbose" = "true" ]; then cat "$PDFJAM_MESSAGES_FILE" >&2 ; fi - IFS=$OIFS - exit 0 +if test "$batch" = true; then + if test "$fileSpec" = ""; then + error_exit "--batch was used, but no PDF/JPG/PNG source file(s) specified" \ + $E_USAGE + fi + if test "$inputFromStdin" = true; then + error_exit "--batch cannot be used with input from stdin" \ + $E_USAGE + fi + IFS="$newline" + for k in $fileSpec; do + sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//') + pageSpec=$(printf "%s" "$k" | sed 's/.*|//') + callNumber=$((PDFJAM_CALL_NUMBER + 1)) + prattle "--" + prattle "Processing file ${callNumber}, '$sourcePath'..." + prattle "Page spec is '$pageSpec'." + sourcePath=$(enquote "$sourcePath") + PDFJAM_EFFECTIVE_CALL="$0 $callOptions -- $sourcePath $pageSpec" + export PDFJAM_EFFECTIVE_CALL + PDFJAM_CALL_NUMBER=$callNumber + export PDFJAM_CALL_NUMBER + eval "$PDFJAM_EFFECTIVE_CALL" + ## i.e., call pdfjam again with one input file + done + if [ "$verbose" = "true" ]; then cat "$PDFJAM_MESSAGES_FILE" >&2; fi + IFS=$OIFS + exit 0 fi ## ## END OF THE '--batch' PROCESSING @@ -1088,24 +1023,23 @@ fi ## For secondary calls, the effective call text is already made; ## otherwise we make it here. ## -if test "$PDFJAM_CALL_NUMBER" -gt 0 -then - theCall="$PDFJAM_EFFECTIVE_CALL" +if test "$PDFJAM_CALL_NUMBER" -gt 0; then + theCall="$PDFJAM_EFFECTIVE_CALL" else - filePageSpec="" - IFS="$newline" - for k in $fileSpec ; do - ## Last substitution on next line is needed for silly characters in - ## file names... - sourcePath=$(printf "%s" $k | sed 's/|[^|]*$//') - sourcePath=$(escape_chars "$sourcePath") - pageSpec=$(printf "%s" $k | sed 's/.*|//') - filePageSpec="$filePageSpec$sourcePath $pageSpec " - done - IFS="$OIFS" - theCall="$0 $callOptions -- $filePageSpec" + filePageSpec="" + IFS="$newline" + for k in $fileSpec; do + ## Last substitution on next line is needed for silly characters in + ## file names... + sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//') + sourcePath=$(enquote "$sourcePath") + pageSpec=$(printf "%s" "$k" | sed 's/.*|//') + filePageSpec="$filePageSpec$sourcePath $pageSpec " + done + IFS="$OIFS" + theCall="$0 $callOptions -- $filePageSpec" fi -printf "%s\n%s\n" "cd $pwd" "$theCall" > "$PDFJAM_TEMP_DIR"/call.txt +printf "%s\n%s\n" "cd $pwd" "$theCall" >"$PDFJAM_TEMP_DIR"/call.txt prattle "Effective call for this run of pdfjam:" prattle "$theCall" 1 ## @@ -1121,233 +1055,216 @@ counter=0 ## stdinUnread=true IFS="$newline" -for k in ${fileSpec} -do - counter=$((counter + 1)) - sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//') - pageSpec=$(printf "%s" $k | sed 's/.*|//') - ## Check, though not exhaustively, for problems with the - ## page spec: leading or trailing comma, double comma or - ## double dash, alphabetic characters other than the word "last", - ## braces not paired as {} with nothing inbetween. A fully - ## specified pattern for valid \includepdfmerge page spec would - ## be better here; but life is too short... - if printf "%s" "$pageSpec" | sed 's/last/99/g' | \ - grep '^,.*\|,$\|,,\|--\|[A-Za-z]\|{[^}]\|[^{]}' 1>/dev/null - then - error_exit "invalid page spec $pageSpec" $E_USAGE - fi - case $sourcePath in +for k in ${fileSpec}; do + counter=$((counter + 1)) + sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//') + pageSpec=$(printf "%s" "$k" | sed 's/.*|//') + ## Check, though not exhaustively, for problems with the + ## page spec: leading or trailing comma, double comma or + ## double dash, alphabetic characters other than the word "last", + ## braces not paired as {} with nothing inbetween. A fully + ## specified pattern for valid \includepdfmerge page spec would + ## be better here; but life is too short... + if printf "%s" "$pageSpec" | sed 's/last/99/g' \ + | grep '^,.*\|,$\|,,\|--\|[A-Za-z]\|{[^}]\|[^{]}' 1>/dev/null; then + error_exit "invalid page spec $pageSpec" $E_USAGE + fi + case $sourcePath in /dev/stdin) - uniqueName="$PDFJAM_TEMP_DIR"/stdin.pdf - if test "$stdinUnread" = true - then - if tty -s ; then - error_exit \ - "tty is connected to stdin, no PDF/JPG/PNG file found" \ - $E_NOINPUT + uniqueName=stdin.pdf + if test "$stdinUnread" = true; then + if tty -s; then + error_exit \ + "tty is connected to stdin, no PDF/JPG/PNG file found" \ + $E_NOINPUT + fi + cat >"$PDFJAM_TEMP_DIR/$uniqueName" + stdinUnread=false fi - cat > "$uniqueName" - stdinUnread=false - fi - ;; + ;; *) - pdfName=$(basename "$sourcePath") - sourceDir=$(dirname "$sourcePath") ## zsh on Mac OS 10.5 chokes here - cd "$sourceDir" || exit 1 ## just to get the full path - sourceDir=$(pwd) - cd "$pwd" || exit 1 - sourceFullPath="$sourceDir"/"$pdfName" - uniqueName="source-$counter.pdf" - uniqueName="$PDFJAM_TEMP_DIR"/"$uniqueName" - ## Next is from the Cygwin patch contributed by Lucas - if using_non_cygwin_latex_from_cygwin; then - cp "$sourceFullPath" "$uniqueName" - else - ln -s "$sourceFullPath" "$uniqueName" - fi - ;; - esac - filePageList="$filePageList","$uniqueName","$pageSpec" + pdfName=$(basename -- "$sourcePath") + sourceDir=$(dirname -- "$sourcePath") ## zsh on Mac OS 10.5 chokes here + cd "$sourceDir" || exit 1 ## just to get the full path + sourceDir=$(pwd) + cd "$pwd" || exit 1 + sourceFullPath="$sourceDir/$pdfName" + uniqueName="source-$counter.pdf" + if using_non_cygwin_latex_from_cygwin; then + cp -f "$sourceFullPath" "$PDFJAM_TEMP_DIR/$uniqueName" + else + ln -fs "$sourceFullPath" "$PDFJAM_TEMP_DIR/$uniqueName" + fi + ;; + esac + filePageList="$filePageList,$uniqueName,$pageSpec" done IFS="$OIFS" -filePageList=$(printf "%s" "$filePageList" | \ - sed 's/^,//') ## remove leading comma +filePageList="${filePageList#,}" +if using_non_cygwin_latex_from_cygwin; then + filePageList=$(printf %s "$filePageList" | tr \\\\ /) +fi + +## +## Finally enter build directory +## +cd "$PDFJAM_TEMP_DIR" || exit 1 + ## ## Do the pdfinfo stuff (if relevant)... ## -select_pdfinfo () { - printf '%s' "$2" | \ - grep -e "^$1:" | \ - sed -e 's/^'"$1"':\s*//' -} -echo_hex_iconv_utf16be () { - printf '%s' "$1" | \ - "$iconv" -f UTF-8 -t UTF-16BE | \ - od -An -v -tx1 | \ - tr -d '[:space:]' -} -echo_pdfinfodata () { - if [ -n "$2" ]; then - TMPA=$(echo_hex_iconv_utf16be "$2") - printf '%s' "/$1 <feff${TMPA}>" - fi +select_pdfinfo() { + ## pdfinfo fields are 17 chars wide. + ## This implementation preserves leading spaces + printf %s "$2" | awk "/^$(printf %-17s "$1:")/{print substr(\$0,18)}" } - -if test "$keepinfo" = true ; then - prattle "Calling ${pdfinfo}..." - PDFinfo=$(pdfinfo -enc UTF-8 "$uniqueName") - pdftitl=$(select_pdfinfo 'Title' "$PDFinfo") - pdfauth=$(select_pdfinfo 'Author' "$PDFinfo") - pdfsubj=$(select_pdfinfo 'Subject' "$PDFinfo") - pdfkeyw=$(select_pdfinfo 'Keywords' "$PDFinfo") +if test -n "$keepinfo"; then + prattle "Calling ${pdfinfo}..." + PDFinfo=$(pdfinfo -enc UTF-8 "$uniqueName") + pdftitl=$(select_pdfinfo 'Title' "$PDFinfo") + pdfauth=$(select_pdfinfo 'Author' "$PDFinfo") + pdfsubj=$(select_pdfinfo 'Subject' "$PDFinfo") + pdfkeyw=$(select_pdfinfo 'Keywords' "$PDFinfo") fi -echo_iconv_from_enc () { - printf '%s' "$2" | \ - "$iconv" -f "$1" -t UTF-8 + +echo_iconv_from_enc() { + printf %s "$1" | "$iconv" -f "$enc" -t UTF-8 } -if test -n "$pdfTitle" ; then - pdftitl=$(echo_iconv_from_enc "$enc" "$pdfTitle") +if test -n "${pdftitle+X}"; then + pdftitl=$(echo_iconv_from_enc "${pdftitle-}") fi -if test -n "$pdfAuthor" ; then - pdfauth=$(echo_iconv_from_enc "$enc" "$pdfAuthor") +if test -n "${pdfauthor+X}"; then + pdfauth=$(echo_iconv_from_enc "${pdfauthor-}") fi -if test -n "$pdfSubject" ; then - pdfsubj=$(echo_iconv_from_enc "$enc" "$pdfSubject") +if test -n "${pdfsubject+X}"; then + pdfsubj=$(echo_iconv_from_enc "${pdfsubject-}") fi -if test -n "$pdfKeywords" ; then - pdfkeyw=$(echo_iconv_from_enc "$enc" "$pdfKeywords") +if test -n "${pdfkeywords+X}"; then + pdfkeyw=$(echo_iconv_from_enc "${pdfkeywords-}") fi -## Converting to PDF string -raw_pdftitl=$(echo_pdfinfodata 'Title' "$pdftitl") -raw_pdfauth=$(echo_pdfinfodata 'Author' "$pdfauth") -raw_pdfsubj=$(echo_pdfinfodata 'Subject' "$pdfsubj") -raw_pdfkeyw=$(echo_pdfinfodata 'Keywords' "$pdfkeyw") - -## -## Now set up the files for latex... -## -fileName="$PDFJAM_TEMP_DIR"/a -texFile="$fileName".tex -msgFile="$fileName".msgs -tempFile="$PDFJAM_TEMP_DIR"/temp.tex -## Next is adapted from the Cygwin patch sent by Lucas -if using_non_cygwin_latex_from_cygwin; then - filePageList=$(echo "$filePageList" | sed 's~\\~/~g') -fi -(cat <<EndTemplate -\batchmode -\documentclass[$documentOptions]{article} -\usepackage{color} \definecolor{bgclr}{RGB}{$pagecolor} \pagecolor{bgclr} -\usepackage[$papersize]{geometry} -\usepackage[utf8]{inputenc} +echo_hex_iconv_utf16be() { + printf '%s' "$1" \ + | "$iconv" -f UTF-8 -t UTF-16BE \ + | od -An -v -tx1 \ + | tr -d '[:space:]' +} +addto_pdfinfo() { + if [ -n "$2" ]; then + ## Convert to PDF string and append + raw_pdfinfo="$raw_pdfinfo + /$1 <feff$(echo_hex_iconv_utf16be "$2")> %" + fi +} +raw_pdfinfo= +addto_pdfinfo Title "$pdftitl" +addto_pdfinfo Author "$pdfauth" +addto_pdfinfo Subject "$pdfsubj" +addto_pdfinfo Keywords "$pdfkeyw" +if [ -n "$raw_pdfinfo" ]; then + raw_pdfinfo=' \ifdefined\luatexversion% LuaLaTeX \protected\def\pdfinfo{\pdfextension info} \fi \ifdefined\XeTeXversion% XeLaTeX - \protected\def\pdfinfo#1{\AtBeginDvi{\special{pdf:docinfo << #1 >>}}} + \protected\def\pdfinfo#1{\AddToHook{shipout/firstpage}{\special{pdf:docinfo << #1 >>}}} \fi \ifdefined\pdfinfo% - \pdfinfo{% - $raw_pdftitl % - $raw_pdfauth % - $raw_pdfsubj % - $raw_pdfkeyw % + \pdfinfo{%'"$raw_pdfinfo"' }% -\fi -\usepackage{pdfpages} -EndTemplate - ) > "$texFile" -if test -z "$pagecolor"; then ## color package is not needed - cp "$texFile" "$tempFile" - sed '/\\\usepackage.*{color}/d' "$tempFile" > "$texFile" - rm "$tempFile" +\fi' fi + +## Apply $pagecolor if set +if [ -n "$pagecolor" ]; then + colorcode=" +\\usepackage{color} +\\definecolor{bgclr}{RGB}{$pagecolor} +\\pagecolor{bgclr}" +else + colorcode= +fi +## +## Now set up the LaTeX file +## +fileName="$(pwd)/a" (cat <<EndTemplate -$preamble -$shortedge +\batchmode +\documentclass[$documentOptions]{article}$colorcode +\usepackage[$papersize]{geometry} +\usepackage[utf8]{inputenc}$raw_pdfinfo +\usepackage{pdfpages}$otheredge$preamble \begin{document} \includepdfmerge[$miscOptions]{$filePageList} \end{document} EndTemplate - ) >> "$texFile" +) >"$fileName.tex" ## ## INPUT FILES ARE ALL READY ## ######################################################################### ## -## RUN LATEX AND COPY THE RESULTING PDF FILE +## RUN LATEX AND COPY THE RESULTING PDF FILE ## if [ "$runs" -eq 1 ] ; then prattle "Calling ${latex}..." else prattle "Calling ${latex} $runs times..." fi -cd "$PDFJAM_TEMP_DIR" || exit 1 failureText=\ "FAILED. -The call to $latex resulted in an error. -If '--no-tidy' was used, you can examine the -log file at - $fileName.log +The call to $latex resulted in an error." +if [ -n "$tidy" ]; then + failureText="$failureText +Rerun with '--no-tidy' or '--builddir PATH' to diagnose the problem." +else + failureText="$failureText +You can examine the build directory at + $(pwd) to try to diagnose the problem." +fi i=1 -while [ "$i" -le "$runs" ] ; do - "$latex" "$texFile" > "$msgFile" || { - prattle "$failureText" - error_exit "Run $i: Output file not written" $E_SOFTWARE - } - i=$((i + 1)) +while [ "$i" -le "$runs" ]; do + "$latex" "$fileName.tex" >"$fileName.msgs" || { + prattle "$failureText" + error_exit "Run $i: Output file not written" $E_SOFTWARE + } + i=$((i + 1)) done cd "$pwd" || exit 1 -if test -f "$fileName".pdf ## if LaTeX didn't choke -then - ## Checks on output file path: - if test -d "$outFile" ## outfile is a directory - then - if test "$sourcePath" = /dev/stdin - then - error_exit \ - "--outfile cannot be a directory when input is stdin" \ - $E_USAGE - fi - if test ! -w "$outFile" - then - error_exit \ - "FAILED: no write permission on ${outFile}." \ - $E_OSFILE - fi - separator="-" - if test "$pageSpec" != "-" - then - separator=-"$pageSpec"- +if test -f "$fileName".pdf; then ## if LaTeX didn't choke + ## Checks on output file path: + if test -d "$outFile"; then ## outfile is a directory + if test ! -w "$outFile"; then + error_exit \ + "FAILED: no write permission on ${outFile}." \ + $E_OSFILE + fi + separator="-" + if test "$pageSpec" != "-"; then + separator=-"$pageSpec"- + fi + outFile=$(printf "%s" "$outFile" | sed 's/\/$//') ## delete any trailing slash + pdfName=$(basename -- "$sourcePath") + pdfName=$(printf "%s" "$pdfName" | + sed 's/\.[pP][dD][fF]$//') ## strip extension + pdfName="$pdfName$separator$suffix".pdf + outFile="$outFile/$pdfName" fi - outFile=$(printf "%s" "$outFile" | sed 's/\/$//') - ## (delete any trailing slash) - pdfName=$(basename "$sourcePath") - pdfName=$(printf "%s" "$pdfName" | \ - sed 's/\.[pP][dD][fF]$//') ## strip extension - pdfName="$pdfName$separator$suffix".pdf - outFile="$outFile"/"$pdfName" - fi fi -if test -f "$outFile" && test ! -w "$outFile" - ## file exists and we can't over-write it -then - error_exit "no write permission at ${outFile}" $E_CANTCREATE +if test -f "$outFile" && test ! -w "$outFile"; then + ## file exists and we can't over-write it + error_exit "no write permission at ${outFile}" $E_CANTCREATE fi #fileSize=$(wc -c < "$fileName.pdf" | sed 's/^\ *//') ## Avoid explicit output to /dev/stdout. if test "$outFile" = "/dev/stdout" \ - && cat "$fileName".pdf 2> /dev/null \ - || cat "$fileName".pdf > "$outFile" 2>/dev/null -then - prattle "Finished. Output was written to '${outFile}'." -else - error_exit "cannot write output at ${outFile}" $E_CANTCREATE + && cat "$fileName".pdf 2> /dev/null \ + || cat "$fileName".pdf > "$outFile" 2>/dev/null +then prattle "Finished. Output was written to '${outFile}'." +else error_exit "cannot write output at ${outFile}" $E_CANTCREATE fi -if [ "$PDFJAM_CALL_NUMBER" = "0" ] && [ "$verbose" = "true" ] -then cat "$PDFJAM_MESSAGES_FILE" >&2 +if [ "$PDFJAM_CALL_NUMBER" = "0" ] && [ "$verbose" = "true" ]; then + cat "$PDFJAM_MESSAGES_FILE" >&2 fi exit 0 ## diff --git a/support/pdfjam/man/pdfjam.1 b/support/pdfjam/man/pdfjam.1 new file mode 100644 index 0000000000..c5a80aeff2 --- /dev/null +++ b/support/pdfjam/man/pdfjam.1 @@ -0,0 +1,50 @@ +.TH "pdfjam" "1" "18 November 2020" "" "" +.SH "NAME" +pdfjam \- A shell script for manipulating PDF files +.SH "SYNOPSIS" +.PP +pdfjam [OPTION [OPTION] \&.\&.\&.] [SRC [PAGESPEC] [SRC [PAGESPEC]] \&.\&.\&.] +.PP +.SH "DESCRIPTION" +.PP +pdfjam provides a front end to most capabilities of the +"pdfpages" package (by Andreas Matthias) of pdflatex. +Detailed information can be found via +"pdfjam --help", and also in the web page mentioned below\&. +.PP +A working installation of pdflatex, with +the pdfpages package, is required\&. +.PP +The pdfjam script is distributed as (the main) part of the pdfjam package. +The homepage of pdfjam is at https://github.com/pdfjam/pdfjam\&. +.PP +.SH "SETUP" +.PP +See https://github.com/pdfjam/pdfjam +.PP +.SH "CONFIGURATION FILES" +.PP +Configuration of the PDFjam utilities involves specifying the location of +pdflatex, the location of temporary files, specification of default page size, +etc. This is done in a block of lines near the top of the pdfjam script; +settings made there are over-ridden by any that are found at a site-wide +configuration file (at /etc/pdfjam.conf, /usr/share/etc/pdfjam.conf, +/usr/local/share/pdfjam.conf, or /usr/local/etc/pdfjam.conf), which in turn are +over-ridden by any that are found in a user-defaults file at ~/.pdfjam.conf\&. +.PP +.SH "LIMITATIONS AND BUGS" +.PP +pdfjam does not work with encrypted PDF files, and does not +preserve hyperlinks. +.PP +Please report bugs! --- either at GitHub or by email, see +https://github.com/pdfjam/pdfjam\&. +.PP +.SH "LICENSE" +.PP +pdfjam is distributed under the GNU public license. +.PP +.SH "AUTHOR" +.PP +The pdfjam package was written by David Firth and is +maintained by Reuben Thomas and Markus Kurtz. diff --git a/support/pdfjam/man1/pdfjam.1 b/support/pdfjam/man1/pdfjam.1 deleted file mode 100644 index 16b9c0af0d..0000000000 --- a/support/pdfjam/man1/pdfjam.1 +++ /dev/null @@ -1,53 +0,0 @@ -.TH "pdfjam" "1" "18 November 2020" "" "" -.SH "NAME" -pdfjam \- A shell script for manipulating PDF files -.SH "SYNOPSIS" -.PP -pdfjam [OPTION [OPTION] \&.\&.\&.] [SRC [PAGESPEC] [SRC [PAGESPEC]] \&.\&.\&.] -.PP -.SH "DESCRIPTION" -.PP -pdfjam provides a front end to most capabilities of the -"pdfpages" package (by Andreas Matthias) of pdflatex. -Detailed information can be found via -"pdfjam --help", and also in the web page mentioned below \&. -.PP -A working installation of pdflatex, with -the pdfpages package, is required\&. -.PP -The pdfjam script is distributed as (the main) part of the pdfjam package. The homepage of pdfjam is at -https://github.com/rrthomas/pdfjam \&. -.PP -.SH "SETUP" -.PP -See https://github.com/rrthomas/pdfjam -.PP -.SH "CONFIGURATION FILES" -.PP -Configuration of the PDFjam utilities -involves specifying the location of pdflatex, -the location of temporary files, specification of default page size, -etc. This is done in a block of lines near the top of the pdfjam script; -settings made there are over-ridden by any that -are found at a site-wide configuration file -(at /etc/pdfjam.conf, -/usr/share/etc/pdfjam.conf, /usr/local/share/pdfjam.conf, or -/usr/local/etc/pdfjam.conf), which -in turn are over-ridden by any that are found in a user-defaults -file at ~/.pdfjam.conf\&. -.PP -.SH "LIMITATIONS AND BUGS" -.PP -pdfjam does not work with encrypted PDF files, and does not -preserve hyperlinks. -.PP -Please report bugs! --- either at GitHub or by email, see -https://github.com/rrthomas/pdfjam \&. -.PP -.SH "LICENSE" -.PP -pdfjam is distributed under the GNU public license. -.PP -.SH "AUTHOR" -.PP -The pdfjam package was written by David Firth and is maintained by Reuben Thomas. diff --git a/support/pdfjam/pdfjam.conf b/support/pdfjam/pdfjam.conf index c1a14a1266..e3468192d3 100644 --- a/support/pdfjam/pdfjam.conf +++ b/support/pdfjam/pdfjam.conf @@ -1,20 +1,20 @@ ############################################################### ## -## This is a _sample_ 'pdfjam.conf' file. +## This is a _sample_ 'pdfjam.conf' file. ## -## Edit lines below (and un-comment them as necessary) to -## override settings made in the 'pdfjam' script itself. +## Edit lines below (and un-comment them as necessary) to +## override settings made in the 'pdfjam' script itself. ## (As distributed, the settings made in this file are the ## same as those made in the 'pdfjam' script.) ## -## A file in this format can be used site-wide (as a file named -## "pdfjam.conf", in an appropriate location), or for a specific -## user (as "~/.pdfjam.conf"). User-specific settings override -## site-wide settings. +## A file in this format can be used site-wide (as a file named +## "pdfjam.conf", in an appropriate location), or for a specific +## user (as "~/.pdfjam.conf"). User-specific settings override +## site-wide settings. ## -## See 'pdfjam --help' for details, including where to put +## See 'pdfjam --help' for details, including where to put ## your edited version of this file; or see the file README.md at -## https://github.com/rrthomas/pdfjam +## https://github.com/pdfjam/pdfjam ## ############################################################### ## @@ -66,7 +66,7 @@ keepinfo='false' ## overridden by '--keepinfo' in the call ## ## Should the '--checkfiles' option be used by default? checkfiles='false' ## overridden by '--checkfiles' in the call; -# checkfiles='true' ## the alternative +# checkfiles='true' ## the alternative ## ############################################################### ## @@ -78,7 +78,7 @@ checkfiles='false' ## overridden by '--checkfiles' in the call; ## ############################################################### ## -## DEFAULT PATH FOR THE --outfile OPTION +## DEFAULT PATH FOR THE --outfile OPTION ## outFile="$pwd" ## the obvious default # outFile="$HOME/Documents" ## (another possibility, perhaps) diff --git a/support/texshop/README.txt b/support/texshop/README.txt index 8e09d03fb5..8c6ef022d2 100644 --- a/support/texshop/README.txt +++ b/support/texshop/README.txt @@ -7,4 +7,4 @@ The main author is Richard Koch, koch@uoregon.edu, with supporting contributions Consult the program web site, https://pages.uoregon.edu/koch/texshop/texshop.html, for full source code, an extensive Changes document, and other information. -The current version, 5.47, was released on November 6, 2024.
\ No newline at end of file +The current version, 5.48, was released on December 17, 2024.
\ No newline at end of file diff --git a/support/texshop/texshop547.html b/support/texshop/texshop547.html deleted file mode 100644 index f60830f7ad..0000000000 --- a/support/texshop/texshop547.html +++ /dev/null @@ -1,31 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <title>TeXShop</title> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -</head> - -<body> - - -<!-- main content --> -<div id="main"> - -Version 5.47 has a few minor changes: -<ul> -<p><li> A new version of Typst was released in October, 2024. This version has improved package management -that induces changes in TeXShop's support for the program. See ~/Library/TeXShop/Engines/Inactive/Typst for details. -<p><li> When TeXShop saved annotations with the option key down so only annotated pages were saved, annotations on these pages were duplicated. This is fixed. -<p><li> When the Experiment window is active, command-1 now switches between its source and preview windows. -<p><li> In Single Window Mode with line numbers visible in the Edit Panel, moving the split bar to the extreme left of the window so only the Preview Panel was visible caused a crash. This is fixed. -<p><li> The manual has new material on Typst and Experiments. -</ul> - -<p> -<p> -</div> - - -</body> -</html>
\ No newline at end of file diff --git a/support/texshop/texshop548.html b/support/texshop/texshop548.html new file mode 100644 index 0000000000..88cf902c40 --- /dev/null +++ b/support/texshop/texshop548.html @@ -0,0 +1,52 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>TeXShop</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +</head> + +<body> + + +<!-- main content --> +<div id="main"> + +Version 5.48 has one noticeable change and a few additional items: +<ul> +<p><li> Apple Intelligence in Sequoia 15.2 introduces a new feature called Math Expression Completion. If a user types "e =" in an editor, the editor automatically adds "2.718"; if a user types "x + \pi =", the editor adds "3.14159". This addition is almost never appropriate in TeX source code, so TeXShop 5.48 has a hidden preference item to turn it off or on. By default it is off. To turn it on, issue the command below in Terminal, where the final integer is positive. When this integer is zero, the feature will be turned off. +<pre> + defaults write TeXShop MathExpressionCompletion 1 +</pre> +The feature can also be turned off by turning Apple Intelligence off in Apple's System Settings, but this is overkill. For instance, Writing Tools can be helpful when editing paragraphs with TeXShop. + +<p><li> A user discovered a bug in the Macro command "Close Begin/End". The word "is" occurs twice in line 147, which reads "tell me to to set environment_name to do shell script". This is fixed in version 5.48, but updating the program does not update the user's Macros since they can be modified by the user. +If you might use this macro, edit this item yourself using "Open Macro Editor" at the top of the "Macros" menu. + +<p><li> George Grätzer recently uploaded an interesting style file to CTAN and TeX Live named +"Gratzer-Color-Scheme". Adding the line below to the header of a LaTeX, XeLaTeX, or LuaLaTeX document +will cause all theorems to be printed in red, all lemmas and propositions to be printed in blue, and all +definitions to be printed in green. Give it a try. +<pre> + \usepackage{Gratzer-Color-Scheme} +</pre> + + +<p><li> The TeXShop help menu has an item titled "First Steps with General Typesetting". The document has a section toward the end showing how to type Arabic, Hebrew, and Japanese text in source files using XeLaTeX. The code selecting a Hebrew font broke in a recent TeX Live update, and the current document fixes this problem. + +<p><li> A ConTeXt user requested that TeXShop define the extensions lmt, mkiv, mkvi, mkxl, mklx, and tuc +because ConTeXt can produce files with these extensions and he wanted to examine such files using Quick Look. I was reluctant to add so many new extensions to TeXShop for this very special purpose. Therefore I wrote a small program named "Helper" which defines the extensions. Installing that program causes Quick Look to display files with these extensions. Helper contains a primitive editor, so clicking a file with one of these extensions opens the file in Helper. + +<p> This Helper program is available on my web site, <A HREF="https://pages.uoregon.edu/koch/"> https://pages.uoregon.edu/koch/ </A>. The site also contains the complete source code for Helper, so a user with a similar problem can extend Helper to deal with additional extensions. This is not a common problem and most users will ignore Helper. + +<p><li> Latexmk is updated to version 4.86. + +</ul> + +<p> +<p> +</div> + + +</body> +</html>
\ No newline at end of file |