2 * Copyright © 2005 Red Hat, Inc.
3 * Copyright © 2006 Red Hat, Inc.
4 * Copyright © 2007 Red Hat, Inc.
6 * Permission to use, copy, modify, distribute, and sell this software
7 * and its documentation for any purpose is hereby granted without
8 * fee, provided that the above copyright notice appear in all copies
9 * and that both that copyright notice and this permission notice
10 * appear in supporting documentation, and that the name of
11 * Red Hat, Inc. not be used in advertising or publicity pertaining to
12 * distribution of the software without specific, written prior
13 * permission. Red Hat, Inc. makes no representations about the
14 * suitability of this software for any purpose. It is provided "as
15 * is" without express or implied warranty.
17 * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
18 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
20 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
21 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
22 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
23 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * Authors: Kristian Høgsberg <krh@redhat.com>
26 * Carl Worth <cworth@redhat.com>
27 * Behdad Esfahbod <besfahbo@redhat.com>
32 #include <librsvg/rsvg.h>
33 #include <librsvg/rsvg-cairo.h>
35 #include <cairo-pdf.h>
38 do { fprintf (stderr, "FAIL: %s\n", msg); exit (-1); } while (0)
40 #define PIXELS_PER_POINT 1
42 int main (int argc, char *argv[])
46 RsvgDimensionData dim;
48 const char *filename = argv[1];
49 const char *output_filename = argv[2];
50 cairo_surface_t *surface;
52 cairo_status_t status;
55 FAIL ("usage: svg2pdf input_file.svg output_file.pdf");
59 rsvg_set_default_dpi (72.0);
60 handle = rsvg_handle_new_from_file (filename, &error);
62 FAIL (error->message);
64 rsvg_handle_get_dimensions (handle, &dim);
68 surface = cairo_pdf_surface_create (output_filename, width, height);
69 cr = cairo_create (surface);
71 /* Clear background */
72 cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
75 rsvg_handle_render_cairo (handle, cr);
77 status = cairo_status (cr);
79 FAIL (cairo_status_to_string (status));
82 cairo_surface_destroy (surface);