List of usage examples for com.itextpdf.text Image getInstance
public static Image getInstance(final java.awt.Image image, final java.awt.Color color) throws BadElementException, IOException
From source file:pipe.PdfMaker.java
private void addTitlePage(Document document) throws DocumentException { Paragraph preface = new Paragraph(); // We add one empty line addEmptyLine(preface, 1);// w w w.jav a 2 s .co m // Lets write a big header Paragraph para = new Paragraph("Meine Pfeifensammlung", catFont); para.setAlignment(Element.ALIGN_CENTER); preface.add(para); addEmptyLine(preface, 1); // Will create: Report generated by: _name, _date preface.add(new Paragraph("Erstellt von: " + System.getProperty("user.name"), arialSmall)); addEmptyLine(preface, 7); Image image = null; String frontpic = "db" + File.separator + "pipe-frontpage.jpg"; try { ImageIcon icon = new ImageIcon(frontpic.toString()); java.awt.Image img = icon.getImage(); java.awt.Image newimg = img.getScaledInstance(500, -1, java.awt.Image.SCALE_SMOOTH); image = Image.getInstance(newimg, null); } catch (BadElementException e) { } catch (MalformedURLException e) { } catch (IOException e) { } Paragraph picture = new Paragraph(""); picture.setAlignment(Element.ALIGN_CENTER); picture.add(image); preface.add(picture); addEmptyLine(preface, 10); preface.add(new Paragraph( "Dieser Katalog wurde mit Mat's pipe-manager erstellt.\nDie Software ist frei verfgbar und herunterladbar ber das Forum von www.komm-zur-pfeife.de.", arialSmall)); document.add(preface); // Start a new page document.newPage(); }
From source file:pipe.PdfMaker.java
private Image fourthLogoElement(String path) throws BadElementException { //String path = "/home/meteor/pipe-manager/pictures/1_Vauen_Basic/03.jpg"; Image image = null;//from w ww. j a v a2 s . com try { ImageIcon icon = new ImageIcon(path.toString()); java.awt.Image img = icon.getImage(); java.awt.Image newimg = img.getScaledInstance(154, -1, java.awt.Image.SCALE_SMOOTH); image = Image.getInstance(newimg, null); } catch (BadElementException e) { } catch (MalformedURLException e) { } catch (IOException e) { } return image; }