danfickle / danfickle/openhtmltopdf

Anonymous inline blocks following inline blocks treated as separate text for line splitting

Open
#864 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.2k
Forks
423
PR merge metrics
No merged PRs in 30d

Description

Reproduction case (in Scala, but should be simple enough to make sense):

```scala
Using.resource(new FileOutputStream("/tmp/output.pdf")) { os =>
new PdfRendererBuilder()
.useFastMode()
.withHtmlContent(
"""
|
|
|

Garantía. (Las Partes podrán establecer en este apartado la Garantía exigida a la y Parte y condiciones).


|
|
|""".stripMargin,
"",
)
.toStream(os)
.run()
}
```

Excuse the nonsense Spanish, had to change the line length to reproduce what we saw in our environment.

Whether using the default line splitter or the ICU line splitter, this puts the `.` onto the next line rather than treating it as part of the same text block as the em:

image

From debugging a little, this is because the text passed to the line breaker is just `.`, so the line breaker doesn't have the necessary context to make a decision about whether a break is allowed.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the Scala example with the default and ICU line splitters, then trace how the inline HTML content is assembled before reaching the line breaker. Verify that the period retains the preceding inline text context and remains on the expected line in both splitter modes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, scala
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.