簡體   English   中英

python 的 reportlab 中的“drawImage()”問題

[英]Problem with “drawImage()” in reportlab in python

我正在嘗試使用 reportlab 將許多圖像放入 PDF 中。 我已經創建了一個包含文件名的列表,並且需要程序到 go 通過在坐標中添加圖像的列表 (x=80, y=100; x=80, y=500; x=330, y=100 ; x=330, y=500)。 The problem I've encountered is that when I write the code to add the images the output PDF is blank (shows no page what so ever), it seems like it's overwriting the canvas.Canvas(".pdf") function.

這是 scrypt 的一部分:

for n in range(len(imagenes)): # "imagenes" 是包含文件名的列表

  imagen = imagenes[n]
  
  pdf.drawImage(f"{imagen}", x=80, y=100)
  
  n += 1
 
  pdf.drawImage(f"{imagen}", x=80, y=500)
  
  n += 1
  
  pdf.drawImage(f"{imagen}", x=330, y=100)
  
  n += 1
  
  pdf.drawImage(f"{imagen}", x=330, y=500)

據我所知,如果您要加載多個圖像,建議您先預加載所有圖像。 瀏覽此處獲取更多信息:

http://www.html5canvastutorials.com/tutorials/html5-canvas-image-loader/

另外,也許這個答案可以幫助你:

在一個 canvas 上繪制多個圖像

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM