splitbrain / dokuwiki-plugin-dw2pdf

A fork of Luigi Micco's PDF export plugin for DokuWiki
http://www.dokuwiki.org/plugin:dw2pdf
55 stars 68 forks source link

enable hyphenation based on wiki language #415

Closed Juergen-aus-Zuendorf closed 1 year ago

Juergen-aus-Zuendorf commented 3 years ago

Hi,

it seems that the given language is not passed from HTML to the PDF output. I am trying to use automatic hyphenation using the CSS function "hyphens". But for this to work, the definition of the language attribute in the HTML code is required. When debugging with "&debughtml=text" you can see that the language is not specified.

Regards Juergen

Klap-in commented 3 years ago

Could you describe how someone can reproduce your situation? I have not yet an idea what your issue is.

Juergen-aus-Zuendorf commented 3 years ago

The CSS command Hyphens: auto can be used to activate automatic hyphenation. However, the hyphenation rules are language-specific. In HTML, the language is determined by the lang attribute, and browsers hyphenate only if this attribute is present and the corresponding hyphenation dictionary is available. Interestingly, mpdf also supports this function. But without a specific, previously defined language, hyphenation looks very strange.

In my userstyle.css file I have the following sequence:

body {
    hyphens: auto;
    -moz-hyphens: auto;
    -ms-hyphens: auto;
    -o-hyphens: auto;
    -webkit-hyphens: auto;
}

... and it works perfectly for german language (Firefox).

The same syntax in the style.ini of the pdf template brings some kind of hyphenation which is totally wrong.

Klap-in commented 3 years ago

And I can just export every page to see this? Please provide a small recipe for reproducing. I do not know what I should put in my wiki, which plugins/versions/settings are needed. I don't know what the current output is in your setup. I do not know what output you expect. Please realize that we do not know anything about your setup. So guide your potential helpers to quickly reproduce your situation.

Juergen-aus-Zuendorf commented 3 years ago

Here I have a small recipe as a wiki text:

====== Spielplatz ======

Die Betriebsanleitung vor Beginn aller Arbeiten sorgfältig durchlesen! Sie ist Produktbestandteil und muss in unmittelbarer Nähe der Maschine für das Personal jederzeit zugänglich aufbewahrt werden. 

And here is the result: a) Browser (Edge): Browser(Edge)

b) Output as PDF: PDF-Ausgabe

The word "jederzeit" is hyphened at a wrong position (correct should be this: je-der-zeit). And this problem runs through the whole text.

My idea why the hyphenation is in the wrong position is that the language "de" is not recognized because it is simply not known during PDF generation. As written at the beginning of this thread, when debugging with "&debughtml=text" you can see that the language is not specified.

Here is my template: schuette_ban_de_v01.zip

Juergen-aus-Zuendorf commented 3 years ago

I have done a little research: The language must be defined in the file "..\dw2pdf\vendor\mpdf\mpdf\src\Config\ConfigVariables.php"

Syntax for German hyphenation:
'SHYlang' => "de", // 'en','de','es','fi','fr','it','nl','pl','ru','sv'

I dont't know: Is there perhaps a possibility to influence this from a parameter passing using the DW2PDF plugin?

Klap-in commented 3 years ago

The wiki has already a global language setting. (of course it get more complex to get the correct language when the translation plugin is used. https://www.dokuwiki.org/plugin:translation).

From this setting, probably for available languages in mpdf the hyphenation setting could be set. https://mpdf.github.io/what-else-can-i-do/hyphenation.html

The config settings for mpdf are handled here: https://github.com/splitbrain/dokuwiki-plugin-dw2pdf/blob/master/DokuPDF.class.php

Juergen-aus-Zuendorf commented 3 years ago

In fact, I use the translation plugin. And for this reason, unfortunately, the global definition via the wiki login language is not enough for me. Therefore, it would certainly be ideal to determine the language analogous to the translation plugin. Alternatively, it would be sufficient to have an URL parameter, e.g. "&lang=de".

splitbrain commented 1 year ago

implemented in #481