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