From a5d2f33fc1f7558d2607a065c4c9330fa2762d2c Mon Sep 17 00:00:00 2001 From: Andrei Solntsev Date: Tue, 5 Nov 2024 22:47:32 +0200 Subject: [PATCH] #438 add test for "word-break: break-all" css property --- CHANGELOG.md | 4 +++ flying-saucer-core/pom.xml | 2 +- flying-saucer-examples/pom.xml | 2 +- flying-saucer-fop/pom.xml | 2 +- flying-saucer-log4j/pom.xml | 2 +- flying-saucer-pdf-osgi/pom.xml | 2 +- flying-saucer-pdf/pom.xml | 2 +- .../org/xhtmlrenderer/pdf/WordBreakTest.java | 32 +++++++++++++++++++ .../org/xhtmlrenderer/pdf/break-all.html | 12 +++++++ flying-saucer-swt/pom.xml | 2 +- pom.xml | 2 +- 11 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 flying-saucer-pdf/src/test/java/org/xhtmlrenderer/pdf/WordBreakTest.java create mode 100644 flying-saucer-pdf/src/test/resources/org/xhtmlrenderer/pdf/break-all.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 98933acf3..69a918c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 9.11.0 - see https://github.com/flyingsaucerproject/flyingsaucer/milestone/25 +* Add support for `word-break:break-all` CSS property -- thanks to Kyle Stephens (#438) +* refactoring: remove setters and make many classes immutable (#434) + ## 9.10.2 (29.10.2024) - see https://github.com/flyingsaucerproject/flyingsaucer/milestone/24?closed=1 * add overloaded method `addFontDirectory(... String encoding ...)` * #431 fix interpretation of cell borders (#432) diff --git a/flying-saucer-core/pom.xml b/flying-saucer-core/pom.xml index f29c2fb0d..cfa1f8e6a 100644 --- a/flying-saucer-core/pom.xml +++ b/flying-saucer-core/pom.xml @@ -7,7 +7,7 @@ org.xhtmlrenderer flying-saucer-parent - 9.10.3-SNAPSHOT + 9.11.0-SNAPSHOT ../pom.xml diff --git a/flying-saucer-examples/pom.xml b/flying-saucer-examples/pom.xml index eb0c4dbfd..457f8997d 100644 --- a/flying-saucer-examples/pom.xml +++ b/flying-saucer-examples/pom.xml @@ -6,7 +6,7 @@ org.xhtmlrenderer flying-saucer-parent - 9.10.3-SNAPSHOT + 9.11.0-SNAPSHOT ../pom.xml diff --git a/flying-saucer-fop/pom.xml b/flying-saucer-fop/pom.xml index e9f847ac9..eb1713d92 100644 --- a/flying-saucer-fop/pom.xml +++ b/flying-saucer-fop/pom.xml @@ -7,7 +7,7 @@ org.xhtmlrenderer flying-saucer-parent - 9.10.3-SNAPSHOT + 9.11.0-SNAPSHOT ../pom.xml diff --git a/flying-saucer-log4j/pom.xml b/flying-saucer-log4j/pom.xml index 8aed77d26..41cd3cc81 100644 --- a/flying-saucer-log4j/pom.xml +++ b/flying-saucer-log4j/pom.xml @@ -7,7 +7,7 @@ org.xhtmlrenderer flying-saucer-parent - 9.10.3-SNAPSHOT + 9.11.0-SNAPSHOT ../pom.xml diff --git a/flying-saucer-pdf-osgi/pom.xml b/flying-saucer-pdf-osgi/pom.xml index b2e7f4a3f..065794063 100644 --- a/flying-saucer-pdf-osgi/pom.xml +++ b/flying-saucer-pdf-osgi/pom.xml @@ -7,7 +7,7 @@ org.xhtmlrenderer flying-saucer-parent - 9.10.3-SNAPSHOT + 9.11.0-SNAPSHOT ../pom.xml diff --git a/flying-saucer-pdf/pom.xml b/flying-saucer-pdf/pom.xml index 6988af5d9..8e2fdcb3b 100644 --- a/flying-saucer-pdf/pom.xml +++ b/flying-saucer-pdf/pom.xml @@ -6,7 +6,7 @@ org.xhtmlrenderer flying-saucer-parent - 9.10.3-SNAPSHOT + 9.11.0-SNAPSHOT ../pom.xml diff --git a/flying-saucer-pdf/src/test/java/org/xhtmlrenderer/pdf/WordBreakTest.java b/flying-saucer-pdf/src/test/java/org/xhtmlrenderer/pdf/WordBreakTest.java new file mode 100644 index 000000000..27835fab1 --- /dev/null +++ b/flying-saucer-pdf/src/test/java/org/xhtmlrenderer/pdf/WordBreakTest.java @@ -0,0 +1,32 @@ +package org.xhtmlrenderer.pdf; + +import com.codeborne.pdftest.PDF; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import static com.codeborne.pdftest.assertj.Assertions.assertThat; + +public class WordBreakTest { + private static final Logger log = LoggerFactory.getLogger(WordBreakTest.class); + + @Test + void breakAll() throws IOException { + + byte[] pdf = Html2Pdf.fromClasspathResource("org/xhtmlrenderer/pdf/break-all.html"); + printFile(pdf, "break-all.pdf"); + assertThat(new PDF(pdf)).containsExactText("HelloWorld1\nHelloWorld2\nHelloWorld3\nHelloWorld4\nHelloWorld5\n"); + } + + private static void printFile(byte[] pdf, String filename) throws IOException { + File file = new File("target", filename); + try (FileOutputStream o = new FileOutputStream(file)) { + o.write(pdf); + } + log.info("Generated PDF: {}", file.getAbsolutePath()); + } +} diff --git a/flying-saucer-pdf/src/test/resources/org/xhtmlrenderer/pdf/break-all.html b/flying-saucer-pdf/src/test/resources/org/xhtmlrenderer/pdf/break-all.html new file mode 100644 index 000000000..2d01b3793 --- /dev/null +++ b/flying-saucer-pdf/src/test/resources/org/xhtmlrenderer/pdf/break-all.html @@ -0,0 +1,12 @@ + + + + + Test::break-all + + +
+ HelloWorld1HelloWorld2HelloWorld3HelloWorld4HelloWorld5 +
+ + \ No newline at end of file diff --git a/flying-saucer-swt/pom.xml b/flying-saucer-swt/pom.xml index 894500459..e2714317e 100644 --- a/flying-saucer-swt/pom.xml +++ b/flying-saucer-swt/pom.xml @@ -7,7 +7,7 @@ org.xhtmlrenderer flying-saucer-parent - 9.10.3-SNAPSHOT + 9.11.0-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index 7f63e8b72..afcc77826 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.xhtmlrenderer flying-saucer-parent - 9.10.3-SNAPSHOT + 9.11.0-SNAPSHOT pom