Skip to content

Commit

Permalink
Added PDFA output format in playground
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Jul 29, 2023
1 parent 5f4a209 commit 7efe210
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 7 deletions.
6 changes: 5 additions & 1 deletion docgen/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
1.4.0-rc.001 (2023-07-29)
1.X.X-rc.001 (2023-XX-XX)
------------------
+ Added PDFA output format in playground

1.4.0-rc.001 (2023-07-29)
------------------
+ [Added native support for GraalVM in core modules (fj-doc-base and fj-doc-freemarker)](https://github.com/fugerit-org/fj-doc/issues/39)
+ [[fj-doc-mod-fop] support for last page constant ${pageCount}](https://github.com/fugerit-org/fj-doc/issues/47)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private static DocTypeHandler createHelper( Element docHandlerConfig ) throws Co
}

public static FreemarkerDocProcessConfig loadConfigSafe( String configPath ) {
log.info( "loadConfigSafe config path : {}", configPath );
FreemarkerDocProcessConfig config = null;
try ( Reader xmlReader = new InputStreamReader(StreamHelper.resolveStream( configPath ) ) ) {
config = loadConfig(xmlReader);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.fugerit.java.doc.playground.config;

import org.fugerit.java.doc.base.config.DocTypeHandler;
import org.fugerit.java.doc.base.config.InitHandler;
import org.fugerit.java.doc.mod.fop.PdfFopTypeHandler;
import org.fugerit.java.doc.freemarker.process.FreemarkerDocProcessConfig;
import org.fugerit.java.doc.freemarker.process.FreemarkerDocProcessConfigFacade;

import io.quarkus.runtime.StartupEvent;
import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -11,12 +13,18 @@
@Slf4j
@ApplicationScoped
public class InitPlayground {

public static final PdfFopTypeHandler PDF_FOP_TYPE_HANDLER = new PdfFopTypeHandler();

void onStart(@Observes StartupEvent ev) {
private static final FreemarkerDocProcessConfig PROCESS_CONFIG = FreemarkerDocProcessConfigFacade.loadConfigSafe( "cl://playground-config/fm-playground-doc-process.xml" );

public static final DocTypeHandler PDF_FOP_TYPE_HANDLER = PROCESS_CONFIG.getFacade().findHandler( "pdf-fop" );

public static final DocTypeHandler PDFA_FOP_TYPE_HANDLER = PROCESS_CONFIG.getFacade().findHandler( "PDF/A-1a" );

void onStart(@Observes StartupEvent ev) {
log.info( "InitPlayground start" );
InitHandler.initDocAsync( PDF_FOP_TYPE_HANDLER );
log.info( "InitPlayground PDF_FOP_TYPE_HANDLER -> {}", PDF_FOP_TYPE_HANDLER );
log.info( "InitPlayground PDFA_FOP_TYPE_HANDLER -> {}", PDFA_FOP_TYPE_HANDLER );
log.info( "InitPlayground end" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ private DocTypeHandler findHandler( BasicInput input ) {
handler = XlsxPoiTypeHandler.HANDLER;
} else if ( "HTML".equalsIgnoreCase( input.getOutputFormat() ) ) {
handler = FreeMarkerHtmlFragmentTypeHandler.HANDLER;
} else if ( "PDFA".equalsIgnoreCase( input.getOutputFormat() ) ) {
handler = InitPlayground.PDFA_FOP_TYPE_HANDLER;
}
return handler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class DocXmlEditor extends Component {
if ( this.state.docFormat === 'HTML' ) {
var decodedStringAtoB = atob(this.state.docOutput);
outputData = <div contentEditable='true' dangerouslySetInnerHTML={{ __html: decodedStringAtoB }}></div>
} else if ( this.state.docFormat === 'PDF' ) {
} else if ( this.state.docFormat === 'PDF' || this.state.docFormat === 'PDFA' ) {
let srcData = 'data:application/pdf;base64,'+ this.state.docOutput;
outputData = outputData = <embed width="100%" height="600" src={srcData}/>
} else if ( this.state.docFormat === 'XLSX' ) {
Expand Down Expand Up @@ -167,6 +167,7 @@ class DocXmlEditor extends Component {
>
<MenuItem value='HTML'>HTML</MenuItem>
<MenuItem value='PDF'>PDF</MenuItem>
<MenuItem value='PDFA'>PDF/A</MenuItem>
<MenuItem value='XLSX'>XLSX</MenuItem>
</Select>
</FormControl>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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>
<docHandler id="PDFA" info="pdf" type="org.fugerit.java.doc.mod.fop.PdfFopTypeHandler">
<docHandlerCustomConfig charset="UTF-8" fop-config-mode="classloader"
fop-config-classloader-path="playground-config/fop-config-pdfa.xml" pdf-a-mode="PDF/A-1a"/>
</docHandler>
<docHandler id="md-ext" info="md" type="org.fugerit.java.doc.base.typehandler.markdown.SimpleMarkdownExtTypeHandler" />
<docHandler id="xml-doc" info="xml" type="org.fugerit.java.doc.base.config.DocTypeHandlerXMLUTF8" />
<docHandler id="xls-poi" info="xls" type="org.fugerit.java.doc.mod.poi.XlsPoiTypeHandler" />
<docHandler id="xlsx-poi" info="xlsx" type="org.fugerit.java.doc.mod.poi.XlsxPoiTypeHandler" />
<docHandler id="fo-fop" info="fo" type="org.fugerit.java.doc.mod.fop.FreeMarkerFopTypeHandlerUTF8" />
<docHandler id="pdf-fop" info="pdf" type="org.fugerit.java.doc.mod.fop.PdfFopTypeHandler"/>
<docHandler id="html-fm" info="html" type="org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandlerUTF8" />
<docHandler id="html-fragment-fm" info="fhtml" type="org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlFragmentTypeHandlerUTF8" />
</docHandlerConfig>

</freemarker-doc-process-config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<fop version="1.0">

<!-- Strict user configuration -->
<strict-configuration>true</strict-configuration>

<!-- Strict FO validation -->
<strict-validation>true</strict-validation>

<!-- Base URL for resolving relative URLs -->
<base>.</base>

<!-- Font Base URL for resolving relative font URLs -->
<font-base>.</font-base>

<!--
NOTE: for PDF/A format all fonts, even the basic ones, myst be fully embdedded.
https://xmlgraphics.apache.org/fop/2.8/pdfa.htm
-->
<renderers>
<renderer mime="application/pdf">
<!-- In this configuration the pdf-a-mode has been set via the freemarker-doc-process.xml
<pdf-a-mode>PDF/A-1a</pdf-a-mode>
<version>1.4</version>
-->
<fonts>
<font embed-url="classpath://font/TitilliumWeb-Regular.ttf" embedding-mode="full">
<font-triplet name="TitilliumWeb" style="normal" weight="normal"/>
</font>
<font embed-url="classpath://font/TitilliumWeb-Bold.ttf" embedding-mode="full">
<font-triplet name="TitilliumWeb" style="normal" weight="bold"/>
</font>
<font embed-url="classpath://font/TitilliumWeb-Italic.ttf" embedding-mode="full">
<font-triplet name="TitilliumWeb" style="italic" weight="normal"/>
</font>
<font embed-url="classpath://font/TitilliumWeb-BoldItalic.ttf" embedding-mode="full">
<font-triplet name="TitilliumWeb" style="italic" weight="bold"/>
</font>
<!--
<auto-detect/>
-->
</fonts>
</renderer>
</renderers>


<!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
<source-resolution>72</source-resolution>
<!-- Target resolution in dpi (dots/pixels per inch) for specifying the target resolution for generated bitmaps, default: 72dpi -->
<target-resolution>72</target-resolution>

<!-- default page-height and page-width, in case
value is specified as auto -->
<default-page-settings height="11in" width="8.26in"/>

</fop>
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
<info name="margins">10;10;10;30</info>
<info name="excel-table-id">excel-table=print</info>
<!-- documenta meta information -->
<info name="doc-title">Basci example</info>
<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="default-font-name">TitilliumWeb</info>
<footer-ext numbered="true">
<para align="center">Page ${currentPage}</para>
</footer-ext>
Expand Down

0 comments on commit 7efe210

Please sign in to comment.