Am 06.06.2016 um 08:02 schrieb Krishnakant:
> Then I would want an ajax call to get the pdf from that view callable.
> So in the ajax call using jquery I can set application/pdf, but what
> should I write in the renderer in view_config is my question.
> And should I return the pdf as a value of a key in return?
You don't need a renderer, just pass the PDF as the body of a Response:
def pdf_view(request):
output = BytesIO()
doc = BaseDocTemplate(output, pagesize=...)
story = []
...
story.append(Paragraph(...))
...
doc.build(story)
body = output.getvalue()
output.close()
return Response(body=body, content_type='application/pdf',
content_disposition='inline; filename="myfile.pdf"')
I usually create a view class and use a method instead. Then you can add
helper methods to the same class, like onPage() and onPageEnd().
-- Christoph