From 108384e83edcfd22b09eefe1cc6013d0c4d93f54 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 21 Feb 2019 22:34:53 +0100 Subject: Skeleton for libstorycode-cairo and libstorycode-gtk --- src/pdfstorycode.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/pdfstorycode.c b/src/pdfstorycode.c index 4c379f4..6a4de05 100644 --- a/src/pdfstorycode.c +++ b/src/pdfstorycode.c @@ -26,10 +26,63 @@ #include #include #include +#include #include "storycode.h" #include "presentation.h" + +static int render_slides_to_pdf(Presentation *p, const char *filename) +{ + double w = 2048.0; + double scale; + cairo_surface_t *surf; + cairo_t *cr; + int i; + PangoContext *pc; + + surf = cairo_pdf_surface_create(filename, w, w); + if ( cairo_surface_status(surf) != CAIRO_STATUS_SUCCESS ) { + fprintf(stderr, _("Couldn't create Cairo surface\n")); + return 1; + } + + cr = cairo_create(surf); + pc = pango_cairo_create_context(cr); + + for ( i=0; islide_width, p->slide_height); + cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + cairo_fill(cr); + + slide_render(s, cr, p->slide_width, + p->slide_height, p->stylesheet, NULL, + p->is, i, p->lang, pc); + + cairo_restore(cr); + + cairo_show_page(cr); + } + + g_object_unref(pc); + cairo_surface_finish(surf); + cairo_destroy(cr); + + return 0; +} + + int main(int argc, char *argv[]) { GFile *file; @@ -46,11 +99,7 @@ int main(int argc, char *argv[]) g_bytes_unref(bytes); /* Render each slide to PDF */ - for ( i=0; i