emile 1 year ago
parent d34c14bf66
commit f440a25e6d

@ -13,11 +13,11 @@
<body class="flex justify-center items-center" id="invoice-details-content">
<div class="w-[50%] flex flex-col items-center gap-5">
<img src="{% static 'images/ositcom_logos/full-logo.jpg' %}" class="w-[150px] h-[150px]">
<img src="https://ositcom.com/static/images/banner-logo.png" class="w-[150px] h-[150px]">
<div class="w-full flex flex-col gap-3 p-5">
<p class="text-gray-500">Bill To: <span class="text-secondosiblue">Winabig</span></p>
<p class="text-gray-500">Customer Details: <span class="text-secondosiblue">036466464</span></p>
<p class="text-gray-500" class="color:red;">Customer Details: <span class="text-secondosiblue">036466464</span></p>
</div>

@ -2,11 +2,11 @@ from django.shortcuts import render, get_object_or_404
from django.utils import timezone
from datetime import timedelta
from .models import *
from django.http import JsonResponse
from django.http import HttpResponse
from django.http import JsonResponse, HttpResponse
from django.template.loader import get_template
from weasyprint import HTML
# LISTING
def items (request, *args, **kwargs):
context = {
@ -114,14 +114,11 @@ def invoice_details (request, invoice_id):
def generate_pdf(request):
# Render the template
template = get_template('invoice.html')
html = template.render()
# Create a PDF file
pdf_file = HTML(string=html).write_pdf()
template = get_template('invoice-details.html')
context = {}
html_string = template.render(context)
# Prepare HTTP response
response = HttpResponse(pdf_file, content_type='application/pdf')
response['Content-Disposition'] = 'filename="invoice.pdf"'
pdf = HTML(string=html_string).write_pdf()
response = HttpResponse(pdf, content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="my_pdf.pdf"'
return response
Loading…
Cancel
Save