Skip to content

Commit

Permalink
Add ability to unpack fonts (#2081)
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsm5 committed Jul 30, 2021
1 parent e88f58e commit e159577
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Expand Up @@ -91,7 +91,7 @@ public void load() throws IOException {

public void load(boolean unzipArchive) throws IOException {
if(unzipArchive) {
unpackFontsZip(); //unpack the fonts.zip archive in the supplied font directory
unpackDefaultFontArchive();
}

loadFonts(); //load all the newly unpacked fonts into the systems GraphicsEnvironment
Expand All @@ -101,7 +101,8 @@ public void load(boolean unzipArchive) throws IOException {
loadFontsForCells();
}

private void unpackFontsZip() throws IOException {
/** unpack the fonts.zip archive in the supplied font directory. Does not override existing files */
public void unpackDefaultFontArchive() throws IOException {
URL fontsUrl = ClassUtils.getResourceURL(FONTS_RESOURCE_NAME);
if(fontsUrl == null) {
throw new IllegalStateException("font archive ["+FONTS_RESOURCE_NAME+"] cannot be found");
Expand Down
Expand Up @@ -44,7 +44,6 @@
import nl.nn.adapterframework.pipes.FixedForwardPipe;
import nl.nn.adapterframework.stream.Message;
import nl.nn.adapterframework.util.ClassUtils;
import nl.nn.adapterframework.util.StreamUtil;
import nl.nn.adapterframework.util.XmlBuilder;

/**
Expand All @@ -62,9 +61,10 @@ public class PdfPipe extends FixedForwardPipe {
private List<String> availableActions = Arrays.asList("combine", "convert");
private String mainDocumentSessionKey = "defaultMainDocumentSessionKey";
private String filenameToAttachSessionKey = "defaultFileNameToAttachSessionKey";
protected String charset = StreamUtil.DEFAULT_INPUT_STREAM_ENCODING;
protected String charset = null;
private boolean isTempDirCreated = false;
private AsposeFontManager fontManager;
private boolean unpackDefaultFonts = false;

@Override
public void configure() throws ConfigurationException {
Expand Down Expand Up @@ -101,7 +101,7 @@ public void configure() throws ConfigurationException {

fontManager = new AsposeFontManager(fontsDirectory);
try {
fontManager.load();
fontManager.load(unpackDefaultFonts);
} catch (IOException e) {
throw new ConfigurationException("an error occured while loading fonts", e);
}
Expand All @@ -126,9 +126,9 @@ public void start() throws PipeStartException {
public void stop() {
if(isTempDirCreated) {
try {
Files.delete(Paths.get(pdfOutputLocation));
Files.delete(Paths.get(pdfOutputLocation));//temp file should be removed after use, not when the ibis shuts down
log.info("Temporary directory is deleted : " + pdfOutputLocation);
pdfOutputLocation="";
pdfOutputLocation=null;
} catch (IOException e) {
log.debug("Could not delete the temp folder " + pdfOutputLocation);
}
Expand Down Expand Up @@ -169,7 +169,7 @@ public PipeRunResult doPipe(Message input, PipeLineSession session) throws PipeR
}

@IbisDoc({ "action to be processed by pdf pipe possible values:{combine, convert}", "null" })
public void setAction(String action) {
public void setAction(String action) { //TODO should be enum
this.action = action;
}
public String getAction() {
Expand Down Expand Up @@ -206,13 +206,14 @@ public String getFontsDirectory() {
return fontsDirectory;
}

@IbisDoc({ "charset to be used to encode the given input string ", "UTF-8" })
public void setUnpackCommonFontsArchive(boolean unpackDefaultFonts) {
this.unpackDefaultFonts = unpackDefaultFonts;
}

@IbisDoc({ "charset to be used to encode the given input string", "UTF-8" })
public void setCharset(String charset) {
this.charset = charset;
}
public String getCharset() {
return charset;
}

@IbisDoc({ "aspose license location including the file name. It can also be used without license but there some restrictions on usage. If license is in resource, license attribute can be license file name. If the license is in somewhere in filesystem then it should be full path to file including filename and starting with file://// prefix. classloader.allowed.protocols property should contain 'file' protocol", "" })
public void setLicense(String license) {
Expand Down

0 comments on commit e159577

Please sign in to comment.