All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jhonnymertz.wkhtmltopdf.wrapper.configurations.XvfbConfig Maven / Gradle / Ivy

Go to download

A Java based wrapper for the wkhtmltopdf command line tool. As the name implies, it uses WebKit to convert HTML documents to PDFs.

There is a newer version: 1.3.1-RELEASE
Show newest version
package com.github.jhonnymertz.wkhtmltopdf.wrapper.configurations;

import com.github.jhonnymertz.wkhtmltopdf.wrapper.params.Param;
import com.github.jhonnymertz.wkhtmltopdf.wrapper.params.Params;

import java.util.ArrayList;
import java.util.List;

/**
 * Wrapper for Xvfb parameters and configuration
 */
public class XvfbConfig {

    private final Params params = new Params();
    private String command;

    /**
     * Instantiates a new Xvfb config.
     */
    public XvfbConfig() {
        this("xvfb-run");
    }

    /**
     * Instantiates a new Xvfb config.
     *
     * @param command the command
     */
    public XvfbConfig(final String command) {
        setCommand(command);
    }

    /**
     * Add params.
     *
     * @param param  the param
     * @param params the params
     */
    public void addParams(final Param param, final Param... params) {
        this.params.add(param, params);
    }

    /**
     * Gets command.
     *
     * @return the command
     */
    public String getCommand() {
        return command;
    }

    /**
     * Sets command.
     *
     * @param command the command
     */
    public void setCommand(final String command) {
        this.command = command;
    }

    /**
     * Gets command line.
     *
     * @return the command line
     */
    public List getCommandLine() {
        List commandLine = new ArrayList<>();

        commandLine.add(getCommand());
        commandLine.addAll(params.getParamsAsStringList());

        return commandLine;
    }

    @Override
    public String toString() {
        return "{" +
                "command='" + command + '\'' +
                ", params=" + params +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy