Code: Select all
from django_minio_backend import MinioBackendStatic
from reportlab.lib.utils import ImageReader
def render_pdf(data: dict, image_url: str) -> io.BytesIO:
RGB_VAL = 50
# Create a file-like buffer to receive PDF data.
buffer = io.BytesIO()
# Register the Open Sans Font
font_file = MinioBackendStatic().open("/fonts/OpenSans-Regular.ttf")
pdfmetrics.registerFont(TTFont("OpenSans", font_file))
# Create the PDF object, using the buffer as its "file."
p = canvas.Canvas(buffer, pagesize=landscape(A4))
image = ImageReader(image_url) #