-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCanvaPDF
More file actions
34 lines (26 loc) · 929 Bytes
/
CanvaPDF
File metadata and controls
34 lines (26 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from reportlab.pdfgen import canvas
# Solicitar datos de una persona
nombre = input("Ingrese el nombre: ")
edad = input("Ingrese la edad: ")
ciudad = input("Ingrese la ciudad: ")
# Imprimir los datos ingresados
print("\nDatos de la persona:")
print("Nombre:", nombre)
print("Edad:", edad)
print("Ciudad:", ciudad)
# Generar PDF con los datos
pdf_filename = "datos_persona.pdf"
# Crear el documento PDF
pdf_canvas = canvas.Canvas(pdf_filename)
# Configurar el formato y la posición para mostrar los datos
text_object = pdf_canvas.beginText(100, 700)
text_object.setFont("Helvetica", 12)
text_object.textLine("Datos de la persona:")
text_object.textLine("Nombre: " + nombre)
text_object.textLine("Edad: " + edad)
text_object.textLine("Ciudad: " + ciudad)
# Agregar los datos al PDF
pdf_canvas.drawText(text_object)
# Guardar el PDF
pdf_canvas.save()
print(f"\nLos datos se han guardado en el archivo PDF: {pdf_filename}")