-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
246 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 56 additions & 3 deletions
59
src/test/java/test/org/fugerit/java/doc/mod/itext/poc/TestDefaultDoc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,78 @@ | ||
package test.org.fugerit.java.doc.mod.itext.poc; | ||
|
||
import org.fugerit.java.core.cfg.ConfigRuntimeException; | ||
import org.fugerit.java.doc.mod.openpdf.HtmlTypeHandler; | ||
import org.fugerit.java.doc.mod.openpdf.PdfTypeHandler; | ||
import org.fugerit.java.doc.mod.openpdf.RtfTypeHandler; | ||
import org.fugerit.java.doc.mod.openpdf.helpers.OpenPpfDocHandler; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import com.lowagie.text.pdf.BaseFont; | ||
|
||
public class TestDefaultDoc extends TestDocBase { | ||
|
||
private static final String CUSTOM_FONT = "TitilliumWeb"; | ||
|
||
@BeforeClass | ||
public static void init() { | ||
try { | ||
OpenPpfDocHandler.registerFont( CUSTOM_FONT , "src/test/resources/font/TitilliumWeb-Regular.ttf"); | ||
} catch (Exception e) { | ||
throw new ConfigRuntimeException( e ); | ||
} | ||
} | ||
|
||
private static final String DEFAULT_DOC = "default_doc"; | ||
|
||
private static final String DEFAULT_DOC_ALT = "default_doc_alt"; | ||
|
||
@Test | ||
public void testOpenFailPDF() { | ||
Assert.assertThrows( AssertionError.class , () -> this.testDocWorker( "default_doc_fail1" , PdfTypeHandler.HANDLER ) ); | ||
} | ||
|
||
@Test | ||
public void testCustomFont() { | ||
BaseFont font = OpenPpfDocHandler.findFont( CUSTOM_FONT ); | ||
Assert.assertNotNull(font); | ||
} | ||
|
||
@Test | ||
public void testOpenPDF() { | ||
this.testDocWorker( "default_doc" , PdfTypeHandler.HANDLER ); | ||
boolean ok = this.testDocWorker( DEFAULT_DOC , PdfTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
@Test | ||
public void testOpenHTML() { | ||
this.testDocWorker( "default_doc" , HtmlTypeHandler.HANDLER ); | ||
boolean ok = this.testDocWorker( DEFAULT_DOC , HtmlTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
@Test | ||
public void testOpenRTF() { | ||
this.testDocWorker( "default_doc" , RtfTypeHandler.HANDLER ); | ||
boolean ok = this.testDocWorker( DEFAULT_DOC , RtfTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
@Test | ||
public void testOpenAltPDF() { | ||
boolean ok = this.testDocWorker( DEFAULT_DOC_ALT , PdfTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
@Test | ||
public void testOpenAltHTML() { | ||
boolean ok = this.testDocWorker( DEFAULT_DOC_ALT , HtmlTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
@Test | ||
public void testOpenAltRTF() { | ||
boolean ok = this.testDocWorker( DEFAULT_DOC_ALT , RtfTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/test/java/test/org/fugerit/java/doc/mod/itext/poc/TestOpenPdfHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package test.org.fugerit.java.doc.mod.itext.poc; | ||
|
||
import org.fugerit.java.doc.mod.openpdf.helpers.PhraseParent; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.lowagie.text.Paragraph; | ||
import com.lowagie.text.Phrase; | ||
|
||
public class TestOpenPdfHelper { | ||
|
||
@Test | ||
public void test001() throws Exception { | ||
PhraseParent parent = new PhraseParent( new Phrase() ); | ||
parent.add( new Paragraph() ); | ||
Assert.assertNotNull( parent ); | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/test/java/test/org/fugerit/java/doc/mod/itext/poc/TestPhraseParent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package test.org.fugerit.java.doc.mod.itext.poc; | ||
|
||
import java.util.Properties; | ||
|
||
import org.fugerit.java.doc.mod.openpdf.helpers.OpenPdfHelper; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class TestPhraseParent { | ||
|
||
@Test | ||
public void test001() throws Exception { | ||
OpenPdfHelper helper = new OpenPdfHelper(); | ||
helper.setParams( new Properties() ); | ||
log.info( "helper.getDefFontStyle() -> {}", helper.getDefFontStyle() ); | ||
Assert.assertNotNull( helper.getParams() ); | ||
} | ||
|
||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<doc | ||
xmlns="http://javacoredoc.fugerit.org" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://javacoredoc.fugerit.org https://www.fugerit.org/data/java/doc/xsd/doc-2-0.xsd" > | ||
|
||
<metadata> | ||
<!-- Margin for document : left;right;top;bottom --> | ||
<info name="margins">10;10;10;30</info> | ||
<info name="excel-table-id">excel-table=print</info> | ||
<!-- documenta meta information --> | ||
<info name="doc-title">Basic example</info> | ||
<info name="doc-subject">fj doc venus sample source xml</info> | ||
<info name="doc-author">fugerit79</info> | ||
<info name="doc-language">en</info> | ||
<!-- font must be loaded --> | ||
<info name="page-orient">horizontal</info> | ||
<header> | ||
<phrase fore-color="#222222" leading="3" align="right">header test</phrase> | ||
</header> | ||
<footer> | ||
<para fore-color="#222222" leading="3" align="right">${r"${currentPage}"} / ${r"${pageCount}"}</para> | ||
</footer> | ||
</metadata> | ||
<body> | ||
<image scaling="100" url="cl://test/img_test_teal.jpg"/> | ||
<phrase leading="3">My sample title</phrase> | ||
<table columns="3" colwidths="30;30;40" width="100" id="excel-table" padding="2"> | ||
<row> | ||
<cell align="center" border-color="#000000" border-width="1"><para style="bold">Name</para></cell> | ||
<cell align="center"><para style="bold">Surname</para></cell> | ||
<cell align="center"><para style="bold">Title</para></cell> | ||
</row> | ||
<row> | ||
<cell><para><![CDATA[Luthien]]></para></cell> | ||
<cell><para><![CDATA[Tinuviel]]></para></cell> | ||
<cell><para><![CDATA[Queen]]></para></cell> | ||
</row> | ||
<row> | ||
<cell><para><![CDATA[Thorin]]></para></cell> | ||
<cell><para><![CDATA[Oakshield]]></para></cell> | ||
<cell><para><![CDATA[King]]></para></cell> | ||
</row> | ||
<row> | ||
<cell><barcode text="0123456789123"/></cell> | ||
<cell><image scaling="100" url="cl://test/img_test_teal.jpg"/></cell> | ||
<cell> | ||
<table columns="2" colwidths="50;50" width="100" id="a-table" padding="2"> | ||
<row> | ||
<cell><para>1</para></cell> | ||
<cell><para>2</para></cell> | ||
</row> | ||
</table> | ||
</cell> | ||
</row> | ||
</table> | ||
</body> | ||
|
||
<page-break/> | ||
|
||
</doc> |
Oops, something went wrong.