diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.c | 7 | ||||
-rw-r--r-- | src/render.c | 39 | ||||
-rw-r--r-- | src/render.h | 1 |
3 files changed, 43 insertions, 4 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c index 91f4068..9e8a7d5 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -354,10 +354,9 @@ static gint export_pdf_response_sig(GtkWidget *d, gint response, filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(d)); - /* FIXME */ - //if ( export_pdf(p, filename) ) { - // show_error(p, "Failed to export as PDF"); - //} + if ( export_pdf(p, filename) ) { + show_error(p, "Failed to export as PDF"); + } g_free(filename); diff --git a/src/render.c b/src/render.c index 0fdd837..d00357a 100644 --- a/src/render.c +++ b/src/render.c @@ -527,3 +527,42 @@ cairo_surface_t *render_slide(struct slide *s, int w, double ww, double hh, return surf; } + + +int export_pdf(struct presentation *p, const char *filename) +{ + int i; + cairo_surface_t *surf; + cairo_t *cr; + + surf = cairo_pdf_surface_create(filename, p->slide_width, + p->slide_height); + + if ( cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS ) { + fprintf(stderr, "Couldn't create Cairo surface\n"); + return 1; + } + + cr = cairo_create(surf); + + for ( i=0; i<p->num_slides; i++ ) { + + cairo_surface_t *sf; + struct slide *s; + + s = p->slides[i]; + sf = render_slide(s, 1024, p->slide_width, p->slide_height, + p->is, ISZ_SLIDESHOW); + cairo_rectangle(cr, 0.0, 0.0, p->slide_width, p->slide_height); + cairo_set_source_surface(cr, sf, 0.0, 0.0); + cairo_fill(cr); + cairo_surface_show_page(surf); + cairo_surface_destroy(sf); + + } + + cairo_surface_finish(surf); + cairo_destroy(cr); + + return 0; +} diff --git a/src/render.h b/src/render.h index 7bdeb8a..8dcb7b5 100644 --- a/src/render.h +++ b/src/render.h @@ -35,5 +35,6 @@ extern cairo_surface_t *render_slide(struct slide *s, int w, enum is_size isz); extern void free_render_buffers(struct slide *s); extern void free_render_buffers_except_thumb(struct slide *s); +extern int export_pdf(struct presentation *p, const char *filename); #endif /* RENDER_H */ |