CairoSVG - Convert SVG to PNG or PDF - Contents
CairoSVG - Convert SVG to PNG or PDF - Contents
User Documentation
Author Guillaume Ayoub Date 2011-02-13 Installation
Dependencies
CairoSVG is written in pure Python and only depends on Pycairo. 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 Python thanks to the adequate installer.
CairoSVG can use lxml to parse the SVG file, and tinycss plus cssselect 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 Pillow.
CairoSVG
CairoSVG can be freely downloaded on the project website, download section. Just get the file and unzip it in a folder of your choice.
Command-Line Usage
Description
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 filenameSupported 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 specification).
Moreover, if-is used as filename, CairoSVG reads the SVG string from the standard input.
Examples
Here are some usage examples:
# Convert to pdf, write to standard output
cairosvg test.svg # Convert to png, write to standard output
cairosvg test.svg -f png # Convert to ps, write to test.ps
cairosvg test.svg -o test.ps # Convert an SVG string to pdf, write to standard output
echo "<svg height='30' width='30'><text y='10'>123</text></svg>" \
| cairosvg -API
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.
CairoSVG - Convert SVG to PNG or PDF - Contents的更多相关文章
- Convert SVG to PNG in Python - Stack Overflow
Convert SVG to PNG in Python - Stack Overflow Convert SVG to PNG in Python
- C#/VB.NET 将SVG图片添加到PDF、转换为PDF
以下内容介绍在C# 程序中如何将SVG图片添加到PDF文档.以及如何将SVG图片转换为PDF文档. 一.环境准备 先下载PDF类库工具,Spire.PDF for .NET hotfix 6.5.6及 ...
- how to convert SVG shapes to polygon
how to convert SVG shapes to polygon 如何将 svg 的 rect 转换成 polygon rect.circle.ellipse.line.polyline.po ...
- [Tools] Convert SVG to a PDF in Node with PDFKit and SVG.js
Given a epxress application and an svg template, we want to draw some text, date onto it and convert ...
- Gmagick convert SVG to PNG with transparent/opacity background
1 前言 在Ubuntu18.04环境下,用gographics/gmagick API使用了以下代码未有效果 pw := gmagick.NewPixelWand() pw.SetOpacity(1 ...
- convert source code files to pdf format in python
import os import sys def find_file(root_dir, type): dirs_pool = [root_dir] dest_pool = [] def scan_d ...
- Batik - 将svg转换成其他格式图片或PDF - [导出服务器配置] 导出服务器原理解析
导出服务器原理解析 Highcharts图表导出(或下载)本质上是将SVG代码转换为不同文件格式的过程,用到的工具是batik,所以所谓导出服务器,只不过是调用batik,将SVG代码转换并下载.下图 ...
- C# 将PDF转为SVG的3种情况
PDF格式的文档广泛用于各种办公场所,在工作中难免会有将PDF文档转换为其他文档格式的需要.在本篇文档中,将介绍PDF转为SVG的方法.根据不同的转换需求,这里分三种情况进行讲述,即转PDF所有页为S ...
- Java 将PDF 转为Word、图片、SVG、XPS、Html、PDF/A
本文将介绍通过Java编程来实现PDF文档转换的方法.包括: 1. PDF转为Word 2. PDF转为图片 3. PDF转为Html 4. PDF转为SVG 4.1 将PDF每一页转为单个的SVG ...
随机推荐
- runtime的概念,message send如果寻找不到相应的对象,如何进行后续处理
运行时刻是指一个程序在运行(或者在被执行)的状态.也就是说,当你打开一个程序使它在电脑上运行的时候,那个程序就是处于运行时刻.在一些编程语言中,把某些可以重用的程序或者实例打包或者重建成为“运行库”. ...
- c#中使用log4net工具记录日志
首先,去官网下载log4net工具 链接http://logging.apache.org/log4net/download_log4net.cgi 目前最新的版本 log4net-1.2.15-bi ...
- Mac 终端命令运行java
链接地址:http://www.cnblogs.com/wangrui-techbolg/archive/2012/12/29/2839047.html 由于mac已经装好java环境,所以直接课运行 ...
- 「C」关键字、标识符、注释、内存分析、数据、常量、变量
一.关键字 C语言提供的有特殊含义的符号,共32个. 一般在Xcode中关键字全部显示紫褐色,关键字全部都为小写.如int.return等. 二.标识符 标识符是程序员在程序中自定义的一些符号和名称. ...
- JavaSE学习总结第08天_面向对象3
08.01 工具类中使用静态 例: class ArrayTool { //将构造方法私有,外界不能创建该类的对象 private ArrayTool(){} //遍历数组 public stat ...
- Java中常见的几种类型转换
public class Main { public static void main(String[] args){ //Int型数字转换成字符串 int num1=123456; //方法1 St ...
- jmeter 压力测试 参数
Aggregate Report 是 JMeter 常用的一个 Listener,中文被翻译为“聚合报告”.今天再次有同行问到这个报告中的各项数据表示什么意思,顺便在这里公布一下,以备大家查阅. 如果 ...
- shell学习之字符串处理
1.获取字符串长度 value=abcd;echo ${#value} 输出:42.获取子串 value=abcd;:} 输出:d value:a:b,其中a表示起始位置,b表示获取的子串的长度. 3 ...
- javascript模块加载框架seajs详解
SeaJS是一个遵循commonJS规范的javascript模块加载框架,可以实现javascript的模块化开发和模块化加载(模块可按需加载或全部加载).SeaJS可以和jQuery完美集成,使用 ...
- asp.net从客户端检测到有潜在危险的Request.Form 值
asp.net开发中,经常遇到“从客户端检测到有潜在危险的Request.Form 值”错误提示,很多人给出的解决方案是: 1.web.config文档<system.web>后面加入这一 ...