title: Creating a pdf file in android programmatically and writing in it
body: <p>I'm trying to create a pdf file inside my app, save it on the external storage the open it. Saving a file isn't an issue for me, nor is opening one, my issue is with creating one and writing in it. So after some research online I found the following way of doing it:</p>
  <pre><code>File file = new File(directoryName, fileName);
  
  // Creating output stream to write in the newly created file
  FileOutputStream fOut = null;
  
  try {
      fOut = new FileOutputStream(file);
  } catch (FileNotFoundException e) {
      e.printStackTrace();
  }
  
  // Creating a new document
  Document document = new Document(PageSize.A4, 50, 50, 50, 50);
  
  try {
      PdfWriter.getInstance(document, fOut);
  
      // Open the document for writing
      document.open();
  
      // Write in the document
      document.add(new Paragraph(&quot;Hello world&quot;));
      document.close();
  
  } catch (DocumentException de) {
      System.err.println(de.getMessage());
  }
  </code></pre>
  <p>Upon running my app and executing the code above, I get the following error:</p>
  <pre><code>java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/Color;
  </code></pre>
  <p>Would someone know what's the issue with my code, or of another way that is sure to work for creating and writing a pdf file ?</p>
  <p>Thanks !</p>