python - reportlab save location -
python - reportlab save location -
i trying save pdf file generated reportlab specific location. possible? code creates pdf own directory.
def myfirstpage(canvas, doc): canvas.savestate() canvas.setfont('times-bold',16) canvas.drawcentredstring(page_width/2.0, page_height-108, title) canvas.setfont('times-roman',9) canvas.restorestate() def create_pdf(sometext): doc = simpledoctemplate("myfile.pdf") story = [spacer(1,2*inch)] style = styles["normal"] bogustext = ("there something: %s. " % sometext) p = paragraph(bogustext, style) story.append(p) story.append(spacer(1,0.2*inch)) doc.build(story, onfirstpage=myfirstpage)
yes, possible. recommend using os.path.join
build path. example:
import os def create_pdf(sometext): outfilename = "myfile.pdf" outfiledir = '/somedir' outfilepath = os.path.join( outfiledir, outfilename ) doc = simpledoctemplate( outfilepath ) # ...
python location save reportlab
Comments
Post a Comment