com.github.jhonnymertz.wkhtmltopdf.wrapper.params.Params Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-wkhtmltopdf-wrapper Show documentation
Show all versions of java-wkhtmltopdf-wrapper Show documentation
A Java based wrapper for the wkhtmltopdf command line tool. As the name implies, it uses WebKit to
convert HTML documents to PDFs.
package com.github.jhonnymertz.wkhtmltopdf.wrapper.params;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
public class Params {
private Collection params;
public Params() {
this.params = new ArrayList();
}
public void add(Param param, Param... params) {
this.params.add(param);
this.params.addAll( Arrays.asList( params ) );
}
public List getParamsAsStringList() {
List commandLine = new ArrayList();
for (Param p : params) {
commandLine.add(p.getKey());
for (String value : p.getValues()) {
if (value != null) {
commandLine.add(value);
}
}
}
return commandLine;
}
@Override
public String toString() {
return StringUtils.join(params, "");
}
}