title: Replace text field itext
body: <p>I trying to replace text of a PDF created by OpenOffice using the example of the oficial itext page but i can't</p>
  
  <p><a href="http://developers.itextpdf.com/examples/stamping-content-existing-pdfs-itext5/replacing-pdf-objects" rel="nofollow noreferrer">http://developers.itextpdf.com/examples/stamping-content-existing-pdfs-itext5/replacing-pdf-objects</a></p>
  
  <p>I extract all the streams to a file but i don't localize the text that i want to replace.</p>
  
  <p>This is an example of manipulate PDF:</p>
  
  <pre><code>public void manipulatePdf(PdfReader reader,String temp) throws IOException, DocumentException {
  
      PdfObject obj;
      for (int i = 1; i &lt;= reader.getXrefSize(); i++) {
          obj = reader.getPdfObject(i);
  
          if (obj != null &amp;&amp; obj.isStream()) {
               PRStream stream = (PRStream)obj;
               byte[] b;
               try {
                   b = PdfReader.getStreamBytes(stream);
                   String p = new String(b);                     
                   //stream.setData(new String(p).replace("firmantes", "HELLO WORLD").getBytes());
                   stream.setData(p.replace("HOLA MUNDO", "mamamamamamamam").getBytes());
               }
               catch(UnsupportedPdfException e) {
                   b = PdfReader.getStreamBytesRaw(stream);
               }
               FileOutputStream fos = new FileOutputStream(String.format(DEST_STREAMS, i));
               fos.write(b);
               fos.flush();
               fos.close();
           }
        }
  }
  </code></pre>
  
  <p>My document only have the text "HOLA MUNDO".</p>
  
  <p>This is the stream that I think contains my data:</p>
  
  <pre><code>0.1 w
  q 0 0.1 595.2 841.8 re
  W* n
  q 0 0 0 rg
  BT
  56.8 774.1 Td /F1 12 Tf[&lt;01&gt;-2&lt;02&gt;-2&lt;03&gt;2&lt;04&gt;55&lt;0506&gt;-2&lt;07&gt;5&lt;08&gt;-2&lt;09&gt;5&lt;02&gt;]TJ
  ET
  Q
  Q 
  </code></pre>
  
  <p>Why can't I see the text?</p>
  
  <p>Thanks</p>