For what you propose one potential solution is MuPDF/MuTool If you wish to decompile An existing PDF there are options in MuPDF-GL for windows using option A to convert to Ascii and “PrettyPrint”
You can write your own PDF as text but it can have limitations this is accepted as a working PDF
%PDF-1.2 4 0 obj << >> stream BT/ 36 Tf((Hello World!))' ET endstream endobj 3 0 obj << /Type /Page /Parent 2 0 R /Contents 4 0 R >> endobj 2 0 obj << /Kids [3 0 R ] /Count 1 /Type /Pages /MediaBox [ -195 -442 400 400 ] >> endobj 1 0 obj << /Pages 2 0 R /Type /Catalog >> endobj trailer << /Root 1 0 R > %%EOF
courtesy of Thomas see Create Memorystream of type pdf and return to browser
If you are “Hand balling” with UTF 16 chars on a “small device” it becomes a step harder see https://stackoverflow.com/a/68442444/10802527
More useful to producing your own many RaspberryPi users Compile PDF via MuTool Create https://mupdf.com/docs/manual-mutool-create.html
The Input Text to be translated during compilation is much simpler especially for image handling
%%MediaBox 0 0 612 792
%%Font TmRm Times-Roman
%%Font Helv-C Helvetica Cyrillic
%%Font Helv-G Helvetica Greek
%%Image I0 logo/ClientLogo.png
% Draw the image.
q
480 0 0 480 50 250 cm
/I0 Do
Q
% Draw a triangle. (Can be rectangles or a grid etc)
q
1 0 0 rg
50 50 m
100 200 l
200 50 l
f
Q
% Show some text. (Remember we humans work downwards, so 50 in then 760,730,700, etc. downwards)
q
0 0 1 rg
BT /TmRm 24 Tf 50 760 Td (Hello, from EPS32!) Tj ET
BT /Helv-C 24 Tf 50 730 Td <fac4d2c1d7d3d4d7d5cad4c521> Tj ET
BT /Helv-G 24 Tf 50 700 Td ( I am Line 3) Tj ET
Q
4
solved Is there a way to obtain Source Code of a PDF file in Windows?