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.
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 "PDF Layout just like this one:
PDF Layout Example
PDF Layout Table Example
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:
%PDF-1.4
1 0 obj
<< /Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R
>>
endobj
2 0 obj
<< /Type /Outlines
/Count 0
>>
endobj
3 0 obj
<< /Type /Pages
/Kids [ 4 0 R ]
/Count 1
>>
endobj
4 0 obj
<< /Type /Page
/Parent 3 0 R
/MediaBox [ 0 0 612 792 ]
/Contents 5 0 R
/Resources << /ProcSet 6 0 R
/Font << /F1 7 0 R >>
>>
>>
endobj
5 0 obj
<< /Length 73 >>
stream
BT
/F1 24 Tf
100 100 Td
( Hello World ) Tj
ET
endstream
endobj
6 0 obj
[ /PDF /Text ]
endobj
7 0 obj
<< /Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
/Encoding /MacRomanEncoding
>>
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
<< /Size 8
/Root 1 0 R
>>
startxref
625
%%EOF
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.