This is an automated email from the ASF dual-hosted git repository.
apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new cc4d9e180a Fix Apache FOP in native with more font usage
cc4d9e180a is described below
commit cc4d9e180a0ed1c32f14eda0afbdffb9ac86bce4
Author: Aurélien Pupier <[email protected]>
AuthorDate: Thu Feb 26 16:50:54 2026 +0100
Fix Apache FOP in native with more font usage
A bunch of proxies can be called with more complex cases, a test has
been added related to font and the need of FontEventProducer. Registered
all the other subinterfaces of EventProducer
fix #8349
Signed-off-by: Aurélien Pupier <[email protected]>
---
.../quarkus/component/fop/deployment/FopProcessor.java | 8 +++++---
.../apache/camel/quarkus/component/fop/it/FopTest.java | 16 +++++++++++-----
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git
a/extensions/fop/deployment/src/main/java/org/apache/camel/quarkus/component/fop/deployment/FopProcessor.java
b/extensions/fop/deployment/src/main/java/org/apache/camel/quarkus/component/fop/deployment/FopProcessor.java
index 8810753e89..bb0f6c602f 100644
---
a/extensions/fop/deployment/src/main/java/org/apache/camel/quarkus/component/fop/deployment/FopProcessor.java
+++
b/extensions/fop/deployment/src/main/java/org/apache/camel/quarkus/component/fop/deployment/FopProcessor.java
@@ -36,7 +36,7 @@ import
io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import
io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import org.apache.camel.quarkus.component.fop.FopRuntimeProxyFeature;
-import org.apache.fop.ResourceEventProducer;
+import org.apache.fop.events.EventProducer;
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.fo.expr.PropertyException;
@@ -81,8 +81,10 @@ class FopProcessor {
}
@BuildStep
- NativeImageProxyDefinitionBuildItem registerDefinitionBuildTimeProxies() {
- return new
NativeImageProxyDefinitionBuildItem(ResourceEventProducer.class.getName());
+ void setupEventProducers(CombinedIndexBuildItem combinedIndex,
+ BuildProducer<NativeImageProxyDefinitionBuildItem>
proxyDefinition) {
+
combinedIndex.getIndex().getAllKnownSubinterfaces(EventProducer.class).forEach(
+ classInfo -> proxyDefinition.produce(new
NativeImageProxyDefinitionBuildItem(classInfo.name().toString())));
}
@BuildStep
diff --git
a/integration-tests/fop/src/test/java/org/apache/camel/quarkus/component/fop/it/FopTest.java
b/integration-tests/fop/src/test/java/org/apache/camel/quarkus/component/fop/it/FopTest.java
index d67f5849a8..484e4291d1 100644
---
a/integration-tests/fop/src/test/java/org/apache/camel/quarkus/component/fop/it/FopTest.java
+++
b/integration-tests/fop/src/test/java/org/apache/camel/quarkus/component/fop/it/FopTest.java
@@ -31,6 +31,7 @@ import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.ExtractableResponse;
+import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import io.smallrye.common.os.OS;
import org.apache.pdfbox.Loader;
@@ -91,11 +92,16 @@ class FopTest {
}
@Test
- public void convertToPdfWithCustomFont() throws IOException {
+ void convertToPdfWithCustomFont() throws IOException {
convertToPdf(msg -> decorateTextWithXSLFO(msg, "Freedom"),
tmpDir.resolve("mycfg.xml").toAbsolutePath().toUri().toString());
}
+ @Test
+ void convertToPdfWithArialFont() throws IOException {
+ convertToPdf(msg -> decorateTextWithXSLFO(msg, "Arial"), null);
+ }
+
@Test
void convertToPdfWithImage() throws Exception {
RequestSpecification requestSpecification = RestAssured.given()
@@ -128,7 +134,7 @@ class FopTest {
if (userConfigFile != null) {
requestSpecification.queryParam("userConfigURL", userConfigFile);
}
- ExtractableResponse response = requestSpecification
+ ExtractableResponse<Response> response = requestSpecification
.body(msgCreator.apply(MSG))
.post("/fop/post") //
.then()
@@ -142,7 +148,7 @@ class FopTest {
public static String decorateTextWithXSLFO(String text, String font) {
String foBlock = font == null ? " <fo:block>" + text +
"</fo:block>\n"
- : " <fo:block font-family=\"" + font + "\">" + text +
"</fo:block>\n";
+ : " <fo:block font-size=\"14pt\" font-family=\"" + font +
"\">" + text + "</fo:block>\n";
return createFoContentWithBlock(foBlock);
}
@@ -150,13 +156,13 @@ class FopTest {
return """
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
- <fo:simple-page-master master-name="only">
+ <fo:simple-page-master master-name="A4"
page-height="29.7cm" page-width="21cm">
<fo:region-body region-name="xsl-region-body"
margin="0.7in" padding="0" />
<fo:region-before region-name="xsl-region-before"
extent="0.7in" />
<fo:region-after region-name="xsl-region-after"
extent="0.7in" />
</fo:simple-page-master>
</fo:layout-master-set>
- <fo:page-sequence master-reference="only">
+ <fo:page-sequence master-reference="A4">
<fo:flow flow-name="xsl-region-body">
%s
</fo:flow>