Branch Coverage

src/pdfmake_page.c
Criterion Covered Total %
branch 99 174 56.9


line true false branch
38 0 237 if (font < 0 || font >= PDFMAKE_FONT_COUNT) return NULL;
44 0 469 if (!name) return -1;
45 2809 48 for (i = 0; i < PDFMAKE_FONT_COUNT; i++) {
46 421 2388 if (strcmp(name, std14_names[i]) == 0) return i;
56 7 266 size_t new_cap = doc->page_cap == 0 ? 4 : doc->page_cap * 2;
58 0 273 if (!new_arr) return 0;
70 0 370 if (!doc) return NULL;
71 0 370 if (doc->finalized) return NULL; /* Can't add pages after finalize */
74 273 97 if (doc->page_count >= doc->page_cap) {
75 0 273 if (!doc_grow_pages(doc)) return NULL;
80 0 370 if (!page) return NULL;
106 116 0 return doc ? doc->page_count : 0;
110 78 0 if (!doc || index >= doc->page_count) return NULL;
1 77 if (!doc || index >= doc->page_count) return NULL;
130 243 0 if (!page || !name || !base_font) return 0;
243 0 if (!page || !name || !base_font) return 0;
0 243 if (!page || !name || !base_font) return 0;
131 0 243 if (page->font_count >= PDFMAKE_MAX_PAGE_FONTS) return 0;
134 0 243 if (pdfmake_std14_lookup(base_font) < 0) return 0;
142 0 243 if (font_dict.kind != PDFMAKE_DICT) return 0;
154 0 243 if (font_num == 0) return 0;
169 0 237 if (!base_font) return 0;
179 3 0 if (!page || !name || extgstate_obj_num == 0) return -1;
3 0 if (!page || !name || extgstate_obj_num == 0) return -1;
0 3 if (!page || !name || extgstate_obj_num == 0) return -1;
180 0 3 if (page->extgstate_count >= PDFMAKE_MAX_PAGE_EXTGSTATES) return -1;
202 233 0 if (!page || !data) return PDFMAKE_EINVAL;
0 233 if (!page || !data) return PDFMAKE_EINVAL;
209 0 233 if (stream.kind != PDFMAKE_STREAM) return PDFMAKE_ENOMEM;
211 0 233 if (!pdfmake_stream_set_data(arena, &stream, data, len)) {
217 0 233 if (contents_num == 0) return PDFMAKE_ENOMEM;
227 0 0 if (!content) return PDFMAKE_EINVAL;
245 0 0 if (!page || !data) return PDFMAKE_EINVAL;
0 0 if (!page || !data) return PDFMAKE_EINVAL;
246 0 0 if (!page->has_content || page->contents_num == 0) {
0 0 if (!page->has_content || page->contents_num == 0) {
258 0 0 if (!existing || existing->kind != PDFMAKE_STREAM) {
0 0 if (!existing || existing->kind != PDFMAKE_STREAM) {
275 0 0 if (!combined) return PDFMAKE_ENOMEM;
279 0 0 if (old_len == 0 || old_bytes[old_len - 1] != '\n') combined[off++] = '\n';
0 0 if (old_len == 0 || old_bytes[old_len - 1] != '\n') combined[off++] = '\n';
282 0 0 if (len == 0 || data[len - 1] != '\n') combined[off++] = '\n';
0 0 if (len == 0 || data[len - 1] != '\n') combined[off++] = '\n';
307 0 207 if (resources.kind != PDFMAKE_DICT) return resources;
310 142 65 if (page->font_count > 0) {
312 0 142 if (font_dict.kind != PDFMAKE_DICT) return font_dict;
314 226 142 for (i = 0; i < page->font_count; i++) {
326 12 195 if (page->image_count > 0) {
328 0 12 if (xobj_dict.kind != PDFMAKE_DICT) return xobj_dict;
330 17 12 for (i = 0; i < page->image_count; i++) {
342 5 202 if (page->prop_count > 0) {
344 0 5 if (prop_dict.kind != PDFMAKE_DICT) return prop_dict;
346 8 5 for (i = 0; i < page->prop_count; i++) {
358 1 206 if (page->extgstate_count > 0) {
360 0 1 if (gs_dict.kind != PDFMAKE_DICT) return gs_dict;
362 1 1 for (i = 0; i < page->extgstate_count; i++) {
381 0 0 return doc ? doc->finalized : 0;
422 0 163 if (!doc) return PDFMAKE_EINVAL;
423 0 163 if (doc->finalized) return PDFMAKE_OK; /* Already finalized */
439 0 163 if (pages_dict.kind != PDFMAKE_DICT) return PDFMAKE_ENOMEM;
445 0 163 if (kids.kind != PDFMAKE_ARRAY) return PDFMAKE_ENOMEM;
449 0 163 if (pages_num == 0) return PDFMAKE_ENOMEM;
455 241 163 for (i = 0; i < doc->page_count; i++) {
459 0 241 if (page_dict.kind != PDFMAKE_DICT) return PDFMAKE_ENOMEM;
477 34 207 if (page->imported_resources) {
486 214 27 if (page->has_content) {
492 1 240 if (page->rotation != 0) {
500 0 241 if (page_num == 0) return PDFMAKE_ENOMEM;
509 163 0 if (!pages_obj || pages_obj->kind != PDFMAKE_DICT) return PDFMAKE_EINVAL;
0 163 if (!pages_obj || pages_obj->kind != PDFMAKE_DICT) return PDFMAKE_EINVAL;
516 0 163 if (catalog.kind != PDFMAKE_DICT) return PDFMAKE_ENOMEM;
523 5 158 if (outline) {
525 5 0 if (outlines_num > 0) {
533 15 148 if (form && form->form_num > 0) {
11 4 if (form && form->form_num > 0) {
540 0 163 if (catalog_num == 0) return PDFMAKE_ENOMEM;
546 5 158 if (doc->ocg_count > 0) {
548 0 5 if (ocerr != PDFMAKE_OK) return ocerr;
552 3 160 if (doc->attach_count > 0) {
554 0 3 if (aterr != PDFMAKE_OK) return aterr;
560 0 163 if (tagerr != PDFMAKE_OK) return tagerr;
564 241 163 for (i = 0; i < doc->page_count; i++) {
566 26 215 if (page->annot_count > 0 && page->page_num > 0) {
26 0 if (page->annot_count > 0 && page->page_num > 0) {
568 26 0 if (page_obj && page_obj->kind == PDFMAKE_DICT) {
26 0 if (page_obj && page_obj->kind == PDFMAKE_DICT) {
570 70 26 for (j = 0; j < page->annot_count; j++) {