Example usage for com.lowagie.text Image absoluteY

List of usage examples for com.lowagie.text Image absoluteY

Introduction

In this page you can find the example usage for com.lowagie.text Image absoluteY.

Prototype

float absoluteY

To view the source code for com.lowagie.text Image absoluteY.

Click Source Link

Document

This is the absolute Y-position of the image.

Usage

From source file:com.compomics.pepshell.controllers.dataexport.PDFExport.java

License:Apache License

@Override
public void exportImage(BufferedImage imageToExport, String filename) {
    File exportFile = new File(ProgramVariables.EXPORTFOLDER, filename + ".pdf");
    if (append && exportFile.exists()) {

    } else {/*from   w  w  w. j a  v  a  2  s  . c o m*/
        File exportImageFile = new File(System.getProperty("file.temp"), filename);
        try {
            ImageIO.write(imageToExport, "png", new FileOutputStream(exportImageFile));
            Image pdfImage = Image.getInstance(exportImageFile.getAbsolutePath());
            Document document = new Document(new Rectangle(pdfImage.absoluteX(), pdfImage.absoluteY()));
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(exportFile));
            document.open();
            document.newPage();
            document.add(pdfImage);
            document.close();
        } catch (DocumentException | IOException ex) {
            FaultBarrier.getInstance().handleException(ex);
        }
    }
}