Search code examples
hyphenationprincexml

Hyphenation of Prince XML for external languages not working in DocRaptor API


I have installed prince xml in local environment in linux.

The hyphenation property works in local environment for tamil language, when i add the below css code in the file hyph.css in prince source folder of style.

:lang(ta) { 
    hyphens:auto;
    prince-hyphenate-patterns: url("../hyph/hyph-ta.pat"); 
}

and by copying the required file hyph-ta.pat to hyph folder in prince source folders.

  • Now the hyphenation works in generated pdf of html content in local environment by prince xml.

  • The content given to prince xml can be given by a remote url for generating in local.

  • In case of API of prince xml like DocRaptor, we didn't have access to prince source file to copy/edit the files hyph-ta.pat and hyph.css.

  • For DocRaptor API i will give content to generate the pdf by HTML content instead of remote url.

  • So that, i have written the above css code in the html content's style property which will be given to the DocRaptor API. And if we change the property value of prince-hyphenate-patterns in the html contents to http resource url points to the hyph-ta.pat file

    :lang(ta) { 
      hyphens:auto;
      prince-hyphenate-patterns: url("http://../hyph-ta.pat"); 
    }
    

    the hyphenation did not works in generated pdf.

Is there any other requirements needed to work the hyphenation in Docraptor API ?

Whenever I have given in http resource file for the property "prince-hyphenate-patterns" the hyphenation did not work in generated pdf document in both local environment and in DocRaptor API.


Solution

  • The primary difference between DocRaptor and a local instance of PrinceXML is the fact that DocRaptor's conversion takes place externally on our own servers.

    This means that while your local instance of PrinceXML can use your local filesystem to access hyph-ta.pat, DocRaptor cannot. The solution here is that hyph-ta.pat will have to be linked either from a public source, or will have to be externally visible by another means. That is to say, instead of the url being something like "../hyph/hyph-ta.pat" it will need to be something like "https://hyph-pattern-source.com/hyph/hyph-ta.pat" (This is just an example format and not a real URL).

    Let me know if this helps answer your question. If you need anything else, we're happy to help!

    Best Regards,

    Jon (who forwarded this response to me)

    DocRaptor Support Team