- if (pg->bg->type == BG_PDF) { // request an asynchronous update
- if (pg->bg->pixbuf_scale == ui.zoom) continue;
- add_bgpdf_request(pg->bg->file_page_seq, ui.zoom, FALSE);
- pg->bg->pixbuf_scale = ui.zoom;
+ if (pg->bg->type == BG_PDF) {
+ // make pixmap scale to correct size if current one is wrong
+ is_well_scaled = (fabs(pg->bg->pixel_width - pg->width*ui.zoom) < 2.
+ && fabs(pg->bg->pixel_height - pg->height*ui.zoom) < 2.);
+ if (pg->bg->canvas_item != NULL && !is_well_scaled) {
+ g_object_get(pg->bg->canvas_item, "width-in-pixels", &is_well_scaled, NULL);
+ if (is_well_scaled)
+ gnome_canvas_item_set(pg->bg->canvas_item,
+ "width", pg->width, "height", pg->height,
+ "width-in-pixels", FALSE, "height-in-pixels", FALSE,
+ "width-set", TRUE, "height-set", TRUE,
+ NULL);
+ }
+ // request an asynchronous update to a better pixmap if needed
+ zoom_to_request = MIN(ui.zoom, MAX_SAFE_RENDER_DPI/72.0);
+ if (pg->bg->pixbuf_scale == zoom_to_request) continue;
+ add_bgpdf_request(pg->bg->file_page_seq, zoom_to_request);
+ pg->bg->pixbuf_scale = zoom_to_request;