LoginSignup
6
7

More than 5 years have passed since last update.

reportlabで画像追加メモ

Last updated at Posted at 2014-01-25

bottomup指定なしの場合

filename = 'pdftest'
# -*- coding: utf-8 -*-
from reportlab.pdfgen import canvas
from PIL import Image

image =Image.open('/Users/momiji/work/spam.jpg')

pdf_cnvs = canvas.Canvas('./spam.pdf' )  
pdf_cnvs.setPageSize((image.size[0]+10,image.size[1]+10))
pdf_cnvs.drawInlineImage(image,0,0)
pdf_cnvs.save()

スクリーンショット 2014-01-25 22.28.59.png

原点が左下。

-

bottmup=Falseの場合

pdf_cnvs = canvas.Canvas('./spam.pdf',bottomup=False)  

スクリーンショット 2014-01-25 22.42.18.png
こうなる。

-

y座標を変更する

pdf_cnvs.drawInlineImage(image,0,-image.size[1])

スクリーンショット 2014-01-25 23.04.57.png

左上から描画されるが、180度回転している。

--
drawInlineImageで画像を貼ると、ipadで途中で途切れる事案発生。
ipadで読むならdrawImageのほうが良かった。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7