1 | #ifndef MUPDF_PDF_XREF_H |
2 | #define MUPDF_PDF_XREF_H |
3 | |
4 | int pdf_create_object(fz_context *ctx, pdf_document *doc); |
5 | |
6 | void pdf_delete_object(fz_context *ctx, pdf_document *doc, int num); |
7 | |
8 | void pdf_update_object(fz_context *ctx, pdf_document *doc, int num, pdf_obj *obj); |
9 | |
10 | void pdf_update_stream(fz_context *ctx, pdf_document *doc, pdf_obj *ref, fz_buffer *buf, int compressed); |
11 | |
12 | pdf_obj *pdf_add_object(fz_context *ctx, pdf_document *doc, pdf_obj *obj); |
13 | pdf_obj *pdf_add_object_drop(fz_context *ctx, pdf_document *doc, pdf_obj *obj); |
14 | pdf_obj *pdf_add_stream(fz_context *ctx, pdf_document *doc, fz_buffer *buf, pdf_obj *obj, int compressed); |
15 | |
16 | pdf_obj *pdf_add_new_dict(fz_context *ctx, pdf_document *doc, int initial); |
17 | pdf_obj *pdf_add_new_array(fz_context *ctx, pdf_document *doc, int initial); |
18 | |
19 | typedef struct pdf_xref_entry_s pdf_xref_entry; |
20 | |
21 | struct pdf_xref_entry_s |
22 | { |
23 | char type; /* 0=unset (f)ree i(n)use (o)bjstm */ |
24 | unsigned char marked; /* marked to keep alive with pdf_mark_xref */ |
25 | unsigned short gen; /* generation / objstm index */ |
26 | int num; /* original object number (for decryption after renumbering) */ |
27 | int64_t ofs; /* file offset / objstm object number */ |
28 | int64_t stm_ofs; /* on-disk stream */ |
29 | fz_buffer *stm_buf; /* in-memory stream (for updated objects) */ |
30 | pdf_obj *obj; /* stored/cached object */ |
31 | }; |
32 | |
33 | typedef struct pdf_xref_subsec_s pdf_xref_subsec; |
34 | |
35 | struct pdf_xref_subsec_s |
36 | { |
37 | pdf_xref_subsec *next; |
38 | int len; |
39 | int start; |
40 | pdf_xref_entry *table; |
41 | }; |
42 | |
43 | struct pdf_xref_s |
44 | { |
45 | int num_objects; |
46 | pdf_xref_subsec *subsec; |
47 | pdf_obj *trailer; |
48 | pdf_obj *pre_repair_trailer; |
49 | pdf_unsaved_sig *unsaved_sigs; |
50 | pdf_unsaved_sig **unsaved_sigs_end; |
51 | int64_t end_ofs; /* file offset to end of xref */ |
52 | }; |
53 | |
54 | pdf_xref_entry *pdf_cache_object(fz_context *ctx, pdf_document *doc, int num); |
55 | |
56 | int pdf_count_objects(fz_context *ctx, pdf_document *doc); |
57 | pdf_obj *pdf_resolve_indirect(fz_context *ctx, pdf_obj *ref); |
58 | pdf_obj *pdf_resolve_indirect_chain(fz_context *ctx, pdf_obj *ref); |
59 | pdf_obj *pdf_load_object(fz_context *ctx, pdf_document *doc, int num); |
60 | pdf_obj *pdf_load_unencrypted_object(fz_context *ctx, pdf_document *doc, int num); |
61 | |
62 | fz_buffer *pdf_load_raw_stream_number(fz_context *ctx, pdf_document *doc, int num); |
63 | fz_buffer *pdf_load_raw_stream(fz_context *ctx, pdf_obj *ref); |
64 | fz_buffer *pdf_load_stream_number(fz_context *ctx, pdf_document *doc, int num); |
65 | fz_buffer *pdf_load_stream(fz_context *ctx, pdf_obj *ref); |
66 | fz_stream *pdf_open_raw_stream_number(fz_context *ctx, pdf_document *doc, int num); |
67 | fz_stream *pdf_open_raw_stream(fz_context *ctx, pdf_obj *ref); |
68 | fz_stream *pdf_open_stream_number(fz_context *ctx, pdf_document *doc, int num); |
69 | fz_stream *pdf_open_stream(fz_context *ctx, pdf_obj *ref); |
70 | |
71 | fz_stream *pdf_open_inline_stream(fz_context *ctx, pdf_document *doc, pdf_obj *stmobj, int length, fz_stream *chain, fz_compression_params *params); |
72 | fz_compressed_buffer *pdf_load_compressed_stream(fz_context *ctx, pdf_document *doc, int num); |
73 | void pdf_load_compressed_inline_image(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int length, fz_stream *cstm, int indexed, fz_compressed_image *image); |
74 | fz_stream *pdf_open_stream_with_offset(fz_context *ctx, pdf_document *doc, int num, pdf_obj *dict, int64_t stm_ofs); |
75 | fz_stream *pdf_open_compressed_stream(fz_context *ctx, fz_compressed_buffer *); |
76 | fz_stream *pdf_open_contents_stream(fz_context *ctx, pdf_document *doc, pdf_obj *obj); |
77 | |
78 | pdf_obj *pdf_trailer(fz_context *ctx, pdf_document *doc); |
79 | void pdf_set_populating_xref_trailer(fz_context *ctx, pdf_document *doc, pdf_obj *trailer); |
80 | int pdf_xref_len(fz_context *ctx, pdf_document *doc); |
81 | pdf_xref_entry *pdf_get_populating_xref_entry(fz_context *ctx, pdf_document *doc, int i); |
82 | pdf_xref_entry *pdf_get_xref_entry(fz_context *ctx, pdf_document *doc, int i); |
83 | void pdf_replace_xref(fz_context *ctx, pdf_document *doc, pdf_xref_entry *entries, int n); |
84 | void pdf_forget_xref(fz_context *ctx, pdf_document *doc); |
85 | void pdf_xref_ensure_incremental_object(fz_context *ctx, pdf_document *doc, int num); |
86 | int pdf_xref_is_incremental(fz_context *ctx, pdf_document *doc, int num); |
87 | void pdf_xref_store_unsaved_signature(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer); |
88 | int pdf_xref_obj_is_unsaved_signature(pdf_document *doc, pdf_obj *obj); |
89 | |
90 | void pdf_repair_xref(fz_context *ctx, pdf_document *doc); |
91 | void pdf_repair_obj_stms(fz_context *ctx, pdf_document *doc); |
92 | void pdf_ensure_solid_xref(fz_context *ctx, pdf_document *doc, int num); |
93 | void pdf_mark_xref(fz_context *ctx, pdf_document *doc); |
94 | void pdf_clear_xref(fz_context *ctx, pdf_document *doc); |
95 | void pdf_clear_xref_to_mark(fz_context *ctx, pdf_document *doc); |
96 | |
97 | int pdf_repair_obj(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf, int64_t *stmofsp, int *stmlenp, pdf_obj **encrypt, pdf_obj **id, pdf_obj **page, int64_t *tmpofs, pdf_obj **root); |
98 | |
99 | pdf_obj *pdf_progressive_advance(fz_context *ctx, pdf_document *doc, int pagenum); |
100 | |
101 | #endif |
102 | |