cairosvg API Reference
SVG to PDF, PostScript, and PNG converter based on Cairo.
cairosvg.Path
Python Library Documentation: class Path in module pathlib
class Path(PurePath)
| Path(*args, **kwargs)
|
| PurePath subclass that can make system calls.
|
| Path represents a filesystem path but unlike PurePath, also offers
| methods to do system calls on path objects. Depending on your system,
| instantiating a Path will return either a PosixPath or a WindowsPath
| object. You can also instantiate a PosixPath or WindowsPath directly,
| but cannot instantiate a WindowsPath on a POSIX system or vice versa.
|
| Method resolution order:
| Path
| PurePath
| builtins.object
|
| Methods defined here:
|
| __enter__(self)
|
| __exit__(self, t, v, tb)
|
| __init__(self, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| absolute(self)
| Return an absolute version of this path by prepending the current
| working directory. No normalization or symlink resolution is performed.
|
| Use resolve() to get the canonical path to a file.
|
| chmod(self, mode, *, follow_symlinks=True)
| Change the permissions of the path, like os.chmod().
|
| exists(self, *, follow_symlinks=True)
| Whether this path exists.
|
| This method normally follows symlinks; to check whether a symlink exists,
| add the argument follow_symlinks=False.
|
| expanduser(self)
| Return a new path with expanded ~ and ~user constructs
| (as returned by os.path.expanduser)
|
| glob(self, pattern, *, case_sensitive=None)
| Iterate over this subtree and yield all existing files (of any
| kind, including directories) matching the given relative pattern.
|
| group(self)
| Return the group name of the file gid.
|
| hardlink_to(self, target)
| Make this path a hard link pointing to the same file as *target*.
|
| Note the order of arguments (self, target) is the reverse of os.link's.
|
| is_block_device(self)
| Whether this path is a block device.
|
| is_char_device(self)
| Whether this path is a character device.
|
| is_dir(self)
| Whether this path is a directory.
|
| is_fifo(self)
| Whether this path is a FIFO.
|
| is_file(self)
| Whether this path is a regular file (also True for symlinks pointing
| to regular files).
|
| is_junction(self)
| Whether this path is a junction.
|
| is_mount(self)
| Check if this path is a mount point
|
| is_socket(self)
| Whether this path is a socket.
|
| is_symlink(self)
| Whether this path is a symbolic link.
|
| iterdir(self)
| Yield path objects of the directory contents.
|
| The children are yielded in arbitrary order, and the
| special entries '.' and '..' are not included.
|
| lchmod(self, mode)
| Like chmod(), except if the path points to a symlink, the symlink's
| permissions are changed, rather than its target's.
|
| lstat(self)
| Like stat(), except if the path points to a symlink, the symlink's
| status information is returned, rather than its target's.
|
| mkdir(self, mode=511, parents=False, exist_ok=False)
| Create a new directory at this given path.
|
| open(self, mode='r', buffering=-1, encoding=None, errors=None, newline=None)
| Open the file pointed to by this path and return a file object, as
| the built-in open() function does.
|
| owner(self)
| Return the login name of the file owner.
|
| read_bytes(self)
| Open the file in bytes mode, read it, and close the file.
|
| read_text(self, encoding=None, errors=None)
| Open the file in text mode, read it, and close the file.
|
| readlink(self)
| Return the path to which the symbolic link points.
|
| rename(self, target)
| Rename this path to the target path.
|
| The target path may be absolute or relative. Relative paths are
| interpreted relative to the current working directory, *not* the
| directory of the Path object.
|
| Returns the new Path instance pointing to the target path.
|
| replace(self, target)
| Rename this path to the target path, overwriting if that path exists.
|
| The target path may be absolute or relative. Relative paths are
| interpreted relative to the current working directory, *not* the
| directory of the Path object.
|
| Returns the new Path instance pointing to the target path.
|
| resolve(self, strict=False)
| Make the path absolute, resolving all symlinks on the way and also
| normalizing it.
|
| rglob(self, pattern, *, case_sensitive=None)
| Recursively yield all existing files (of any kind, including
| directories) matching the given relative pattern, anywhere in
| this subtree.
|
| rmdir(self)
| Remove this directory. The directory must be empty.
|
| samefile(self, other_path)
| Return whether other_path is the same or not as this file
| (as returned by os.path.samefile()).
|
| stat(self, *, follow_symlinks=True)
| Return the result of the stat() system call on this path, like
| os.stat() does.
|
| symlink_to(self, target, target_is_directory=False)
| Make this path a symlink pointing to the target path.
| Note the order of arguments (link, target) is the reverse of os.symlink.
|
| touch(self, mode=438, exist_ok=True)
| Create this file with the given access mode, if it doesn't exist.
|
| unlink(self, missing_ok=False)
| Remove this file or link.
| If the path is a directory, use rmdir() instead.
|
| walk(self, top_down=True, on_error=None, follow_symlinks=False)
| Walk the directory tree from this directory, similar to os.walk().
|
| write_bytes(self, data)
| Open the file in bytes mode, write to it, and close the file.
|
| write_text(self, data, encoding=None, errors=None, newline=None)
| Open the file in text mode, write to it, and close the file.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| cwd()
| Return a new path pointing to the current working directory.
|
| home()
| Return a new path pointing to the user's home directory (as
| returned by os.path.expanduser('~')).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(cls, *args, **kwargs)
| Construct a PurePath from one or several strings and or existing
| PurePath objects. The strings and path objects are combined so as
| to yield a canonicalized path, which is incorporated into the
| new PurePath object.
|
| ----------------------------------------------------------------------
| Methods inherited from PurePath:
|
| __bytes__(self)
| Return the bytes representation of the path. This is only
| recommended to use under Unix.
|
| __eq__(self, other)
| Return self==value.
|
| __fspath__(self)
|
| __ge__(self, other)
| Return self>=value.
|
| __gt__(self, other)
| Return self>value.
|
| __hash__(self)
| Return hash(self).
|
| __le__(self, other)
| Return self<=value.
|
| __lt__(self, other)
| Return self<value.
|
| __reduce__(self)
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| __rtruediv__(self, key)
|
| __str__(self)
| Return the string representation of the path, suitable for
| passing to system calls.
|
| __truediv__(self, key)
|
| as_posix(self)
| Return the string representation of the path with forward (/)
| slashes.
|
| as_uri(self)
| Return the path as a 'file' URI.
|
| is_absolute(self)
| True if the path is absolute (has both a root and, if applicable,
| a drive).
|
| is_relative_to(self, other, /, *_deprecated)
| Return True if the path is relative to another path or False.
|
| is_reserved(self)
| Return True if the path contains one of the special names reserved
| by the system, if any.
|
| joinpath(self, *pathsegments)
| Combine this path with one or several arguments, and return a
| new path representing either a subpath (if all arguments are relative
| paths) or a totally different path (if one of the arguments is
| anchored).
|
| match(self, path_pattern, *, case_sensitive=None)
| Return True if this path matches the given pattern.
|
| relative_to(self, other, /, *_deprecated, walk_up=False)
| Return the relative path to another path identified by the passed
| arguments. If the operation is not possible (because this is not
| related to the other path), raise ValueError.
|
| The *walk_up* parameter controls whether `..` may be used to resolve
| the path.
|
| with_name(self, name)
| Return a new path with the file name changed.
|
| with_segments(self, *pathsegments)
| Construct a new path object from any number of path-like objects.
| Subclasses may override this method to customize how new path objects
| are created from methods like `iterdir()`.
|
| with_stem(self, stem)
| Return a new path with the stem changed.
|
| with_suffix(self, suffix)
| Return a new path with the file suffix changed. If the path
| has no suffix, add given suffix. If the given suffix is an empty
| string, remove the suffix from the path.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from PurePath:
|
| anchor
| The concatenation of the drive and root, or ''.
|
| drive
| The drive prefix (letter or UNC path), if any.
|
| name
| The final path component, if any.
|
| parent
| The logical parent of the path.
|
| parents
| A sequence of this path's logical parents.
|
| parts
| An object providing sequence-like access to the
| components in the filesystem path.
|
| root
| The root of the path, if any.
|
| stem
| The final path component, minus its last suffix.
|
| suffix
| The final component's last suffix, if any.
|
| This includes the leading period. For example: '.txt'
|
| suffixes
| A list of the final component's suffixes, if any.
|
| These include the leading periods. For example: ['.tar', '.gz']
cairosvg.ROOT
Python Library Documentation: WindowsPath in module pathlib object
class WindowsPath(Path, PureWindowsPath)
| WindowsPath(*args, **kwargs)
|
| Path subclass for Windows systems.
|
| On a Windows system, instantiating a Path should return this object.
|
| Method resolution order:
| WindowsPath
| Path
| PureWindowsPath
| PurePath
| builtins.object
|
| Methods inherited from Path:
|
| __enter__(self)
|
| __exit__(self, t, v, tb)
|
| __init__(self, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| absolute(self)
| Return an absolute version of this path by prepending the current
| working directory. No normalization or symlink resolution is performed.
|
| Use resolve() to get the canonical path to a file.
|
| chmod(self, mode, *, follow_symlinks=True)
| Change the permissions of the path, like os.chmod().
|
| exists(self, *, follow_symlinks=True)
| Whether this path exists.
|
| This method normally follows symlinks; to check whether a symlink exists,
| add the argument follow_symlinks=False.
|
| expanduser(self)
| Return a new path with expanded ~ and ~user constructs
| (as returned by os.path.expanduser)
|
| glob(self, pattern, *, case_sensitive=None)
| Iterate over this subtree and yield all existing files (of any
| kind, including directories) matching the given relative pattern.
|
| group(self)
| Return the group name of the file gid.
|
| hardlink_to(self, target)
| Make this path a hard link pointing to the same file as *target*.
|
| Note the order of arguments (self, target) is the reverse of os.link's.
|
| is_block_device(self)
| Whether this path is a block device.
|
| is_char_device(self)
| Whether this path is a character device.
|
| is_dir(self)
| Whether this path is a directory.
|
| is_fifo(self)
| Whether this path is a FIFO.
|
| is_file(self)
| Whether this path is a regular file (also True for symlinks pointing
| to regular files).
|
| is_junction(self)
| Whether this path is a junction.
|
| is_mount(self)
| Check if this path is a mount point
|
| is_socket(self)
| Whether this path is a socket.
|
| is_symlink(self)
| Whether this path is a symbolic link.
|
| iterdir(self)
| Yield path objects of the directory contents.
|
| The children are yielded in arbitrary order, and the
| special entries '.' and '..' are not included.
|
| lchmod(self, mode)
| Like chmod(), except if the path points to a symlink, the symlink's
| permissions are changed, rather than its target's.
|
| lstat(self)
| Like stat(), except if the path points to a symlink, the symlink's
| status information is returned, rather than its target's.
|
| mkdir(self, mode=511, parents=False, exist_ok=False)
| Create a new directory at this given path.
|
| open(self, mode='r', buffering=-1, encoding=None, errors=None, newline=None)
| Open the file pointed to by this path and return a file object, as
| the built-in open() function does.
|
| owner(self)
| Return the login name of the file owner.
|
| read_bytes(self)
| Open the file in bytes mode, read it, and close the file.
|
| read_text(self, encoding=None, errors=None)
| Open the file in text mode, read it, and close the file.
|
| readlink(self)
| Return the path to which the symbolic link points.
|
| rename(self, target)
| Rename this path to the target path.
|
| The target path may be absolute or relative. Relative paths are
| interpreted relative to the current working directory, *not* the
| directory of the Path object.
|
| Returns the new Path instance pointing to the target path.
|
| replace(self, target)
| Rename this path to the target path, overwriting if that path exists.
|
| The target path may be absolute or relative. Relative paths are
| interpreted relative to the current working directory, *not* the
| directory of the Path object.
|
| Returns the new Path instance pointing to the target path.
|
| resolve(self, strict=False)
| Make the path absolute, resolving all symlinks on the way and also
| normalizing it.
|
| rglob(self, pattern, *, case_sensitive=None)
| Recursively yield all existing files (of any kind, including
| directories) matching the given relative pattern, anywhere in
| this subtree.
|
| rmdir(self)
| Remove this directory. The directory must be empty.
|
| samefile(self, other_path)
| Return whether other_path is the same or not as this file
| (as returned by os.path.samefile()).
|
| stat(self, *, follow_symlinks=True)
| Return the result of the stat() system call on this path, like
| os.stat() does.
|
| symlink_to(self, target, target_is_directory=False)
| Make this path a symlink pointing to the target path.
| Note the order of arguments (link, target) is the reverse of os.symlink.
|
| touch(self, mode=438, exist_ok=True)
| Create this file with the given access mode, if it doesn't exist.
|
| unlink(self, missing_ok=False)
| Remove this file or link.
| If the path is a directory, use rmdir() instead.
|
| walk(self, top_down=True, on_error=None, follow_symlinks=False)
| Walk the directory tree from this directory, similar to os.walk().
|
| write_bytes(self, data)
| Open the file in bytes mode, write to it, and close the file.
|
| write_text(self, data, encoding=None, errors=None, newline=None)
| Open the file in text mode, write to it, and close the file.
|
| ----------------------------------------------------------------------
| Class methods inherited from Path:
|
| cwd()
| Return a new path pointing to the current working directory.
|
| home()
| Return a new path pointing to the user's home directory (as
| returned by os.path.expanduser('~')).
|
| ----------------------------------------------------------------------
| Static methods inherited from Path:
|
| __new__(cls, *args, **kwargs)
| Construct a PurePath from one or several strings and or existing
| PurePath objects. The strings and path objects are combined so as
| to yield a canonicalized path, which is incorporated into the
| new PurePath object.
|
| ----------------------------------------------------------------------
| Methods inherited from PurePath:
|
| __bytes__(self)
| Return the bytes representation of the path. This is only
| recommended to use under Unix.
|
| __eq__(self, other)
| Return self==value.
|
| __fspath__(self)
|
| __ge__(self, other)
| Return self>=value.
|
| __gt__(self, other)
| Return self>value.
|
| __hash__(self)
| Return hash(self).
|
| __le__(self, other)
| Return self<=value.
|
| __lt__(self, other)
| Return self<value.
|
| __reduce__(self)
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| __rtruediv__(self, key)
|
| __str__(self)
| Return the string representation of the path, suitable for
| passing to system calls.
|
| __truediv__(self, key)
|
| as_posix(self)
| Return the string representation of the path with forward (/)
| slashes.
|
| as_uri(self)
| Return the path as a 'file' URI.
|
| is_absolute(self)
| True if the path is absolute (has both a root and, if applicable,
| a drive).
|
| is_relative_to(self, other, /, *_deprecated)
| Return True if the path is relative to another path or False.
|
| is_reserved(self)
| Return True if the path contains one of the special names reserved
| by the system, if any.
|
| joinpath(self, *pathsegments)
| Combine this path with one or several arguments, and return a
| new path representing either a subpath (if all arguments are relative
| paths) or a totally different path (if one of the arguments is
| anchored).
|
| match(self, path_pattern, *, case_sensitive=None)
| Return True if this path matches the given pattern.
|
| relative_to(self, other, /, *_deprecated, walk_up=False)
| Return the relative path to another path identified by the passed
| arguments. If the operation is not possible (because this is not
| related to the other path), raise ValueError.
|
| The *walk_up* parameter controls whether `..` may be used to resolve
| the path.
|
| with_name(self, name)
| Return a new path with the file name changed.
|
| with_segments(self, *pathsegments)
| Construct a new path object from any number of path-like objects.
| Subclasses may override this method to customize how new path objects
| are created from methods like `iterdir()`.
|
| with_stem(self, stem)
| Return a new path with the stem changed.
|
| with_suffix(self, suffix)
| Return a new path with the file suffix changed. If the path
| has no suffix, add given suffix. If the given suffix is an empty
| string, remove the suffix from the path.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from PurePath:
|
| anchor
| The concatenation of the drive and root, or ''.
|
| drive
| The drive prefix (letter or UNC path), if any.
|
| name
| The final path component, if any.
|
| parent
| The logical parent of the path.
|
| parents
| A sequence of this path's logical parents.
|
| parts
| An object providing sequence-like access to the
| components in the filesystem path.
|
| root
| The root of the path, if any.
|
| stem
| The final path component, minus its last suffix.
|
| suffix
| The final component's last suffix, if any.
|
| This includes the leading period. For example: '.txt'
|
| suffixes
| A list of the final component's suffixes, if any.
|
| These include the leading periods. For example: ['.tar', '.gz']
cairosvg.SURFACES
Python Library Documentation: dict object
class dict(object)
| dict() -> new empty dictionary
| dict(mapping) -> new dictionary initialized from a mapping object's
| (key, value) pairs
| dict(iterable) -> new dictionary initialized as if via:
| d = {}
| for k, v in iterable:
| d[k] = v
| dict(**kwargs) -> new dictionary initialized with the name=value pairs
| in the keyword argument list. For example: dict(one=1, two=2)
|
| Built-in subclasses:
| StgDict
|
| Methods defined here:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __or__(self, value, /)
| Return self|value.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __ror__(self, value, /)
| Return value|self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| D.clear() -> None. Remove all items from D.
|
| copy(...)
| D.copy() -> a shallow copy of D
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| pop(...)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| update(...)
| D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| __class_getitem__(...)
| See PEP 585
|
| fromkeys(iterable, value=None, /)
| Create a new dictionary with keys from iterable and values set to value.
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None
cairosvg.VERSION
Error rendering doc: No Python documentation found for '2.9.0'. Use help() to get the interactive help utility. Use help(str) for help on the str class.
cairosvg.svg2eps
Python Library Documentation: function svg2eps in module cairosvg
svg2eps(bytestring=None, *, file_obj=None, url=None, dpi=96, parent_width=None, parent_height=None, scale=1, unsafe=False, background_color=None, negate_colors=False, invert_images=False, write_to=None, output_width=None, output_height=None)
Convert an SVG document to EPS.
Specify the input by passing one of these:
:param bytestring: The SVG source as a byte-string.
:param file_obj: A file-like object.
:param url: A filename.
Give some options:
:param dpi: The ratio between 1 inch and 1 pixel.
:param parent_width: The width of the parent container in pixels.
:param parent_height: The height of the parent container in pixels.
:param scale: The ouptut scaling factor.
:param unsafe: A boolean allowing external file access, XML entities
and very large files
(WARNING: vulnerable to XXE attacks and various DoS).
This does NOT restrict fetching of the main SVG input
specified via the ``url`` parameter.
Applications should validate input URLs to prevent SSRF.
Specifiy the output with:
:param write_to: The filename of file-like object where to write the
output. If None or not provided, return a byte string.
Only ``bytestring`` can be passed as a positional argument, other
parameters are keyword-only.
cairosvg.svg2pdf
Python Library Documentation: function svg2pdf in module cairosvg
svg2pdf(bytestring=None, *, file_obj=None, url=None, dpi=96, parent_width=None, parent_height=None, scale=1, unsafe=False, background_color=None, negate_colors=False, invert_images=False, write_to=None, output_width=None, output_height=None)
Convert an SVG document to PDF.
Specify the input by passing one of these:
:param bytestring: The SVG source as a byte-string.
:param file_obj: A file-like object.
:param url: A filename.
Give some options:
:param dpi: The ratio between 1 inch and 1 pixel.
:param parent_width: The width of the parent container in pixels.
:param parent_height: The height of the parent container in pixels.
:param scale: The ouptut scaling factor.
:param unsafe: A boolean allowing external file access, XML entities
and very large files
(WARNING: vulnerable to XXE attacks and various DoS).
This does NOT restrict fetching of the main SVG input
specified via the ``url`` parameter.
Applications should validate input URLs to prevent SSRF.
Specifiy the output with:
:param write_to: The filename of file-like object where to write the
output. If None or not provided, return a byte string.
Only ``bytestring`` can be passed as a positional argument, other
parameters are keyword-only.
cairosvg.svg2png
Python Library Documentation: function svg2png in module cairosvg
svg2png(bytestring=None, *, file_obj=None, url=None, dpi=96, parent_width=None, parent_height=None, scale=1, unsafe=False, background_color=None, negate_colors=False, invert_images=False, write_to=None, output_width=None, output_height=None)
Convert an SVG document to PNG.
Specify the input by passing one of these:
:param bytestring: The SVG source as a byte-string.
:param file_obj: A file-like object.
:param url: A filename.
Give some options:
:param dpi: The ratio between 1 inch and 1 pixel.
:param parent_width: The width of the parent container in pixels.
:param parent_height: The height of the parent container in pixels.
:param scale: The ouptut scaling factor.
:param unsafe: A boolean allowing external file access, XML entities
and very large files
(WARNING: vulnerable to XXE attacks and various DoS).
This does NOT restrict fetching of the main SVG input
specified via the ``url`` parameter.
Applications should validate input URLs to prevent SSRF.
Specifiy the output with:
:param write_to: The filename of file-like object where to write the
output. If None or not provided, return a byte string.
Only ``bytestring`` can be passed as a positional argument, other
parameters are keyword-only.
cairosvg.svg2ps
Python Library Documentation: function svg2ps in module cairosvg
svg2ps(bytestring=None, *, file_obj=None, url=None, dpi=96, parent_width=None, parent_height=None, scale=1, unsafe=False, background_color=None, negate_colors=False, invert_images=False, write_to=None, output_width=None, output_height=None)
Convert an SVG document to PS.
Specify the input by passing one of these:
:param bytestring: The SVG source as a byte-string.
:param file_obj: A file-like object.
:param url: A filename.
Give some options:
:param dpi: The ratio between 1 inch and 1 pixel.
:param parent_width: The width of the parent container in pixels.
:param parent_height: The height of the parent container in pixels.
:param scale: The ouptut scaling factor.
:param unsafe: A boolean allowing external file access, XML entities
and very large files
(WARNING: vulnerable to XXE attacks and various DoS).
This does NOT restrict fetching of the main SVG input
specified via the ``url`` parameter.
Applications should validate input URLs to prevent SSRF.
Specifiy the output with:
:param write_to: The filename of file-like object where to write the
output. If None or not provided, return a byte string.
Only ``bytestring`` can be passed as a positional argument, other
parameters are keyword-only.
cairosvg.svg2svg
Python Library Documentation: function svg2svg in module cairosvg
svg2svg(bytestring=None, *, file_obj=None, url=None, dpi=96, parent_width=None, parent_height=None, scale=1, unsafe=False, background_color=None, negate_colors=False, invert_images=False, write_to=None, output_width=None, output_height=None)
Convert an SVG document to SVG.
Specify the input by passing one of these:
:param bytestring: The SVG source as a byte-string.
:param file_obj: A file-like object.
:param url: A filename.
Give some options:
:param dpi: The ratio between 1 inch and 1 pixel.
:param parent_width: The width of the parent container in pixels.
:param parent_height: The height of the parent container in pixels.
:param scale: The ouptut scaling factor.
:param unsafe: A boolean allowing external file access, XML entities
and very large files
(WARNING: vulnerable to XXE attacks and various DoS).
This does NOT restrict fetching of the main SVG input
specified via the ``url`` parameter.
Applications should validate input URLs to prevent SSRF.
Specifiy the output with:
:param write_to: The filename of file-like object where to write the
output. If None or not provided, return a byte string.
Only ``bytestring`` can be passed as a positional argument, other
parameters are keyword-only.