ReportLab kann keine Ressource öffnen, wenn Minio (S3) vorgewiesen wirdPython

Python-Programme
Anonymous
 ReportLab kann keine Ressource öffnen, wenn Minio (S3) vorgewiesen wird

Post by Anonymous »

Ich verwende ReportLab in einem Container-Django-Projekt mit Django-Minio-Backend zum Speichern von Benutzern. Ich möchte ein PDF erstellen, das das hochgeladene Bild als Hintergrund verwendet.

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) #

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post