fz_stext_page * fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_stext_sheet *sheet) { fz_stext_page *text; fz_device *dev; fz_rect mediabox; if (page == NULL) return NULL; text = fz_new_stext_page(ctx, fz_bound_page(ctx, page, &mediabox)); fz_try(ctx) { dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, page, dev, &fz_identity, NULL); fz_close_device(ctx, dev); } fz_always(ctx) { fz_drop_device(ctx, dev); } fz_catch(ctx) { fz_drop_stext_page(ctx, text); fz_rethrow(ctx); } return text; }
static void fz_stext_begin_page(fz_context *ctx, fz_device *dev, const fz_rect *mediabox, const fz_matrix *ctm) { fz_stext_device *tdev = (fz_stext_device*)dev; if (tdev->page->len) { tdev->page->next = fz_new_stext_page(ctx); tdev->page = tdev->page->next; } tdev->page->mediabox = *mediabox; fz_transform_rect(&tdev->page->mediabox, ctm); }
static fz_device * text_begin_page(fz_context *ctx, fz_document_writer *wri_, const fz_rect *mediabox) { fz_text_writer *wri = (fz_text_writer*)wri_; if (wri->page) { fz_drop_stext_page(ctx, wri->page); wri->page = NULL; } wri->page = fz_new_stext_page(ctx, mediabox); return fz_new_stext_device(ctx, wri->page, &wri->opts); }
fz_stext_page * fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_stext_sheet *sheet) { fz_stext_page *text; fz_device *dev; text = fz_new_stext_page(ctx); fz_try(ctx) { dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, page, dev, &fz_identity, NULL); } fz_always(ctx) { fz_drop_device(ctx, dev); } fz_catch(ctx) { fz_drop_stext_page(ctx, text); fz_rethrow(ctx); } return text; }