Java tutorial
/******************************************************************************* * * PDF Output Writer - Pentaho Kettle Step plugin * * Author: Rishu Shrivastava * * ******************************************************************************* * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************************/ package pentaho.kettle.step.plugs.pdfout; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import org.pentaho.di.core.Const; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfWriter; /** * This class is used to generate the PDF document for the incoming rows. * @author Rishu * */ public class PDFOutputGenerate { public void generatePDF(String OutputFileName) throws IOException { if (Const.isWindows()) { if (OutputFileName.startsWith("file:///")) OutputFileName = OutputFileName.substring(8); OutputFileName = OutputFileName.replace("\\", "\\\\"); } Document document = new Document(); PdfWriter writer; try { writer = PdfWriter.getInstance(document, new FileOutputStream(OutputFileName)); document.open(); document.add(new Paragraph("Hello Rishu Here !!")); /* * Setting up File Attributes - Document Description */ document.addAuthor("Rishu Shrivastava"); document.addCreationDate(); document.addCreator("Rishu"); document.addTitle("Set Attribute Example"); document.addSubject("An example to show how attributes can be added to pdf files."); document.close(); writer.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } } }