How to send PDF and show in the html

14 views
Skip to first unread message

Erika Bazurto

unread,
Oct 7, 2016, 1:13:37 PM10/7/16
to Django REST framework
my code is:
view

class PDFHandler(APIView):
class SimpleExample(APIView):
renderer_classes = (PDFRenderer)

def get(self, request):
pdf = BytesIO()

gen_pdf = canvas.Canvas(pdf)
gen_pdf.drawString(100, 100, 'Simple example')
gen_pdf.showPage()
gen_pdf.save()

return PDFResponse(
pdf.getvalue(),
file_name='example',
status=status.HTTP_200_OK
)

html : 

<input id="new" type = "button" value = "crear archivo">
<script>
$(function () {
$('#new').click(function() {
$.ajax({
type: "GET",
dataType: "JSON",
url: "/pdf/",
contentType: "application/json;charset= utf-8",
success: function (data) {
}
})
});
});
</script>
result in the page is 

how to send PDF and show in the html???? :S


Reply all
Reply to author
Forward
0 new messages