Question
Header and footer on PDF reports
- sevtor
-
Topic Author
- Offline
- New Member
-
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).
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.
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Please Log in or Create an account to join the conversation.
- xiao
-
- Offline
- Junior Member
-
- Posts: 220
Please Log in or Create an account to join the conversation.
- sevtor
-
Topic Author
- Offline
- New Member
-
I also have a lot of improvements to the report generator if anyone is interested.
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Please Log in or Create an account to join the conversation.
- xiao
-
- Offline
- Junior Member
-
- Posts: 220
Please Log in or Create an account to join the conversation.
- xiao
-
- Offline
- Junior Member
-
- Posts: 220
Hello, I visited your demo and the effect is very good. It would be perfect if some garbled characters that are not English characters in the generated PDF can be solved.Yes, I have solved this.
I also have a lot of improvements to the report generator if anyone is interested.
Please Log in or Create an account to join the conversation.
- xiao
-
- Offline
- Junior Member
-
- Posts: 220
Please Log in or Create an account to join the conversation.
- HerzScheisse
-
- Offline
- New Member
-
you need to unpack this file and open "webtrees-2.0.7.patch" file with a text editor (I used VSCode)
then you need to apply the changes stated there..
take attention to the lines added (+) and lines removed(-)
and as always... backup your data first...
webtrees 2.1.20 - modules: all vesta, faces, legal notice, privacy policy, fancy treeview, fancy research links
Linux Ubuntu | PHP 8.3.3 | MariaDB 10.5.23 | rewrite_urls="1"
My genealogy site: www.eisold.family
Please Log in or Create an account to join the conversation.
- xiao
-
- Offline
- Junior Member
-
- Posts: 220
Thank you very much. I have seen "webtrees-2.0.7.patch" in the compressed package,it seems that the patch is included in the first post (last of the attachments)
you need to unpack this file and open "webtrees-2.0.7.patch" file with a text editor (I used VSCode)
then you need to apply the changes stated there..
take attention to the lines added (+) and lines removed(-)
and as always... backup your data first...
but the file seems to be damaged.
Please Log in or Create an account to join the conversation.
- bertkoor
-
- Offline
- Platinum Member
-
- Greetings from Utrecht, Holland
stamboom.BertKoor.nl runs on webtrees v2.2.1
Please Log in or Create an account to join the conversation.
- xiao
-
- Offline
- Junior Member
-
- Posts: 220
Hi, when I use the "family-tree" module, I get the following error. How can I solve it?Header and footer on PDF reports
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).
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.
Please Log in or Create an account to join the conversation.
- hermann
-
- Offline
- Elite Member
-
Second option: I assume that you installed the current "master" version of this module, but you should always install the released version of a custom module (see github.com/miqrogroove/family-tree-home/releases ). Try to install the last released version.
Hermann
Designer of the custom module "Extended Family"
webtrees 2.2.1 (all custom modules installed, PHP 8.3.12, MariaDB 10.6) @ ahnen.hartenthaler.eu
Please Log in or Create an account to join the conversation.
- sevtor
-
Topic Author
- Offline
- New Member
-
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Please Log in or Create an account to join the conversation.
- sevtor
-
Topic Author
- Offline
- New Member
-
Unfortunately they are not included in the patch file I submitted earlier. I will prepare a patch file as soon as possible!
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Please Log in or Create an account to join the conversation.
- sevtor
-
Topic Author
- Offline
- New Member
-
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Please Log in or Create an account to join the conversation.
- xiao
-
- Offline
- Junior Member
-
- Posts: 220
I'm very sorry, files in .patch format are a new thing to me. I have never been exposed to files with this kind of suffix. Can you publish a complete module package?A patch file for ReportParserGenerate.php
In addition, I saw on your demo site that if I export "Pedigree", the Chinese characters there are garbled (because my system is Chinese, your demo defaults to Chinese, and the non-English characters in the exported pdf are garbled) ,As shown below.
I think it may be a font problem. I remember that TCPDF has a font named "cid0jp" that supports Chinese (/TCPDF-main/examples/example_038.php).
I checked the code for generating PDF by webtrees and found that my PHP ability cannot solve the problem of garbled Chinese fonts.
Thank you very much for your reply.
Wish all the best.
Please Log in or Create an account to join the conversation.
- sevtor
-
Topic Author
- Offline
- New Member
-
As a bonus I shall include the modules that I use quite a lot. They give the pedigree tree, a descendants overview and a history module that can give the details for ancestors or descendants in many generations.
To get chinese characters in pdf documents is more tricky and I don't know the tcpdf tool well enough. But I found that there are many tools available that can convert a html file to pdf. I tried it on the demo site by first generating a report with chinese characters and then got it translated by a tool ( html2pdf.com/ ).
webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Please Log in or Create an account to join the conversation.
- xiao
-
- Offline
- Junior Member
-
- Posts: 220
Thank you very muchFirst, I have now packaged my version of the Report folder into a zip file to be included. it was developed with version 2.1.17 but works with the demo which is version 2.1.16.
As a bonus I shall include the modules that I use quite a lot. They give the pedigree tree, a descendants overview and a history module that can give the details for ancestors or descendants in many generations.
To get chinese characters in pdf documents is more tricky and I don't know the tcpdf tool well enough. But I found that there are many tools available that can convert a html file to pdf. I tried it on the demo site by first generating a report with chinese characters and then got it translated by a tool ( html2pdf.com/ ).
Please Log in or Create an account to join the conversation.
- Franz Frese
-
- Offline
- Platinum Member
-
Please Log in or Create an account to join the conversation.
- hermann
-
- Offline
- Elite Member
-
I copied them to my folder modules_v4 and replaced the original folder /app/Report by the files you provided. Is this replacement necessary? I have to repeat it always after an upgrade. @Greg: would you add the modifications of @sevtor to the webtrees core?
Hermann
Designer of the custom module "Extended Family"
webtrees 2.2.1 (all custom modules installed, PHP 8.3.12, MariaDB 10.6) @ ahnen.hartenthaler.eu
Please Log in or Create an account to join the conversation.
- Franz Frese
-
- Offline
- Platinum Member
-
Please Log in or Create an account to join the conversation.