| 2124 | } |
| 2125 | |
| 2126 | bool pdf_doc_open(pdf_doc_t *d) { |
| 2127 | const unsigned char *h = cbm_memmem(d->data, d->len, "%PDF-", 5); |
| 2128 | d->hdr = h ? (size_t)(h - d->data) : 0; |
| 2129 | bool ok = load_xref(d); |
| 2130 | if (ok) { |
| 2131 | pdf_val_t *root = pdf_resolve(d, pdf_dget_raw(d->trailer, "Root")); |
| 2132 | ok = root && root->kind == PV_DICT; |
| 2133 | } |
| 2134 | if (!ok && !d->nomem) { |
| 2135 | reconstruct(d); |
| 2136 | } |
| 2137 | return !d->nomem; |
| 2138 | } |
| 2139 | |
| 2140 | void pdf_doc_close(pdf_doc_t *d) { |
| 2141 | if (d->scratch_arena_live) { |
no test coverage detected