diff --git a/CHANGELOG.md b/CHANGELOG.md index c2f3ccb..950d755 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## version 0.2.0 - 2023-08-20 * Updated parent version to fj-doc 1.5.0 * Added sonar cloud quality gate +* Removed some deprecation notice by OpenPDF ## version 0.1.0 - 2023-08-13 * Updated parent version to fj-doc 1.4.4 diff --git a/src/main/java/org/fugerit/java/doc/mod/openpdf/ITextDocHandler.java b/src/main/java/org/fugerit/java/doc/mod/openpdf/ITextDocHandler.java index fc4f5f9..27a4733 100644 --- a/src/main/java/org/fugerit/java/doc/mod/openpdf/ITextDocHandler.java +++ b/src/main/java/org/fugerit/java/doc/mod/openpdf/ITextDocHandler.java @@ -31,6 +31,7 @@ The Apache Software Foundation (http://www.apache.org/). import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Optional; import java.util.Properties; import org.fugerit.java.core.lang.helpers.StringUtils; @@ -69,6 +70,8 @@ The Apache Software Foundation (http://www.apache.org/). import com.lowagie.text.Phrase; import com.lowagie.text.Rectangle; import com.lowagie.text.Table; +import com.lowagie.text.alignment.HorizontalAlignment; +import com.lowagie.text.alignment.VerticalAlignment; import com.lowagie.text.html.HtmlTags; import com.lowagie.text.pdf.Barcode; import com.lowagie.text.pdf.Barcode128; @@ -180,15 +183,6 @@ private static int getAlign( int align ) { return r; } - private static int getValign( int align ) { - int r = Element.ALIGN_TOP; - if ( align == DocPara.ALIGN_BOTTOM ) { - r = Element.ALIGN_BOTTOM; - } else if ( align == DocPara.ALIGN_MIDDLE ) { - r = Element.ALIGN_MIDDLE; - } - return r; - } protected static Image createImage( DocImage docImage ) throws Exception { Image image = null; @@ -370,10 +364,16 @@ protected static Table createTable( DocTable docTable, ITextHelper docHelper ) t cell.setBackgroundColor( DocModelUtils.parseHtmlColor( docCell.getBackColor() ) ); } if ( docCell.getAlign() != DocPara.ALIGN_UNSET ) { - cell.setHorizontalAlignment( getAlign( docCell.getAlign() ) ); + Optional ha = HorizontalAlignment.of( docCell.getAlign() ); + if ( ha != null && ha.isPresent() ) { + cell.setHorizontalAlignment( ha.get() ); + } } if ( docCell.getValign() != DocPara.ALIGN_UNSET ) { - cell.setVerticalAlignment( getValign( docCell.getValign() ) ); + Optional va = VerticalAlignment.of( docCell.getAlign() ); + if ( va != null && va.isPresent() ) { + cell.setVerticalAlignment( va.get() ); + } } CellParent cellParent = new CellParent( cell ); Iterator itCurrent = docCell.docElements(); @@ -401,7 +401,6 @@ protected static Table createTable( DocTable docTable, ITextHelper docHelper ) t } } table.addCell( cell ); - @SuppressWarnings("unchecked") List listChunk = cell.getChunks(); if ( listChunk.size() == fontList.size() ) { for ( int k=0; k it = container.docElements(); Phrase phrase = new Phrase(); float leading = (float)-1.0;