title: How to Write PDF using Java
body: <p>I need to write some text in to a PDF document using Java. I wrote a code for that. But i'm unable to open the file. If you guys have some idea please share with me. </p>
  
  <pre><code>public class WritPDF
  {
  
      public static void main(String[] args)
      {
          Writer writer = null;
  
          try
              {
                  String text = "This is a text file";
  
                  File file = new File("C:/Users/PrinterTest/Hi1.pdf");
                  writer = new BufferedWriter(new FileWriter(file));;
                  writer.write(text);
              } catch (FileNotFoundException e)
              {
                  e.printStackTrace();
              } catch (IOException e)
              {
                  e.printStackTrace();
              } finally
              {
                  try
                      {
                          if (writer != null)
                              {           
                              }
                      } catch (IOException e)
                      {}
              }
      }
  
  }
  </code></pre>