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 ...
随机推荐
- Django admin究竟要怎么写才优雅
比如在Django admin 注册models时,会用到. 对于APP里自带的models,可以使用这种方式注册. from django.contrib import admin # Regist ...
- C# Thread Programming Start
引言 1.理解多线程 2. 线程异步与线程同步 3.创建多线程应用程序 3.1通过System.Threading命名空间的类构建 3.1.1异步调用线程 3.1.2并发问题 3.1.3线程同步 3. ...
- [Android文档翻译]设备兼容性
原文地址:Device Compatibility Android设计于运行在多种不同类型的设备上,从手机.平板到电视.作为一名开发者,设备的涵盖范围为你的app提供了广大的潜在用户.为了让你的app ...
- python and 和 or
在Python 中,and 和 or 执行布尔逻辑演算,如你所期待的一样.但是它们并不返回布尔值,而是返回它们实际进行比较的值之一. 例 4.15. and 介绍 >>> 'a' a ...
- 关于JAVA 向上转型
最近复习中比较绕的一个地方 通过试验总结一下 若A为父类 B为子类 声明方式为: A t= new B(); 将子类对象赋值给父类对象,它编译时为父类对象,但运行时却是子类对象: 1)被声明为父类对象 ...
- [置顶] PHP开发实战权威指南-读书总结
从今年开始,断断续续学习PHP已经有4个月了. 最初,认真学习PHP几天,就弄WordPress搭建了一个个人博客,这也符合技术人的实践理念. 最近,重温PHP开发实战权威指南,做点总结,整理下自己学 ...
- Girls' research(manacher)
Girls' research Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) ...
- HDU 1862 EXCEL次序 (排序水问题)
Problem Description Excel对能够记录一组由任意列排序指定.现在,请把你编译的代码类似特征. Input 測试输入包括若干測试用例. 每一个測试用例的第1行包括两个整数 N ...
- ARM异常---一个DataAbort的触发过程:
一个DataAbort异常的触发过程://////////////////////////////xxxx.inc_STACK_BASEADDRESS EQU 0x33ff8000_MMUTT_STA ...
- UVa401 Palindromes
#include <stdio.h>#include <string.h> char mirror(char c){ static const char m[] = &q ...