Commit a3f70378 authored by Pavel Vinogradov's avatar Pavel Vinogradov

Updated for MuPDF 1.12.0

parent 6f81c08f
......@@ -43,18 +43,16 @@ pdf_page_images_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_erro
/* Extract images */
mupdf_page_extract_text(mupdf_document, mupdf_page);
fz_page_block* block;
for (block = mupdf_page->text->blocks; block < mupdf_page->text->blocks + mupdf_page->text->len; block++) {
if (block->type == FZ_PAGE_BLOCK_IMAGE) {
fz_image_block *image_block = block->u.image;
fz_stext_block* block;
for (block = mupdf_page->text->first_block; block; block = block->next) {
if (block->type == FZ_STEXT_BLOCK_IMAGE) {
zathura_image_t* zathura_image = g_malloc(sizeof(zathura_image_t));
zathura_image->position.x1 = image_block->bbox.x0;
zathura_image->position.y1 = image_block->bbox.y0;
zathura_image->position.x2 = image_block->bbox.x1;
zathura_image->position.y2 = image_block->bbox.y1;
zathura_image->data = image_block->image;
zathura_image->position.x1 = block->bbox.x0;
zathura_image->position.y1 = block->bbox.y0;
zathura_image->position.x2 = block->bbox.x1;
zathura_image->position.y2 = block->bbox.y1;
zathura_image->data = block->u.i.image;
girara_list_append(list, zathura_image);
}
......
......@@ -44,11 +44,6 @@ pdf_page_init(zathura_page_t* page)
goto error_free;
}
mupdf_page->sheet = fz_new_stext_sheet(mupdf_page->ctx);
if (mupdf_page->sheet == NULL) {
goto error_free;
}
zathura_page_set_data(page, mupdf_page);
/* get page dimensions */
......@@ -79,10 +74,6 @@ pdf_page_clear(zathura_page_t* page, mupdf_page_t* mupdf_page)
fz_drop_stext_page(mupdf_page->ctx, mupdf_page->text);
}
if (mupdf_page->sheet != NULL) {
fz_drop_stext_sheet(mupdf_page->ctx, mupdf_page->sheet);
}
if (mupdf_page->page != NULL) {
fz_drop_page(mupdf_document->ctx, mupdf_page->page);
}
......
......@@ -3,6 +3,8 @@
#ifndef PDF_H
#define PDF_H
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <zathura/plugin-api.h>
#include <mupdf/fitz.h>
......@@ -18,7 +20,6 @@ typedef struct mupdf_page_s
{
fz_page* page; /**< Reference to the mupdf page */
fz_context* ctx; /**< Context */
fz_stext_sheet* sheet; /**< Text sheet */
fz_stext_page* text; /**< Page text */
fz_rect bbox; /**< Bbox */
bool extracted_text; /**< If text has already been extracted */
......
......@@ -37,7 +37,8 @@ pdf_page_render_to_buffer(mupdf_document_t* mupdf_document, mupdf_page_t* mupdf_
fz_rect rect = { .x1 = page_width, .y1 = page_height };
fz_colorspace* colorspace = fz_device_bgr(mupdf_document->ctx);
fz_pixmap* pixmap = fz_new_pixmap_with_bbox_and_data(mupdf_page->ctx, colorspace, &irect, 1, image);
fz_separations* seps= fz_page_separations(mupdf_page->ctx, mupdf_page->page);
fz_pixmap* pixmap = fz_new_pixmap_with_bbox_and_data(mupdf_page->ctx, colorspace, &irect, seps, 1, image);
fz_clear_pixmap_with_value(mupdf_page->ctx, pixmap, 0xFF);
device = fz_new_draw_device(mupdf_page->ctx, NULL, pixmap);
......@@ -46,6 +47,7 @@ pdf_page_render_to_buffer(mupdf_document_t* mupdf_document, mupdf_page_t* mupdf_
fz_drop_pixmap(mupdf_page->ctx, pixmap);
fz_drop_display_list(mupdf_page->ctx, display_list);
fz_drop_separations(mupdf_page->ctx, seps);
return ZATHURA_ERROR_OK;
}
......
......@@ -24,9 +24,14 @@ pdf_page_get_text(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_rectan
mupdf_page_extract_text(mupdf_document, mupdf_page);
}
fz_rect rect = { rectangle.x1, rectangle.y1, rectangle.x2, rectangle.y2 };
return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, rect);
fz_point a = { rectangle.x1, rectangle.y1 };
fz_point b = { rectangle.x2, rectangle.y2 };
#ifdef _WIN32
return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, a, b, 1);
#else
return fz_copy_selection(mupdf_page->ctx, mupdf_page->text, a, b, 0);
#endif
error_ret:
......
......@@ -7,17 +7,17 @@
void
mupdf_page_extract_text(mupdf_document_t* mupdf_document, mupdf_page_t* mupdf_page) {
if (mupdf_document == NULL || mupdf_document->ctx == NULL || mupdf_page == NULL ||
mupdf_page->sheet == NULL || mupdf_page->text == NULL) {
mupdf_page->text == NULL) {
return;
}
fz_device* text_device = NULL;
fz_try (mupdf_page->ctx) {
text_device = fz_new_stext_device(mupdf_page->ctx, mupdf_page->sheet, mupdf_page->text, NULL);
text_device = fz_new_stext_device(mupdf_page->ctx, mupdf_page->text, NULL);
/* Disable FZ_IGNORE_IMAGE to collect image blocks */
fz_disable_device_hints(mupdf_page->ctx, text_device, FZ_IGNORE_IMAGE);
/* Disable FZ_DONT_INTERPOLATE_IMAGES to collect image blocks */
fz_disable_device_hints(mupdf_page->ctx, text_device, FZ_DONT_INTERPOLATE_IMAGES);
fz_matrix ctm;
fz_scale(&ctm, 1.0, 1.0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment