title: Android PDF Writer(APW) Enconding
body: <p>I am using Android PDF Write(APW) to create a PDF, but it doesn't work with some special characters(portuguese).</p>
  
  <pre><code>mypdf.addText(170, 50, 40,"Coração");
  </code></pre>
  
  <p>The standard enconding is:</p>
  
  <pre><code>mypdf.setFont(StandardFonts.SUBTYPE, StandardFonts.COURIER, StandardFonts.WIN_ANSI_ENCODING);
  outputToFile("helloworld.pdf",pdfcontent,"ISO-8859-1");
  </code></pre>
  
  <p>I'v tried</p>
  
  <pre><code>outputToFile("helloworld.pdf",pdfcontent,"UTF-8");
  outputToFile("helloworld.pdf",pdfcontent,"UTF-16");
  outputToFile("helloworld.pdf",pdfcontent,"Cp1252");
  </code></pre>
  
  <p>and didn't succeed.
  Any ideas what should I do?</p>
  
  <p>EDIT</p>
  
  <p>The method outputToFile is defined as:</p>
  
  <pre><code>    private void outputToFile(String fileName, String pdfContent, String encoding) {
      File newFile = new File(Environment.getExternalStorageDirectory() + "/" + fileName);
      try {
          newFile.createNewFile();
          try {
              FileOutputStream pdfFile = new FileOutputStream(newFile);
              pdfFile.write(pdfContent.getBytes(encoding));
              pdfFile.close();
          } catch(FileNotFoundException e) {
              //
          }
      } catch(IOException e) {
          //
      }
  }
  </code></pre>
  
  <p>The method addText is defined as:</p>
  
  <pre><code>    public void addText(int leftPosition, int topPositionFromBottom, int fontSize, String text, String transformation) {
      addContent(
          "BT\n" +
          transformation + " " + Integer.toString(leftPosition) + " " + Integer.toString(topPositionFromBottom) + " Tm\n" +
          "/F" + Integer.toString(mPageFonts.size()) + " " + Integer.toString(fontSize) + " Tf\n" +
          "(" + text + ") Tj\n" +
          "ET\n"
      );
  }
  </code></pre>
  
  <p>Besides, I change the font color to white adding the following rawcontent:</p>
  
  <pre><code>mypdf.addRawContent("1 1 1 rg\n"); 
  </code></pre>
  
  <p>Then I come back to the black font color:</p>
  
  <pre><code>    mypdf.addRawContent("0 0 0 rg\n");
  </code></pre>