Spaces:
Runtime error
Runtime error
Create generate_pdf.py
Browse files- generate_pdf.py +23 -0
generate_pdf.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from reportlab.lib.pagesizes import letter
|
| 2 |
+
from reportlab.pdfgen import canvas
|
| 3 |
+
|
| 4 |
+
def create_pdf(quote_data):
|
| 5 |
+
# Define file path for saving the PDF
|
| 6 |
+
file_name = "/mnt/data/quote_invoice.pdf"
|
| 7 |
+
|
| 8 |
+
# Create the PDF
|
| 9 |
+
c = canvas.Canvas(file_name, pagesize=letter)
|
| 10 |
+
|
| 11 |
+
# Add Quote Data to PDF
|
| 12 |
+
c.drawString(100, 750, f"Customer: {quote_data['records'][0]['Customer_Name__c']}")
|
| 13 |
+
c.drawString(100, 730, f"Quote Date: {quote_data['records'][0]['Quote_Date__c']}")
|
| 14 |
+
c.drawString(100, 710, f"Origination Location: {quote_data['records'][0]['Origination_Location__c']}")
|
| 15 |
+
c.drawString(100, 690, f"Total Amount: {quote_data['records'][0]['Total_Amount__c']}")
|
| 16 |
+
|
| 17 |
+
c.save() # Save the PDF
|
| 18 |
+
|
| 19 |
+
return file_name
|
| 20 |
+
|
| 21 |
+
# Call the function to generate PDF from fetched quote data
|
| 22 |
+
pdf_file = create_pdf(quote_data)
|
| 23 |
+
print("PDF generated:", pdf_file)
|