Ejemplo n.º 1
0
    def asString(self, format, verbose=None, preview=0, **kw):
        """Converts to an 8 bit string in given format."""
        assert format in ('pdf','ps','eps','gif','png','jpg','jpeg','bmp','ppm','tiff','tif','py','pict','pct','tiffp','tiffl','tiff1'), 'Unknown file format "%s"' % format
        from reportlab import rl_config
        #verbose = verbose is not None and (verbose,) or (getattr(self,'verbose',verbose),)[0]
        if format == 'pdf':
            from reportlab.graphics import renderPDF
            return renderPDF.drawToString(self)
        elif format in ('gif','png','tif','tiff','jpg','pct','pict','bmp','ppm','tiffp','tiffl','tiff1'):
            from reportlab.graphics import renderPM
            return renderPM.drawToString(self, fmt=format,showBoundary=getattr(self,'showBorder',
                            rl_config.showBoundary),**_extraKW(self,'_renderPM_',**kw))
        elif format == 'eps':
            try:
                from rlextra.graphics import renderPS_SEP as renderPS
            except ImportError:
                from reportlab.graphics import renderPS

            return renderPS.drawToString(self,
                                preview = preview,
                                showBoundary=getattr(self,'showBorder',rl_config.showBoundary))
        elif format == 'ps':
            from reportlab.graphics import renderPS
            return renderPS.drawToString(self, showBoundary=getattr(self,'showBorder',rl_config.showBoundary))
        elif format == 'py':
            return self._renderPy()
Ejemplo n.º 2
0
    def asString(self, format, verbose=None, preview=0, **kw):
        """Converts to an 8 bit string in given format."""
        assert format in (
            "pdf",
            "ps",
            "eps",
            "gif",
            "png",
            "jpg",
            "jpeg",
            "bmp",
            "ppm",
            "tiff",
            "tif",
            "py",
            "pict",
            "pct",
            "tiffp",
            "tiffl",
            "tiff1",
        ), ('Unknown file format "%s"' % format)
        from reportlab import rl_config

        # verbose = verbose is not None and (verbose,) or (getattr(self,'verbose',verbose),)[0]
        if format == "pdf":
            from reportlab.graphics import renderPDF

            return renderPDF.drawToString(self)
        elif format in ("gif", "png", "tif", "tiff", "jpg", "pct", "pict", "bmp", "ppm", "tiffp", "tiffl", "tiff1"):
            from reportlab.graphics import renderPM

            return renderPM.drawToString(
                self,
                fmt=format,
                showBoundary=getattr(self, "showBorder", rl_config.showBoundary),
                **_extraKW(self, "_renderPM_", **kw)
            )
        elif format == "eps":
            try:
                from rlextra.graphics import renderPS_SEP as renderPS
            except ImportError:
                from reportlab.graphics import renderPS

            return renderPS.drawToString(
                self, preview=preview, showBoundary=getattr(self, "showBorder", rl_config.showBoundary)
            )
        elif format == "ps":
            from reportlab.graphics import renderPS

            return renderPS.drawToString(self, showBoundary=getattr(self, "showBorder", rl_config.showBoundary))
        elif format == "py":
            return self._renderPy()