def saveImage(self, paths, multipage=None):
        """
        Save or export the canvas to a specified format.
        The argument `paths` can either be a single path or a list of paths.

        The file extension is important because it will determine the format in which the image will be exported.

        All supported file extensions: `pdf`, `svg`, `png`, `jpg`, `jpeg`, `tiff`, `tif`, `gif`, `bmp` and `mov`.

        * A `pdf` can be multipage. If `multipage` is `False` only the current page is saved.
        * A `mov` will use each page as a frame.
        * A `gif` can be animated when there are multiple pages and it will use each page as a frame.
        * All images and `svg` formats will only save the current page. If `multipage` is `True` all pages are saved to disk (a page index will be added to the file name).

        .. showcode:: /../examples/saveImage.py
        """
        if isinstance(paths, (str, unicode)):
            paths = [paths]
        for rawPath in paths:
            path = optimizePath(rawPath)
            dirName = os.path.dirname(path)
            if not os.path.exists(dirName):
                raise DrawBotError("Folder '%s' doesn't exists" % dirName)
            base, ext = os.path.splitext(path)
            ext = ext.lower()[1:]
            if not ext:
                ext = rawPath
            context = getContextForFileExt(ext)
            if context is None:
                raise DrawBotError(
                    "Did not found a supported context for: '%s'" % ext)
            self._drawInContext(context)
            context.saveImage(path, multipage)
    def saveImage(self, paths, multipage=None):
        """
        Save or export the canvas to a specified format.
        The argument `paths` can either be a single path or a list of paths.

        The file extension is important because it will determine the format in which the image will be exported.

        All supported file extensions: `pdf`, `svg`, `png`, `jpg`, `jpeg`, `tiff`, `tif`, `gif`, `bmp` and `mov`.

        * A `pdf` can be multipage. If `multipage` is `False` only the current page is saved.
        * A `mov` will use each page as a frame.
        * A `gif` can be animated when there are multiple pages and it will use each page as a frame.
        * All images and `svg` formats will only save the current page. If `multipage` is `True` all pages are saved to disk (a page index will be added to the file name).

        .. showcode:: /../examples/saveImage.py
        """
        if isinstance(paths, (str, unicode)):
            paths = [paths]
        for path in paths:
            path = optimizePath(path)
            dirName = os.path.dirname(path)
            if not os.path.exists(dirName):
                raise DrawBotError, "Folder '%s' doesn't exists" % dirName
            base, ext = os.path.splitext(path)
            ext = ext.lower()[1:]
            context = getContextForFileExt(ext)
            self._drawInContext(context)
            context.saveImage(path, multipage)
Example #3
0
    def printImage(self):
        """
        Export the canvas to a printing dialog, ready to print.

        .. showcode:: /../examples/printImage.py
        """
        context = getContextForFileExt("pdf")
        self._drawInContext(context)
        context.printImage()
    def printImage(self, pdf=None):
        """
        Export the canvas to a printing dialog, ready to print.

        Optionally a `pdf` object can be provided.

        .. showcode:: /../examples/printImage.py
        """
        context = getContextForFileExt("pdf")
        if pdf is None:
            self._drawInContext(context)
            context.printImage()
        else:
            context.printImage(pdf)
    def printImage(self, pdf=None):
        """
        Export the canvas to a printing dialog, ready to print.

        Optionally a `pdf` object can be provided.

        .. showcode:: /../examples/printImage.py
        """
        context = getContextForFileExt("pdf")
        if pdf is None:
            self._drawInContext(context)
            context.printImage()
        else:
            context.printImage(pdf)
Example #6
0
    def saveImage(self, paths):
        """
        Save or export the canvas to a specified format.
        The argument `paths` can either be a single path or a list of paths.

        The file extension is important because it will determine the format in which the image will be exported.

        All supported file extensions: `pdf`, `svg`, `png`, `jpg`, `jpeg`, `tiff`, `tif`, `gif`, `bmp` and `mov`.
        
        * A `pdf` can be multipage. 
        * A `mov` will use each page as a frame.
        * All images and `svg` formats will only save the current page.

        .. showcode:: /../examples/saveImage.py
        """
        if isinstance(paths, (str, unicode)):
            paths = [paths]
        for path in paths:
            path = os.path.expanduser(path)
            base, ext = os.path.splitext(path)
            ext = ext.lower()[1:]
            context = getContextForFileExt(ext)
            self._drawInContext(context)
            context.saveImage(path)