Skip to content

Commit

Permalink
Removed some deprecation notice by OpenPDF
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Aug 20, 2023
1 parent f55b2c2 commit 99caf0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 14 additions & 15 deletions src/main/java/org/fugerit/java/doc/mod/openpdf/ITextDocHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<HorizontalAlignment> 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<VerticalAlignment> va = VerticalAlignment.of( docCell.getAlign() );
if ( va != null && va.isPresent() ) {
cell.setVerticalAlignment( va.get() );
}
}
CellParent cellParent = new CellParent( cell );
Iterator<DocElement> itCurrent = docCell.docElements();
Expand Down Expand Up @@ -401,7 +401,6 @@ protected static Table createTable( DocTable docTable, ITextHelper docHelper ) t
}
}
table.addCell( cell );
@SuppressWarnings("unchecked")
List<Element> listChunk = cell.getChunks();
if ( listChunk.size() == fontList.size() ) {
for ( int k=0; k<listChunk.size(); k++ ) {
Expand Down Expand Up @@ -578,7 +577,7 @@ public void handleDoc(DocBase docBase) throws Exception {
DocHeader docHeader = docBase.getDocHeader();
if ( docHeader != null && docHeader.isUseHeader() ) {
if ( docHeader.isBasic() ) {
HeaderFooter header = this.createHeaderFoter( docHeader, docHeader.getAlign(), docHelper );
HeaderFooter header = this.createHeaderFooter( docHeader, docHeader.getAlign(), docHelper );
this.document.setHeader( header );
} else {
if ( DOC_OUTPUT_PDF.equals( this.docType ) ) {
Expand All @@ -591,7 +590,7 @@ public void handleDoc(DocBase docBase) throws Exception {
DocFooter docFooter = docBase.getDocFooter();
if ( docFooter != null && docFooter.isUseFooter() ) {
if ( docFooter.isBasic() ) {
HeaderFooter footer = this.createHeaderFoter( docFooter, docFooter.getAlign(), docHelper );
HeaderFooter footer = this.createHeaderFooter( docFooter, docFooter.getAlign(), docHelper );
this.document.setFooter( footer );
} else {
if ( DOC_OUTPUT_PDF.equals( this.docType ) ) {
Expand Down Expand Up @@ -650,7 +649,7 @@ public static Element getElement( Document document, DocElement docElement, bool
return result;
}

private HeaderFooter createHeaderFoter( DocHeaderFooter container, int align, ITextHelper docHelper ) throws Exception {
private HeaderFooter createHeaderFooter( DocHeaderFooter container, int align, ITextHelper docHelper ) throws Exception {
Iterator<DocElement> it = container.docElements();
Phrase phrase = new Phrase();
float leading = (float)-1.0;
Expand Down

0 comments on commit 99caf0e

Please sign in to comment.