Web based family history software

file Question Header and footer on PDF reports

  • sevtor
  • sevtor's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 8 months ago #1 by sevtor
Header and footer on PDF reports was created by sevtor
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.

webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #2 by xiao
Replied by xiao on topic Header and footer on PDF reports
Hello, have you solved the problem of exporting PDF?

Please Log in or Create an account to join the conversation.

  • sevtor
  • sevtor's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 5 months ago #3 by sevtor
Replied by sevtor on topic Header and footer on PDF reports
Yes, I have solved this.
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.

More
1 year 5 months ago #4 by xiao
Replied by xiao on topic Header and footer on PDF reports
hi, I also encountered the same problem when exporting PDF, but I am not able to solve the problem yet. Can you give me some advice?

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #5 by xiao
Replied by xiao on topic Header and footer on PDF reports

Yes, I have solved this.
I also have a lot of improvements to the report generator if anyone is interested.
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.

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #6 by xiao
Replied by xiao on topic Header and footer on PDF reports
Hello, I want to export the report to a PDF file. Your patch is very good. Can you provide it?

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #7 by HerzScheisse
Replied by HerzScheisse on topic Header and footer on PDF reports
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...

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.

More
1 year 4 months ago #8 by xiao
Replied by xiao on topic Header and footer on PDF reports

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...
Thank you very much. I have seen "webtrees-2.0.7.patch" in the compressed package,
but the file seems to be damaged.

Please Log in or Create an account to join the conversation.

  • bertkoor
  • bertkoor's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
More
1 year 4 months ago #9 by bertkoor
Replied by bertkoor on topic Header and footer on PDF reports
webtrees-change-suggestion.zip contains a ".patch" file, and I don't see the file itself is damaged. It needs to be applied to a clone of the webtrees git repository by the " git apply " command.

stamboom.BertKoor.nl runs on webtrees v2.2.1

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #10 by xiao
Replied by xiao on topic Header and footer on PDF reports

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.
Hi, when I use the "family-tree" module, I get the following error. How can I solve it?
 

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago - 1 year 4 months ago #11 by hermann
Replied by hermann on topic Header and footer on PDF reports
First option: you can delete the relevant folder in your modules_v4 directory in order to deinstall the family tree home custom module.
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
Last edit: 1 year 4 months ago by hermann.

Please Log in or Create an account to join the conversation.

  • sevtor
  • sevtor's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 4 months ago #12 by sevtor
Replied by sevtor on topic Header and footer on PDF reports
It seems that some words and phrases are not translated correctly, e.g. "Generation ", "She was born", whereas other are translated, e.g. "The husband died". Did you run this on the demo site? When I try it, it looks as I expect. Strange!

webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/

Please Log in or Create an account to join the conversation.

  • sevtor
  • sevtor's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 4 months ago #13 by sevtor
Replied by sevtor on topic Header and footer on PDF reports
The family tree module requires some patches to ReportParserGenerate.php
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
  • sevtor's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 4 months ago #14 by sevtor
Replied by sevtor on topic Header and footer on PDF reports
A patch file for ReportParserGenerate.php

webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Attachments:

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago - 1 year 4 months ago #15 by xiao
Replied by xiao on topic Header and footer on PDF reports

A patch file for ReportParserGenerate.php
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?

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.

 
Last edit: 1 year 4 months ago by xiao.

Please Log in or Create an account to join the conversation.

  • sevtor
  • sevtor's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 4 months ago - 1 year 4 months ago #16 by sevtor
Replied by sevtor on topic Header and footer on PDF reports
First, 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/ ).

webtrees 2.1.18, php 8.1.27, torstendahl.se/demo/
Attachments:
Last edit: 1 year 4 months ago by sevtor.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #17 by xiao
Replied by xiao on topic Header and footer on PDF reports

First, 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/ ).
Thank you very much

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #18 by Franz Frese
Replied by Franz Frese on topic Header and footer on PDF reports
So (a very simple) solution for   xiao  is to generate html and convert the result to pdf.
On Windows - system you can (simply) use the "Microsoft print to pdf".

By using a pdf-printer you do not need a foreign site for conversion html->pdf and you do not need the extended reports created by  sevtor  .

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #19 by hermann
Replied by hermann on topic Header and footer on PDF reports
@sevtor: your webtrees reports are great! Thank you!

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.

More
1 year 4 months ago #20 by Franz Frese
Replied by Franz Frese on topic Header and footer on PDF reports
The question should not be "Is this replacement necessary?" but "Do the changed files disturb the current reports?" .  Then sevtor can do a pull request at github webtrees!

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum