In the LaTeX template, you add custom metadata to include box location information inside the PDF. I am using typst to generate the exam sheet, and I cannot generate non-standard PDF metadata. However, I can embed a file in the generated PDF.
For example, here is a PDF file with an embedded "correctexam.json" file containing:
{"answerboxes":{"lastname":{"x":3.196,"y":2.3,"w":15.1,"h":0.8,"p":1},"firstname":{"x":3.196,"y":3.3,"w":1
5.1,"h":0.8,"p":1},"stdid":{"x":3.196,"y":4.3,"w":6.3,"h":0.8,"p":1},"answer-1-1":{"x":1.5,"y":17.509,"w":
18.0,"h":6.0,"p":1},"answer-2-1":{"x":1.5,"y":27.225,"w":18.0,"h":6.0,"p":1},"answer-3-1":{"x":1.5,"y":11.
532,"w":18.0,"h":6.0,"p":2}}}
Right now, I use a small program that I wrote to extract the embedded JSON file and reinject custom metadata in the PDF to get it parsed by correctexam, but it would be great if correctexam could directly extract the "correctexam.json" stream from the PDF and use the data inside. This is "cleaner" than using custom metadata.
typst-example.pdf
If you want to look at the embedded JSON file, you can use mutool (from mupdf):
$ mutool show -b typst-example.pdf 138
138 0 obj
<<
/Type /Filespec
/F (correctexam.json)
/UF (correctexam.json)
/EF <<
/F 137 0 R
/UF 137 0 R
>>
/Desc (Metadata for CorrectExam)
>>
endobj
$ mutool show -b typst-example.pdf 137
{"answerboxes":{"lastname":{"x":3.196,"y":2.3,"w":15.1,"h":0.8,"p":1},"firstname":{"x":3.196,"y":3.3,"w":15.1,"h":0.8,"p":1},"stdid":{"x":3.196,"y":4.3,"w":6.3,"h":0.8,"p":1},"answer-1-1":{"x":1.5,"y":17.509,"w":18.0,"h":6.0,"p":1},"answer-2-1":{"x":1.5,"y":27.225,"w":18.0,"h":6.0,"p":1},"answer-3-1":{"x":1.5,"y":11.532,"w":18.0,"h":6.0,"p":2}}}⏎
In the LaTeX template, you add custom metadata to include box location information inside the PDF. I am using typst to generate the exam sheet, and I cannot generate non-standard PDF metadata. However, I can embed a file in the generated PDF.
For example, here is a PDF file with an embedded "correctexam.json" file containing:
{"answerboxes":{"lastname":{"x":3.196,"y":2.3,"w":15.1,"h":0.8,"p":1},"firstname":{"x":3.196,"y":3.3,"w":1 5.1,"h":0.8,"p":1},"stdid":{"x":3.196,"y":4.3,"w":6.3,"h":0.8,"p":1},"answer-1-1":{"x":1.5,"y":17.509,"w": 18.0,"h":6.0,"p":1},"answer-2-1":{"x":1.5,"y":27.225,"w":18.0,"h":6.0,"p":1},"answer-3-1":{"x":1.5,"y":11. 532,"w":18.0,"h":6.0,"p":2}}}Right now, I use a small program that I wrote to extract the embedded JSON file and reinject custom metadata in the PDF to get it parsed by correctexam, but it would be great if correctexam could directly extract the "correctexam.json" stream from the PDF and use the data inside. This is "cleaner" than using custom metadata.
typst-example.pdf
If you want to look at the embedded JSON file, you can use
mutool(frommupdf):