Skip to content

Instantly share code, notes, and snippets.

@NickBeeuwsaert
Created September 4, 2013 21:52
Show Gist options
  • Save NickBeeuwsaert/6443345 to your computer and use it in GitHub Desktop.
Save NickBeeuwsaert/6443345 to your computer and use it in GitHub Desktop.
#include <cairo.h>
#include <cairo-ps.h>
#include <svg-cairo.h>
int main(int argc, char *argv[]){
if(argc!=3){
fprintf(stderr, "Usage: %s input.svg output.ps\n", argv[0]);
return -1;
}
svg_cairo_t *svg_file;
svg_cairo_create(&svg_file);
svg_cairo_parse(svg_file, argv[1]);
int w, h;
svg_cairo_get_size(svg_file, &w, &h);
cairo_surface_t *surface = cairo_ps_surface_create(argv[2], w,h);
cairo_t *context = cairo_create(surface);
svg_cairo_render(svg_file, context);
cairo_destroy(context);
cairo_surface_destroy(surface);
svg_cairo_destroy(svg_file);
return 0;
}
all: main.c
gcc -o main main.c -I/opt/X11/include/cairo -I/opt/X11/include/pixman-1 -I/opt/X11/include -I/opt/X11/include/freetype2 -I/opt/X11/include -I/opt/X11/include/libpng15 -I/opt/X11/include -I/usr/include/libxml2 -I/usr/local/Cellar/libsvg-cairo/0.1.6/include -I/usr/local/Cellar/libsvg/0.1.4/include -L/opt/X11/lib -L/usr/local/Cellar/libsvg-cairo/0.1.6/lib -L/usr/local/Cellar/libsvg/0.1.4/lib -lsvg-cairo -lsvg -lpng -ljpeg -lz -lxml2 -lcairo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment