I have a list of strings where each element is a line of LaTex.
Using flask, how can I generate the pdf to be return on a request?
For example:
document = []
def add( toAdd ):
global document
document.append( toAdd )
def begin(item):
return "\\begin{"+str(item)+"}"
def end(item):
return "\\end{"+str(item)+"}"
@route('/pdf')
def populate_document( protocol, document ):
TITLE = "title"
AUTHOR = "author"
HEADER = "\\documentclass[12pt]{article}"
ENUMERATE = "enumerate"
DOCUMENT = "document"
STEPS = "steps"
steps = protocol[STEPS]
# KEEP AT TOP
add( HEADER )
# KEEP AT TOP
add( cmd( TITLE, protocol[TITLE] ) )
add( cmd( AUTHOR, protocol[AUTHOR] ) )
add( begin( DOCUMENT ) )
add( cmd( "section*", protocol[TITLE] ) )
add( end( ENUMERATE ) )
add( end( DOCUMENT ) )
### HOW TO COMPILE `document` and RETURN AS PDF?
I'm happy to clarify further if needed.
Thanks in advance.