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 ...
随机推荐
- mobilize扁平化的fullPage.js类工具使用心得
可以生成一个fullPage效果的主页,但是列表页面和内容页面呢? 主页中的block,可以选择多种组建生成.甚至连form都有: 应该改造其源代码,动态化和cms系统化,添加二三级页面模板: == ...
- muduo简化(1):Reactor的关键结构
说明:本文参照muduo代码,主要用意是简化muduo代码呈现其主要结构,并脱离muduo的文件依赖. 本节简化的是Reactor的关键结构部分:EventLoop.Poller.Channel.遵照 ...
- poj3693之后缀数组
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5946 Accepted: 1799 Description The r ...
- [javascript]MooTools Selectors(MooTools 选择器) ELEMENT DOM选择
//ELEMENT DOM选择//on are tag names. //All the divs on the page: $$('div'); //All the divs and paragra ...
- C语言选择法排序
#include <stdio.h> int main() { int i, j, p, n, q; ] = {, , , , }; //对无序数组进行排序 ; i<; i++) { ...
- spring的定时执行代码 跑批
最近公司上线了抽奖的活动,活动需求 1:每天凌晨更新状态,实现自动开启和关闭活动 2:活动结束自动抽取中奖号码 在这里提供spring的定时调度功能 1:首先是配置文件 在你的web.xml中,查看配 ...
- Xamarin.Android开发实践(二)
原文:Xamarin.Android开发实践(二) 一.准备 开始学习本教程前必须先完成该教程http://www.cnblogs.com/yaozhenfa/p/xamarin_android_qu ...
- BZOJ 1644: [Usaco2007 Oct]Obstacle Course 障碍训练课
题目 1644: [Usaco2007 Oct]Obstacle Course 障碍训练课 Time Limit: 5 Sec Memory Limit: 64 MB Description 考虑一 ...
- Codeforces 41D Pawn 简单dp
题目链接:点击打开链接 给定n*m 的矩阵 常数k 以下一个n*m的矩阵,每一个位置由 0-9的一个整数表示 问: 从最后一行開始向上走到第一行使得路径上的和 % (k+1) == 0 每一个格子仅仅 ...
- Java class文件分析工具 -- Classpy
Classpy Classpy是一个图形化的class文件分析工具,功能和javap类似,界面主要參考了Java Class Viewer: 为什么要又一次创造轮子? 写这个工具花了将近一周的时间.那 ...