Files
ElyOffice/crates/ely-pdf-engine/shim/ely_shim.h
T
ZacharyZhang-NY b7fca0146d Ely Office: six offline-first desktop apps in Rust and GPUI
ElyDoc, ElyTable, ElyShow (LibreOfficeKit), ElyPDF (MuPDF), ElyTree (Git),
ElyMark (Milkdown and CodeMirror in CEF). ElyMail and ElyAgent follow.
2026-10-08 21:20:08 -04:00

57 lines
2.4 KiB
C

/* What the shim files share. */
#ifndef ELY_SHIM_H
#define ELY_SHIM_H
#include <mupdf/fitz.h>
#include <mupdf/pdf.h>
int ely_fail(fz_context *ctx);
const char *ely_error(void);
int ely_render(fz_context *ctx, fz_document *doc, int number, float scale, int rotate, const int tile[4], int dark,
unsigned char *bgra);
void ely_fail_also(fz_context *ctx, const char *what);
pdf_document *ely_pdf_of(fz_context *ctx, fz_document *doc);
int ely_edit_failed(fz_context *ctx, pdf_document *pdf, int begun);
void ely_forget_resources(fz_context *ctx, pdf_document *pdf);
pdf_obj *ely_target(fz_context *ctx, pdf_document *pdf, pdf_obj *obj);
typedef void (ely_change)(fz_context *ctx, fz_document *copy, void *arg);
void ely_save_copy(fz_context *ctx, pdf_document *pdf, const char *raw, const char *out, const char *password,
const pdf_write_options *opts,
ely_change *change, void *arg);
/* A text block as read, page space, and its glyphs. */
typedef struct
{
void *glyphs;
fz_font *font;
fz_point first;
float size;
int rgb;
fz_rect bbox;
int lines;
float gap;
} ely_shape;
fz_matrix ely_to_user(fz_context *ctx, pdf_page *page);
void ely_read_block(fz_context *ctx, fz_document *doc, pdf_page *page, int number, int index, const char *expected,
ely_shape *shape);
void ely_remove_block(fz_context *ctx, pdf_document *pdf, pdf_page *page, ely_shape *shape);
void ely_drop_shape(fz_context *ctx, ely_shape *shape);
pdf_obj *ely_append_content(fz_context *ctx, pdf_document *pdf, pdf_obj *page, fz_buffer *buf);
const char *ely_add_resource(fz_context *ctx, pdf_document *pdf, pdf_obj *page, pdf_obj *type, const char *stem,
pdf_obj *ref, char *name, size_t room);
void ely_json_string(fz_context *ctx, fz_output *out, const char *s);
fz_json *ely_member(fz_context *ctx, fz_json *obj, const char *key, int type);
float ely_number(fz_context *ctx, fz_json *array, int at);
fz_rect ely_rect(fz_context *ctx, fz_json *array, float least);
pdf_annot *ely_find_annot(fz_context *ctx, pdf_page *page, int id, int widget);
void ely_write_fields(fz_context *ctx, fz_output *out, pdf_page *page);
void ely_unlink_field(fz_context *ctx, pdf_document *pdf, pdf_obj *field);
void ely_unsign(fz_context *ctx, pdf_document *pdf);
void ely_watch_begin(fz_context *ctx);
int ely_watch_end(fz_context *ctx);
const char *ely_open_warnings(void);
void ely_drop_alt(fz_context *ctx, pdf_document *pdf, pdf_page *page);
#endif