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

pro.verron.officestamper.preset.Image Maven / Gradle / Ivy

Go to download

Office-stamper is a Java template engine for docx documents, forked from org.wickedsource.docx-stamper

The newest version!
package pro.verron.officestamper.preset;

import org.apache.commons.io.IOUtils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * This class describes an image which will be inserted into a document.
 *
 * @author Joseph Verron
 * @author Romster
 * @version ${version}
 * @since 1.0.0
 */
public final class Image {

    /**
     * TODO_LATER: make private asap
     */
    private final byte[] imageBytes;

    /**
     * TODO_LATER: make private asap
     */
    private Integer maxWidth;

    /**
     * 

Constructor for Image.

* * @param in - content of the image as InputStream * @throws IOException if any. */ public Image(InputStream in) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(in, out); this.imageBytes = out.toByteArray(); } /** *

Constructor for Image.

* * @param in - content of the image as InputStream * @param maxWidth - max width of the image in twip * @throws IOException if any. */ public Image(InputStream in, Integer maxWidth) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(in, out); this.imageBytes = out.toByteArray(); this.maxWidth = maxWidth; } /** *

Constructor for Image.

* * @param imageBytes - content of the image as an array of the bytes */ public Image(byte[] imageBytes) { this.imageBytes = imageBytes; } /** *

Constructor for Image.

* * @param imageBytes - content of the image as an array of the bytes * @param maxWidth - max width of the image in twip */ public Image(byte[] imageBytes, Integer maxWidth) { this.imageBytes = imageBytes; this.maxWidth = maxWidth; } /** *

Getter for the field maxWidth.

* * @return a {@link Integer} object */ public Integer getMaxWidth() { return maxWidth; } /** *

Getter for the field imageBytes.

* * @return an array of {@link byte} objects */ public byte[] getImageBytes() { return imageBytes; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy