#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from reportlab.platypus import (
    Paragraph as BaseParagraph,
    Spacer,
)
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet


styles = getSampleStyleSheet()
snormal = ParagraphStyle('normal')


def Paragraph(text, style=snormal, **kw):
    if isinstance(style, basestring):
        style = styles[style]

    if kw:
        style = ParagraphStyle('style', parent=style, **kw)
    return BaseParagraph(text, style)


def HSpacer(width):
    return Spacer(0, width)

@@ -145,16 +145,40 @@
 agraph,%0A
+    Image as BaseImage,%0A
     Spac
@@ -592,8 +592,220 @@
  width)%0A
+%0A%0Adef Image(path, width=None, height=None, ratio=None):%0A    if width and ratio:%0A        height = width / ratio%0A    elif height and ratio:%0A        width = height * ratio%0A%0A    return BaseImage(path, width, height)%0A

Add a image shortcut to compute height and width with a ratio