当前位置: 首页>>代码示例>>Python>>正文


Python ImageReader.hAlign方法代码示例

本文整理汇总了Python中reportlab.lib.utils.ImageReader.hAlign方法的典型用法代码示例。如果您正苦于以下问题:Python ImageReader.hAlign方法的具体用法?Python ImageReader.hAlign怎么用?Python ImageReader.hAlign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reportlab.lib.utils.ImageReader的用法示例。


在下文中一共展示了ImageReader.hAlign方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getImage

# 需要导入模块: from reportlab.lib.utils import ImageReader [as 别名]
# 或者: from reportlab.lib.utils.ImageReader import hAlign [as 别名]
        def getImage(img_obj, scale=True, reader=False, width=max_image_width, style="", column_count=column_count, caption="", leadImage=False, hAlign=None, body_image=True):

            if not leadImage and body_image and column_count == 1:
                # Special case to make one column body images 66% of the page
                width = 1.33*width

            img_width = img_obj.width
            img_height = img_obj.height

            if scale and (img_width > width):
                img_height = (width/img_width)*img_height
                img_width = width

            if hasattr(img_obj, 'data'):
                if hasattr(img_obj.data, 'data'):
                    img_data = BytesIO(img_obj.data.data)
                else:
                    img_data = BytesIO(img_obj.data)
            elif hasattr(img_obj, '_data'):
                img_data = BytesIO(img_obj._data)
            else:
                img_data = BytesIO('')

            if reader:
                img = ImageReader(img_data)
            else:
                if caption or leadImage:
                    img = ImageFigure(img_data, caption=caption, width=img_width, height=img_height, align="right", max_image_width=width, column_count=column_count)
                else:
                    img = Image(img_data, width=img_width, height=img_height)

            if style:
                img.style = style

            if hAlign:
                img.hAlign = hAlign
            elif column_count == 1:
                img.hAlign = TA_LEFT
            else:
                img.hAlign = TA_CENTER

            return img
开发者ID:tsimkins,项目名称:agsci.ExtensionExtender,代码行数:44,代码来源:pdf.py


注:本文中的reportlab.lib.utils.ImageReader.hAlign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。