title: Is there a way to obtain Source Code of a PDF file in Windows?
body: <p>I've been looking a way to obtain the source code of a PDF file, not the HEX code but a plain text code, my intention is to code a PDF file from plain text, that way I can create a PDF report with a ESP32 or maybe an Arduino board, uploading the source code to a program, save it to an SD card and rename it with a .pdf extension.</p>
  <p>I know it's more complicated than just add lines and Strings like you would do with an HTML document. If I add or delete an object the file will be corrupted, but the plan is to generate a &quot;PDF Layout just like this one:</p>
  <p><a href="https://i.stack.imgur.com/czekc.png" rel="nofollow noreferrer">PDF Layout Example</a><br />
  <a href="https://i.stack.imgur.com/7egjq.png" rel="nofollow noreferrer">PDF Layout Table Example</a></p>
  <p>That way I wouldn't be deleting or adding any objects, just modifying the String that already exists. I found I can generate PDF files from a text editor like NotePad using plain text like this example:</p>
  <pre><code>    %PDF-1.4
  1 0 obj
    &lt;&lt; /Type /Catalog
        /Outlines 2 0 R
        /Pages 3 0 R
    &gt;&gt;
  endobj
  
  2 0 obj
    &lt;&lt; /Type /Outlines
        /Count 0
    &gt;&gt;
  endobj
  
  3 0 obj
    &lt;&lt; /Type /Pages
        /Kids [ 4 0 R ]
        /Count 1
    &gt;&gt;
  endobj
  
  4 0 obj
    &lt;&lt; /Type /Page
        /Parent 3 0 R
        /MediaBox [ 0 0 612 792 ]
        /Contents 5 0 R
        /Resources &lt;&lt; /ProcSet 6 0 R
        /Font &lt;&lt; /F1 7 0 R &gt;&gt;
    &gt;&gt;
  &gt;&gt;
  endobj
  
  5 0 obj
    &lt;&lt; /Length 73 &gt;&gt;
  stream
    BT
      /F1 24 Tf
      100 100 Td
      ( Hello World ) Tj
    ET
  endstream
  endobj
  
  6 0 obj
    [ /PDF /Text ]
  endobj
  
  7 0 obj
    &lt;&lt; /Type /Font
      /Subtype /Type1
      /Name /F1
      /BaseFont /Helvetica
      /Encoding /MacRomanEncoding
    &gt;&gt;
  endobj
  
  xref
  0 8
  0000000000 65535 f
  0000000009 00000 n
  0000000074 00000 n
  0000000120 00000 n
  0000000179 00000 n
  0000000364 00000 n
  0000000466 00000 n
  0000000496 00000 n
  
  trailer
    &lt;&lt; /Size 8
      /Root 1 0 R
    &gt;&gt;
  startxref
  625
  %%EOF
  </code></pre>
  <p>So I've been searching a way to extract that kind of code from my PDF layout but I've been only capable of extracting the HEX code which is kind of useless for my purpose. I would be grateful on any help or guidance on this project.</p>