mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 23:33:57 +01:00
Render PDF page
This commit is contained in:
parent
726766549e
commit
a76dd2f4fe
@ -70,7 +70,7 @@ zathura_document_open(const char* path, const char* password)
|
||||
document->password = password;
|
||||
document->current_page_number = 0;
|
||||
document->number_of_pages = 0;
|
||||
document->scale = 100;
|
||||
document->scale = 1.0;
|
||||
document->rotate = 0;
|
||||
document->data = NULL;
|
||||
|
||||
|
@ -87,7 +87,7 @@ struct zathura_document_s
|
||||
const char* password;
|
||||
unsigned int current_page_number;
|
||||
unsigned int number_of_pages;
|
||||
int scale;
|
||||
double scale;
|
||||
int rotate;
|
||||
void* data;
|
||||
|
||||
|
18
ft/pdf/pdf.c
18
ft/pdf/pdf.c
@ -250,9 +250,20 @@ pdf_page_render(zathura_page_t* page)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* calculate sizes */
|
||||
unsigned int page_width = Zathura.document->scale * page->width;
|
||||
unsigned int page_height = Zathura.document->scale * page->height;
|
||||
|
||||
if(Zathura.document->rotate == 90 || Zathura.document->rotate == 270) {
|
||||
unsigned int dim_temp = 0;
|
||||
dim_temp = page_width;
|
||||
page_width = page_height;
|
||||
page_height = dim_temp;
|
||||
}
|
||||
|
||||
/* create cairo data */
|
||||
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
|
||||
page->width, page->height);
|
||||
page_width, page_height);
|
||||
|
||||
if(!surface) {
|
||||
return NULL;
|
||||
@ -265,6 +276,10 @@ pdf_page_render(zathura_page_t* page)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cairo_set_source_rgb(cairo, 1, 1, 1);
|
||||
cairo_rectangle(cairo, 0, 0, page_width, page_height);
|
||||
cairo_fill(cairo);
|
||||
|
||||
switch(Zathura.document->rotate) {
|
||||
case 90:
|
||||
cairo_translate(cairo, page->width, 0);
|
||||
@ -286,7 +301,6 @@ pdf_page_render(zathura_page_t* page)
|
||||
/* render */
|
||||
poppler_page_render(page->data, cairo);
|
||||
|
||||
cairo_paint(cairo);
|
||||
cairo_destroy(cairo);
|
||||
|
||||
return surface;
|
||||
|
Loading…
Reference in New Issue
Block a user