Forum Feature requests

multiple input files

jim_albright
I would like a switch on command line like -l for the file name that contains a list of input files. I will have 27 or 66 books to combine into one output file.

Jim Albright
Wycliffe Bible Translators

oliof
Would it be sufficient to write a batch file for this?
jim_albright
I don't think so. I am concerned about the possible limit to the size of the command line. Some programs have a limit to the size of the command line and if I do this for 66 file names the command line could exceed 1000 characters.

I have worked with other programs that allow input file names that are space delimited as Prince does but also allow an input file containing the list of file names. That is a convenient way of handling the situation. And from a programming standpoint it isn't difficult to do.

Jim Albright
Wycliffe Bible Translators

jim_albright
<?xml version="1.0" encoding="utf-8"?>
<xi:part xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="WBT.acf.SLCD.dict.2001-front_matter.xhtml"/>
<xi:include href="WBT.acf.SLCD.dict.2001-Preface.xhtml"/>
<xi:include href="WBT.acf.SLCD.dict.2001-Introduction.xhtml"/>
<xi:include href="WBT.acf.SLCD.dict.2001-WritingSystem.xhtml"/>
<xi:include href="WBT.acf.SLCD.dict.2001-Dictionary1.xhtml"/>
<xi:include href="WBT.acf.SLCD.dict.2001-Appendix1.xhtml"/>
</xi:part>


Found how to do it. This file loads all the others.

Jim Albright
Wycliffe Bible Translators

mikeday
Prince 8.1 is now available, and includes a new -l / --input-list command-line that allows you to read a list of files to process from another file.
Johann
We tried the --input-list option for the first time, and got the error: no output filename specified!

After reading the manual we realized that this options does not generate a PDF file for every file in the input list (what we expected), but merges all inputs into a single PDF!

Would it be possible to expand the behavior of this option, such that a PDF file is generated for each list entry in the case no output file is specified?

- - -
Johann

mikeday
You can do this from outside Prince, for example on Linux you can use this shell script:
for file in *.html ; do
    prince $file
done
Johann

Thanks, Mike!

Yes, it is trivial in Linux, but we have Windows and our use case is:
We have a tool that generates (one or more) XHTML files and lists the URLs in a text file (separated with Unix line endings). It is not so trivial to call Prince for every token/line in a text file in a portable way in a windows dos box.
Currently we use a Java application that does the Prince calls, but it would be fine if Prince could handle this.

- - -
Johann

mikeday
Perhaps in the future we can extend the Prince JavaScript API to support these use cases, that might be more flexible than supporting every possible combination of input options. :)
bosscube
I know this thread is almost 6 years old, but it still shows up in Google when you search for batch process with prince. For anyone interested, you can use the method above in Linux, and the following will work just fine in a Windows batch script. E.g. create a text file, name it something like html-to-pdf.bat and paste the following inside:

for %%f in (*.html) do prince %%f -o %%f.pdf


Stick the html-to-pdf.bat file in the folder with the html files you want to convert. Then, open the command prompt in that folder and the script by simply typing
html-to-pdf.bat
and pressing enter.

I hope this helps someone.

EDIT: This assumes you have the prince binary in your PATH. If you don't, you will have to replace "prince" in the script above with the full path to your prince binary. E.g:

for %%f in (*.html) do C:\some\folder\location\prince-12.4-win64\bin\prince %%f -o %%f.pdf
mikeday
Thanks!