/************************************************************************** /* This class demonstrates the most primitive usage of iText. /* /* Copyright (c) 2004 by Bernhard Bablok (mail@bablokb.de) /* /* This program is free software; you can redistribute it and/or modify /* it under the terms of the GNU General Public License as published /* by the Free Software Foundation; either version 2 of the License or /* (at your option) any later version. /* /* This program 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 General Public License for more details. /* /* You should have received a copy of the GNU General Public License /* along with this program; see the file COPYING. If not, write to /* the Free Software Foundation Inc., 59 Temple Place - Suite 330, /* Boston, MA 02111-1307 USA /**************************************************************************/ import java.io.*; import com.lowagie.text.*; import com.lowagie.text.pdf.*; /** This class demonstrates the most primitive usage of iText. @version $Revision: 1.2 $ @author $Author: bablokb $ */ public class SimplePdf { ////////////////////////////////////////////////////////////////////////////// public static void main(String[] args) { try { SimplePdf pdf = new SimplePdf(); Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("SimplePdf.pdf")); pdf.addMetaInfo(document); document.open(); document.add(new Paragraph(pdf.getLines())); document.close(); } catch (Exception e) { e.printStackTrace(); } } ////////////////////////////////////////////////////////////////////////////// /** Read stdin into a String-object. */ private String getLines() throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); StringBuffer result = new StringBuffer(); String line; while((line = reader.readLine()) != null) result.append(line).append("\n"); return result.toString(); } ////////////////////////////////////////////////////////////////////////////// /** Add metainformation to the document. @param doc The document to add metainfo to */ private void addMetaInfo(Document doc) { doc.addTitle("A Simple PDF-Document"); doc.addSubject("PDF-Creation from Java"); doc.addKeywords("PDF Java Linux-Magazin Coffee-Shop"); doc.addAuthor("Bernhard Bablok"); doc.addCreator("Bernhard Bablok"); } }