1 /* gcc `pkg-config --cflags --libs librsvg-2.0 cairo-pdf` -o svg2pdf svg2pdf.c
3 * Copyright © 2005 Red Hat, Inc.
4 * Copyright © 2006 Red Hat, Inc.
5 * Copyright © 2007 Red Hat, Inc.
7 * Permission is hereby granted, free of charge, to any person
8 * obtaining a copy of this software and associated documentation
9 * files (the "Software"), to deal in the Software without
10 * restriction, including without limitation the rights to use, copy,
11 * modify, merge, publish, distribute, sublicense, and/or sell copies
12 * of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * Authors: Kristian Høgsberg <krh@redhat.com>
28 * Carl Worth <cworth@redhat.com>
29 * Behdad Esfahbod <besfahbo@redhat.com>
34 #include <librsvg/rsvg.h>
35 #include <librsvg/rsvg-cairo.h>
37 #include <cairo-pdf.h>
40 do { fprintf (stderr, "FAIL: %s\n", msg); exit (-1); } while (0)
42 #define PIXELS_PER_POINT 1
44 int main (int argc, char *argv[])
48 RsvgDimensionData dim;
50 const char *filename = argv[1];
51 const char *output_filename = argv[2];
52 cairo_surface_t *surface;
54 cairo_status_t status;
57 FAIL ("usage: svg2pdf input_file.svg output_file.pdf");
61 rsvg_set_default_dpi (72.0);
62 handle = rsvg_handle_new_from_file (filename, &error);
64 FAIL (error->message);
66 rsvg_handle_get_dimensions (handle, &dim);
70 surface = cairo_pdf_surface_create (output_filename, width, height);
71 cr = cairo_create (surface);
73 rsvg_handle_render_cairo (handle, cr);
75 status = cairo_status (cr);
77 FAIL (cairo_status_to_string (status));
80 cairo_surface_destroy (surface);