Just a quick “did you know?” JSON files can not only be loaded to extract the text content with Page.get_text()
, but also faithfully rendered with any indentation, just do:
import pymupdf
doc = pymupdf.open("my_data.json", filetype="txt")
pdfdata = doc.convert_to_pdf()
with open('output.pdf', 'wb') as f:
f.write(pdfdata)