List of usage examples for com.lowagie.text Image absoluteX
float absoluteX
To view the source code for com.lowagie.text Image absoluteX.
Click Source Link
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 {//w ww. j a v a 2s . c om 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); } } }