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()
The origin is at the bottom left.
pdf_cnvs = canvas.Canvas('./spam.pdf',bottomup=False)
It will be like this.
pdf_cnvs.drawInlineImage(image,0,-image.size[1])
It is drawn from the upper left, but it is rotated 180 degrees.
-- When I paste an image with drawInlineImage, a case occurs that is interrupted on the ipad. If you read it on ipad, drawImage was better.
Recommended Posts