Skip to content

Commit

Permalink
Merge pull request #388 from Heavenfighter/master
Browse files Browse the repository at this point in the history
#387 allow embedd fonts from jar-file for pdf creation
  • Loading branch information
jstaerk authored May 31, 2024
2 parents ed0c12d + 18be7ad commit d0caf0d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.mustangproject.ZUGFeRD;

import org.apache.fop.apps.*;
import org.apache.fop.apps.io.ResourceResolverFactory;
import org.apache.fop.configuration.Configuration;
import org.apache.fop.configuration.ConfigurationException;
import org.apache.fop.configuration.DefaultConfigurationBuilder;
Expand Down Expand Up @@ -304,6 +305,11 @@ out from git with arbitrary options (which may include CSRF changes)

FopFactory fopFactory = builder.build();//FopFactory.newInstance(new File("c:\\Users\\jstaerk\\temp\\fop-config.xconf"));

fopFactory.getFontManager().setResourceResolver(
ResourceResolverFactory.createInternalResourceResolver(
new File(".").toURI(),
new ClasspathResolverURIAdapter()));

FOUserAgent userAgent = fopFactory.newFOUserAgent();

userAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b");
Expand Down
Binary file added library/src/main/resources/FreeSans.ttf
Binary file not shown.
2 changes: 1 addition & 1 deletion library/src/main/resources/fop-config.xconf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<renderer mime="application/pdf">
<fonts><!-- https://xmlgraphics.apache.org/fop/1.1/fonts.html auto-embed -->
<auto-detect/>
<font kerning="no" embed-url="FreeSans.ttf" embedding-mode="subset">
<font kerning="no" embed-url="classpath:FreeSans.ttf" embedding-mode="subset">
<font-triplet name="SourceSerifPro" style="normal" weight="normal" />
<font-triplet name="Times-Bold" style="normal" weight="normal" />
</font>
Expand Down

0 comments on commit d0caf0d

Please sign in to comment.