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

net.sf.nervalreports.generators.PDFImageSentence Maven / Gradle / Ivy

Go to download

This is the PDF generator package of NervalReports (a lightweight report creation library), used to generate a report directly to a .pdf file.

The newest version!
/** This file is part of nervalreports.
 *
 * nervalreports is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * nervalreports is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with nervalreports.  If not, see . */
package net.sf.nervalreports.generators;

import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;

/* default */ class PDFImageSentence extends PDFSentence {
	
	private final PDImageXObject image;
	
	/** Default constructor.
	 * @param image image to be used as sentence.
	 * @param width desired width to render the image at the sentence.
	 * @param height desired height to render the image at the sentence. */
	/* default */ PDFImageSentence(PDImageXObject image, float width, float height) {
		super(Type.PDF_IMAGE_SENTENCE);
		this.image = image;
		setWidth(width);
		setHeight(height);
	}

	/** {@inheritDoc} */
	@Override
	void flush(PDPageContentStream pageContentStream, float x, float y) throws Exception {
		pageContentStream.drawImage(image, x, y, getWidth(), getHeight());
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy