fisharebest / webtrees

Online genealogy
https://webtrees.net
GNU General Public License v3.0
432 stars 294 forks source link

Header and footer on PDF reports #3530

Open sevtor opened 3 years ago

sevtor commented 3 years ago

Recently I decided to share my findings from the family research with family members that don't want to login to webtrees and then click on links. The solution is of course to generate PDF reports that I can distribute. However, these are not formatted as I would prefer.

The xml descriptions that are used to generate reports contain header, body and footer segments. When html reports are generated the header and footer segments are used, but for pdf reports they are totally ignored. (A change that I recently suggested at least gives the document title, from version 2.0.7.)

Now I have suggestions to use the header segment also for PDF reports, see app/Report/PdfRenderer.php. The footer segment is more difficult to use but is totally similar in all reports. Therefore a custom footer is created that gives the wanted information. Formatting must be supplied according to Tcpdf rules, see tcpdf.org/examples/example_003/ . Thus TcpdfWrapper.php must contain Header and Footer functions. The result is headers and footers that are very similar to those in html reports. Examples are given in the files header-and-footer-(html,pdf)-(before,after).(png,pdf). The pedigree reports shows that the line under the header cuts through the pedigree chart before the change.

Report specifications

The reports are defined in xml files which are stored in resources/xml/. They contain definitions of information to put in the page headers of pdf reports. I find some of these headers too general, e.g. "Related families" which can contain ancestors, descendants, or just a closer family. My suggestion is to give the central person and the selection, e.g. "Seved Torstendahl: Ancestors" or "Seved Torstendahl: Parents and siblings". Examples are given in pedigree-report-(before,after).pdf and individual-ext-report-(before,after).pdf.

Some reports (individual-ext-report.xml and relative-ext-report.xml) have options to select different views. Changes are included to set the header information to selected person and which view was selected. Some reports have tables and the table headers were part of the page headers. That is not easily reproduced and thus the table header is moved to the first page only (relative-ext-report.xml).

References to footnotes may be included if sources are selected. However the numbers are generated one space away from the name (or fact, ...) and close to the following word. I made adjustments to move the footnote reference closer to the preceding word and away from the next. The result can be seen in the images footnote-before.png and footnote-after.png.

I also want to present all my findings which are normally included in different notes. Therefore the individual_ext_report.xml has been modified to include much more information.

I think that all these modifications are of general interest and should be included in future releases. Patch files are also included.

header-and-footer-html-before.pdf: header-and-footer-html-before

header-and-footer-html-after.pdf: header-and-footer-html-after

header-and-footer-pdf-before.pdf header-and-footer-pdf-after.pdf

pedigree_report-before.pdf pedigree_report-after.pdf

individual_ext_report-before.pdf individual_ext_report-after.pdf

Patch file and some examples: webtrees-change-suggestion1.zip

DaPoHou commented 3 years ago

Thank you very much! Looking forward to more research on the report module.

fisharebest commented 3 years ago

I have merged some of the changes into the master branch.

I'm not sure about some of the others.

The changes to the NOTE handling doesn't seem to work with shared-notes. I don't understand the header/footer code well enough to review it.

I have converted the rest of the changes into a pull request #3716, to make it easier to discuss them.