Java - openpdf - Break word with hyphen

395 Views Asked by At

We are using openpdf 1.3.26 template 2.1 to generate PDF from HTML and CSS. I have a div with the following style

.text-block{
         display:block;
         text-align:justify;
         word-wrap: break-word;
         hyphens: auto;
         width:50px
         
        }
<span lang="de"  class="text-block" >myyyextraaaaaaaaalong text </span>

The hyphens are being added when I try this on my browser, but not the generated PDF.

2

There are 2 best solutions below

0
On BEST ANSWER

To me it looks like your PDF processor is limited CSS 2.1. and hyphens is CSS3 property.

0
On

Try the below snippet once. read article https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens#:~:text=The%20hyphens%20CSS%20property%20specifies,automatically%20insert%20hyphens%20where%20appropriate.

.text-block {
  display: block;
  text-align: justify;
  word-wrap: break-word;
  hyphens: none;
  width: 50px
}
<span lang="de" class="text-block" >myyyextraaaaaaaaalong text</span>