[GNC] [GNC-dev] PDF Reports

Adrien Monteleone adrien.monteleone at lusfiber.net
Thu Mar 19 09:29:13 EDT 2020


Michael,

Out of curiosity, does the built-in print to file (as PDF) or ‘Make PDF' features of GnuCash not produce a proper document for you?

Does opening the HTML in a browser or other app not create a proper document when saving to PDF via the MacOS print facility?

Also, for anyone investigating this, two additional excellent utilities are `html2pdf` or `wkhtmlpdf`.

Regards,
Adrien

> On Mar 19, 2020 w12d79, at 3:28 AM, Michael Hendry <hendry.michael at gmail.com> wrote:
> 
> Morning, Alan.
> 
> I’m currently working through a series of reports which _will_ need to be examined by an auditor, and have been refining the reports’ configuration settings as I go.
> 
> To ensure that I’ve converted all the HTML files to PDF, I’ve written the shell script below which may be helpful to other Mac users as it stands, or for other OSes with appropriate modification.
> 
> Regards,
> 
> Michael
> 
> 
> #!/bin/sh
> # h2p.sh
> #
> # Michael Hendry
> # 19th March 2020
> #
> # Convert all .html files in current directory to .pdf files in subdirectory ./pdf (created if necessary)
> #
> # Requires “htmldoc” - see https://formulae.brew.sh/formula/htmldoc
> #
> # First make a directory for the converted files (the -p means it will create the whole path if necessary)
> mkdir -p ./pdf
> # Now loop through all .html files and convert to pdf
> for f in *.html
> do # Note that $f has to be enclosed in quotation marks, to cope with spaces in filenames.
> 	txt=${f%.*}
> 	htmldoc --charset utf-8 --webpage --header ... -f  ./pdf/"$txt".pdf "$f"
> done
> #
> # Alternatively, the following command con be run from the command-line:
> #
> # mkdir -p ./pdf ;for f in *.html;do txt=${f%.*}; htmldoc --charset utf-8 --webpage --header ... -f  ./pdf/"$txt".pdf "$f" ;done




More information about the gnucash-user mailing list