From debcc009b93ff421d81c9defd2db9a2a455d24a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Rodri=CC=81guez?= Date: Tue, 14 Jun 2022 18:31:56 +0200 Subject: [PATCH 1/2] [BP] Switch from itext to openpdf for PDF map rendering Backport of https://github.com/geonetwork/core-geonetwork/pull/6343 --- core/pom.xml | 11 +- .../kernel/thumbnail/ThumbnailMaker.java | 18 +-- pom.xml | 108 ++++++------------ services/pom.xml | 4 +- .../api/records/formatters/FormatterApi.java | 75 ++++-------- .../ImageReplacedElementFactory.java | 5 +- .../geonet/api/standards/StandardsApi.java | 18 +-- web/pom.xml | 10 +- 8 files changed, 89 insertions(+), 160 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 4a234f03b82..3808200a4ac 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -1,6 +1,6 @@ + + com.github.librepdf + openpdf + org.mapfish.print print-lib + + + com.itextpdf + itextpdf + commons-httpclient commons-httpclient diff --git a/core/src/main/java/org/fao/geonet/kernel/thumbnail/ThumbnailMaker.java b/core/src/main/java/org/fao/geonet/kernel/thumbnail/ThumbnailMaker.java index 7ef5508d35f..52b0c8571db 100644 --- a/core/src/main/java/org/fao/geonet/kernel/thumbnail/ThumbnailMaker.java +++ b/core/src/main/java/org/fao/geonet/kernel/thumbnail/ThumbnailMaker.java @@ -1,5 +1,5 @@ //============================================================================= -//=== Copyright (C) 2001-2014 Food and Agriculture Organization of the +//=== Copyright (C) 2001-2022 Food and Agriculture Organization of the //=== United Nations (FAO-UN), United Nations World Food Programme (WFP) //=== and United Nations Environment Programme (UNEP) //=== @@ -24,8 +24,6 @@ package org.fao.geonet.kernel.thumbnail; import jeeves.server.context.ServiceContext; - -import org.dom4j.DocumentException; import org.fao.geonet.constants.Geonet; import org.fao.geonet.utils.IO; import org.fao.geonet.utils.Log; @@ -36,20 +34,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; -import java.awt.Graphics2D; -import java.awt.Transparency; +import javax.imageio.ImageIO; +import java.awt.*; import java.awt.image.BufferedImage; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; +import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.util.HashMap; -import javax.imageio.ImageIO; - /** * Use MapFish print module to generate thumbnail. * @@ -155,7 +147,7 @@ private MapPrinter getMapPrinter() { } public Path generateThumbnail(String jsonConfig, Integer rotationAngle) - throws IOException, DocumentException, com.itextpdf.text.DocumentException { + throws IOException { PJsonObject specJson = MapPrinter.parseSpec(jsonConfig); if (Log.isDebugEnabled(LOGGER_NAME)) { diff --git a/pom.xml b/pom.xml index 46a9d3513fe..e39f52772eb 100644 --- a/pom.xml +++ b/pom.xml @@ -422,11 +422,6 @@ - org.apache.xmlgraphics fop @@ -858,10 +853,15 @@ dlib 1.0 + + com.github.librepdf + openpdf + 1.3.26 + org.mapfish.print print-lib - 2.1.6 + 2.2.0 @@ -958,20 +958,12 @@ mysql-connector-java 8.0.20 - - - com.oracle.database.jdbc ojdbc8 19.6.0.0 - + + org.codehaus.izpack izpack-standalone-compiler @@ -1120,14 +1112,8 @@ org.xhtmlrenderer - flying-saucer-pdf-itext5 - ${flying-saucer} - - - com.itextpdf - itextpdf - - + flying-saucer-pdf-openpdf + ${flying-saucer.version} @@ -1231,66 +1217,42 @@ - + + + + + + + + + + + + - - false - osgeo - OSGeo repository + OSGeo Release repository https://repo.osgeo.org/repository/release/ - - - - - - - - - - - - - - - - - - - @@ -1589,7 +1551,7 @@ 5.8.0 2.1.1 2.10.3 - 9.0.7 + 9.1.22 2.14.4 1.2.17 2.17.1 diff --git a/services/pom.xml b/services/pom.xml index 019ac840ef1..730f03887bd 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -1,6 +1,6 @@ + + com.github.librepdf + openpdf + org.mapfish.print print-lib + + com.lowagie + itext + commons-httpclient commons-httpclient From e9f62ab1bff39e39c72f9c05f03dec3d52ed61a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Rodri=CC=81guez?= Date: Wed, 15 Jun 2022 09:47:16 +0200 Subject: [PATCH 2/2] Remove unnecessary exclusions Remove itext exclusions becasue it isn't a depencency of mapfish's print-lib 2.2.0 anymore --- core/pom.xml | 5 ----- web/pom.xml | 4 ---- 2 files changed, 9 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 3808200a4ac..4459759f7de 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -398,11 +398,6 @@ org.mapfish.print print-lib - - - com.itextpdf - itextpdf - commons-httpclient commons-httpclient diff --git a/web/pom.xml b/web/pom.xml index e4079d1f323..6fa2f6b462d 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -322,10 +322,6 @@ org.mapfish.print print-lib - - com.lowagie - itext - commons-httpclient commons-httpclient