[reportlab-users] drawImage produces blank page only

Bernd Prager bernd at prager.ws
Thu Dec 29 17:50:51 EST 2005


> ----------------------------------------------------------------------
>

>
> I think your problem is in the sizing.  ReportLab defines pages in points.
> im.size returns pixels.  You must define your pagesize in points and then
> drawInlineImage on it.
>
> This works for me (not tested).  Try:
>
>     from reportlab.lib.pagesizes import letter
>
>     formwidthinpoints, formheightinpoints=letter
>     Canvas=canvas.Canvas(FAX.PDFfilename,  pageCompression=1,
>     formwidthinpoints, formheightinpoints=letter
>
>      Canvas.drawInlineImage('out300.jpg', 0, 0,
>          pagesize=letter)
>
>
> Larry Bates
>
I solved this problem, but you still have an interesting point though Larry.

I scan a document and trim it. I don't know the size upfront and want to
preserve the original size if possible.
All I know is the resolution of 300dpi.
The pixel size I can determine with Image.size.
I tested the script with the assumptions points == pixels and it worked,
but that might have been dumb luck. How do I do it correctly?
How do I get the points from it?

-- Bernd



More information about the reportlab-users mailing list