博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CairoSVG - Convert SVG to PNG or PDF - Contents
阅读量:2209 次
发布时间:2019-05-05

本文共 2315 字,大约阅读时间需要 7 分钟。

User Documentation

Author Guillaume Ayoub
Date 2011-02-13

This document is a short description for installing and using CairoSVG.

CairoSVG is written in pure Python and only depends on . It is known to work with Python 2.6, 2.7, 3.2 and 3.3.

Linux and OS X users certainly have Python already installed. For Windows users, please install thanks to the adequate installer.

CairoSVG can use to parse the SVG file, and plus to apply CSS not included in thestyleattribute of the tags. If these packages are not available, CSS will only be supported in thestyleattributes.

Embedded raster images other than PNG are handled by .

CairoSVG can be freely downloaded on the . Just get the file and unzip it in a folder of your choice.

Here is the simple CairoSVG usage:

Usage: cairosvg.py filename [options]Options:  -h, --help            show this help message and exit  -v, --version         show version and exit  -f FORMAT, --format=FORMAT                        output format  -d DPI, --dpi=DPI     ratio between 1in and 1px  -o OUTPUT, --output=OUTPUT                        output filename

Supported output formats arepdf,psandpng(default ispdf). The default output is the standard output. If an output filename is given, the format is automatically chosen according to the extension.

Thedpioptions sets the ratio between pixels and real-life units such as millimeters and inches (as explained in the ).

Moreover, if-is used as filename, CairoSVG reads the SVG string from the standard input.

Here are some usage examples:

# Convert to pdf, write to standard outputcairosvg test.svg# Convert to png, write to standard outputcairosvg test.svg -f png# Convert to ps, write to test.pscairosvg test.svg -o test.ps# Convert an SVG string to pdf, write to standard outputecho "
123
" \ | cairosvg -

Thecairosvgmodule offers 4 functions:

  • svg2pdf,
  • svg2png,
  • svg2ps, and
  • svg2svg(!).

These functions expect one of these parameters:

  • bytestring, a byte string containing SVG, or
  • url, an URL or a filename, or
  • file_obj, a file-like object.

If thewrite_toargument is provided (filename or file-like object), the output is written there. Otherwise, the function returns a byte string.

posted on
2014-01-04 19:23  阅读(
...) 评论(
...) 收藏

转载于:https://www.cnblogs.com/lexus/p/3505208.html

你可能感兴趣的文章
【selenium】selenium ide的安装过程
查看>>
【手机自动化测试】monkey测试
查看>>
【英语】软件开发常用英语词汇
查看>>
Fiddler 抓包工具总结
查看>>
【雅思】雅思需要购买和准备的学习资料
查看>>
【雅思】雅思写作作业(1)
查看>>
【雅思】【大作文】【审题作业】关于同不同意的审题作业(重点)
查看>>
【Loadrunner】通过loadrunner录制时候有事件但是白页无法出来登录页怎么办?
查看>>
【English】【托业】【四六级】写译高频词汇
查看>>
【托业】【新东方全真模拟】01~02-----P5~6
查看>>
【托业】【新东方全真模拟】03~04-----P5~6
查看>>
【托业】【新东方托业全真模拟】TEST05~06-----P5~6
查看>>
【托业】【新东方托业全真模拟】TEST09~10-----P5~6
查看>>
【托业】【新东方托业全真模拟】TEST07~08-----P5~6
查看>>
solver及其配置
查看>>
JAVA多线程之volatile 与 synchronized 的比较
查看>>
Java集合框架知识梳理
查看>>
笔试题(一)—— java基础
查看>>
Redis学习笔记(三)—— 使用redis客户端连接windows和linux下的redis并解决无法连接redis的问题
查看>>
Intellij IDEA使用(一)—— 安装Intellij IDEA(ideaIU-2017.2.3)并完成Intellij IDEA的简单配置
查看>>