Django&reportlab:在同一页面的div上显示生成的pdf

问题描述 投票:0回答:1

我使用reportlab生成pdfs,我的视图如下:

def statut(request,id):
# Set up response
infoSte=sarl.objects.get(id=id)
associe=Associee.objects.all().filter(id_sarl=id)

associe_gerant=0
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'filename="form_letter.pdf"'
buff = BytesIO()
menu_pdf = SimpleDocTemplate(buff, rightMargin=60,
                            leftMargin=60, topMargin=65, bottomMargin=65)
story = []
#APPENDING PDF CONTENT ..
story.append(Paragraph(denomination_so,styleN))
menu_pdf.multiBuild(story, canvasmaker=FooterCanvas)
response.write(buff.getvalue())
buff.close()
return response 

使用下面的URL呈现此视图

url(r'^pdfstatut/(?P<id>\d+)$',views.statut, name='statutJuridique'),

当exacuting这个url时,pdf是在专用页面上生成的。我需要的是当我点击页面左侧的链接statut时,pdf显示在右侧的部分:

enter image description here

当我的视图仅返回仅为pdf的响应时,如何实现此类结果。

django templates django-views reportlab
1个回答
0
投票

你可以使用一个名为PDF的JS对象,如下所述:Pdf object

或非JS,如下所述:Static

© www.soinside.com 2019 - 2024. All rights reserved.