Skip to content

Commit

Permalink
fj-doc-freemarker dependency #5
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Jan 10, 2024
1 parent fe60d39 commit d7965a3
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- fj-doc-freemarker dependency

### Changed

- fj-doc version set to 3.3.0
- openpdf version 1.3.36

Expand Down
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@
<dependency>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc-base</artifactId>
</dependency>

</dependency>

<dependency>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc-freemarker</artifactId>
</dependency>

</dependencies>

<organization>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.fugerit.java.doc.mod.openpdf.helpers;

import lombok.extern.slf4j.Slf4j;
import org.fugerit.java.core.cfg.ConfigException;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

@Slf4j
public class OpenPDFConfigHelper {

public static void handleConfig( Element config, String type ) throws ConfigException {
log.info( "configure for type: {}", type );
NodeList fontList = config.getElementsByTagName( "font" );
for ( int k=0; k<fontList.getLength(); k++ ) {
Element currentFontTag = (Element) fontList.item( k );
String name = currentFontTag.getAttribute( "name" );
String path = currentFontTag.getAttribute( "path" );
log.info( "current font {} - {}", name, path );
ConfigException.apply( () -> OpenPpfDocHandler.registerFont( name , path ) );
}
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.org.fugerit.java.doc.mod.itext.poc;
package test.org.fugerit.java.doc.mod.openpdf.poc;

import java.awt.Color;
import java.io.FileOutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.org.fugerit.java.doc.mod.itext.poc;
package test.org.fugerit.java.doc.mod.openpdf.poc;

import org.fugerit.java.core.cfg.ConfigRuntimeException;
import org.fugerit.java.doc.mod.openpdf.HtmlTypeHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.org.fugerit.java.doc.mod.itext.poc;
package test.org.fugerit.java.doc.mod.openpdf.poc;

import static org.junit.Assert.fail;

Expand All @@ -13,10 +13,14 @@
import org.fugerit.java.doc.base.config.DocTypeHandler;

import lombok.extern.slf4j.Slf4j;
import org.fugerit.java.doc.freemarker.process.FreemarkerDocProcessConfig;
import org.fugerit.java.doc.freemarker.process.FreemarkerDocProcessConfigFacade;

@Slf4j
public class TestDocBase {

private FreemarkerDocProcessConfig config = FreemarkerDocProcessConfigFacade.loadConfigSafe( "cl://fm-test-mod-openpdf-config.xml" );

protected boolean testDocWorker( String testCase, DocTypeHandler handler ) {
boolean ok = false;
String inputXml = "xml/"+testCase+".xml" ;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.org.fugerit.java.doc.mod.itext.poc;
package test.org.fugerit.java.doc.mod.openpdf.poc;

import org.fugerit.java.doc.mod.openpdf.helpers.PhraseParent;
import org.junit.Assert;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.org.fugerit.java.doc.mod.itext.poc;
package test.org.fugerit.java.doc.mod.openpdf.poc;

import org.fugerit.java.core.cfg.ConfigRuntimeException;
import org.fugerit.java.doc.mod.openpdf.helpers.OpenPdfFontHelper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.org.fugerit.java.doc.mod.itext.poc;
package test.org.fugerit.java.doc.mod.openpdf.poc;

import java.util.Properties;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package test.org.fugerit.java.doc.mod.openpdf.poc;

import org.fugerit.java.doc.mod.openpdf.PdfTypeHandler;
import org.junit.Assert;
import org.junit.Test;

public class TestSpec extends TestDocBase {

private static final String DEFAULT_DOC = "test";

@Test
public void testOpenPDF() {
boolean ok = this.testDocWorker( DEFAULT_DOC , PdfTypeHandler.HANDLER );
Assert.assertTrue(ok);
}

}
19 changes: 19 additions & 0 deletions src/test/resources/fm-test-mod-openpdf-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<freemarker-doc-process-config
xmlns="https://freemarkerdocprocess.fugerit.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://freemarkerdocprocess.fugerit.org https://www.fugerit.org/data/java/doc/xsd/freemarker-doc-process-1-0.xsd" >

<docHandlerConfig registerById="true">
<docHandler id="pdf_openpdf" info="pdf" type="org.fugerit.java.doc.mod.openpdf.PdfTypeHandler">
<docHandlerCustomConfig charset="UTF-8">
<font name="Calibri" path="src/test/resources/font/TitilliumWeb-Regular.ttf"/>
</docHandlerCustomConfig>
</docHandler>
<docHandler id="rtf_openpdf" info="rtf" type="org.fugerit.java.doc.mod.openpdf.RtfTypeHandler">
</docHandler>
<docHandler id="html_openpdf" info="html" type="org.fugerit.java.doc.mod.openpdf.HtmlTypeHandler">
</docHandler>
</docHandlerConfig>

</freemarker-doc-process-config>

0 comments on commit d7965a3

Please sign in to comment.