diff --git a/ft/djvu/djvu.c b/ft/djvu/djvu.c index b1b5df6..8c8e2ad 100644 --- a/ft/djvu/djvu.c +++ b/ft/djvu/djvu.c @@ -196,8 +196,8 @@ djvu_page_render(zathura_page_t* page) } /* calculate sizes */ - unsigned int page_width = page->width; - unsigned int page_height = page->height; + unsigned int page_width = Zathura.document->scale * page->width; + unsigned int page_height = Zathura.document->scale * page->height; /* init ddjvu render data */ ddjvu_rect_t rrect = { 0, 0, page_width, page_height }; @@ -209,9 +209,9 @@ djvu_page_render(zathura_page_t* page) switch(Zathura.document->rotate) { case 90: - tmp = page_width; + dim_temp = page_width; page_width = page_height; - page_height = page_tmp; + page_height = dim_temp; rotation = DDJVU_ROTATE_90; break; @@ -219,9 +219,9 @@ djvu_page_render(zathura_page_t* page) rotation = DDJVU_ROTATE_180; break; case 270: - tmp = page_width; + dim_temp = page_width; page_width = page_height; - page_height = page_tmp; + page_height = dim_temp; rotation = DDJVU_ROTATE_270; break; diff --git a/ft/pdf/pdf.c b/ft/pdf/pdf.c index a2d6454..0673015 100644 --- a/ft/pdf/pdf.c +++ b/ft/pdf/pdf.c @@ -1,8 +1,11 @@ /* See LICENSE file for license and copyright information */ #include +#include +#include #include "pdf.h" +#include "../../zathura.h" bool pdf_document_open(zathura_document_t* document) @@ -238,5 +241,48 @@ pdf_page_form_fields_get(zathura_page_t* page) cairo_surface_t* pdf_page_render(zathura_page_t* page) { - return NULL; + if(Zathura.document || !page || !page->data || !page->document) { + return NULL; + } + + /* create cairo data */ + cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, + page->width, page->height); + + if(!surface) { + return NULL; + } + + cairo_t* cairo = cairo_create(surface); + + if(!cairo) { + cairo_surface_destroy(surface); + return NULL; + } + + switch(Zathura.document->rotate) { + case 90: + cairo_translate(cairo, page->width, 0); + break; + case 180: + cairo_translate(cairo, page->width, page->height); + break; + case 270: + cairo_translate(cairo, 0, page->height); + break; + default: + cairo_translate(cairo, 0, 0); + break; + } + + cairo_scale(cairo, Zathura.document->scale, Zathura.document->scale); + cairo_rotate(cairo, Zathura.document->rotate * G_PI / 180.0); + + /* render */ + poppler_page_render(page->data, cairo); + + cairo_paint(cairo); + cairo_destroy(cairo); + + return surface; }