Replace catalog object if found.
Signed-off-by: yzrh <yzrh@noema.org>
This commit is contained in:
parent
8276423eb8
commit
8cd8a8fbba
1 changed files with 26 additions and 18 deletions
|
@ -244,10 +244,6 @@ cnki_pdf(cnki_t **param)
|
||||||
printf("Loaded %d object(s)\n",
|
printf("Loaded %d object(s)\n",
|
||||||
pdf_get_count(&pdf));
|
pdf_get_count(&pdf));
|
||||||
|
|
||||||
pdf_obj_sort(&pdf);
|
|
||||||
|
|
||||||
_pdf_obj_dedup(param, &pdf);
|
|
||||||
|
|
||||||
int dictionary_size;
|
int dictionary_size;
|
||||||
char *dictionary;
|
char *dictionary;
|
||||||
|
|
||||||
|
@ -262,6 +258,10 @@ cnki_pdf(cnki_t **param)
|
||||||
if ((*param)->stat > 0)
|
if ((*param)->stat > 0)
|
||||||
printf("Discovered %d parent object(s)\n", parent[0]);
|
printf("Discovered %d parent object(s)\n", parent[0]);
|
||||||
|
|
||||||
|
pdf_obj_sort(&pdf);
|
||||||
|
|
||||||
|
_pdf_obj_dedup(param, &pdf);
|
||||||
|
|
||||||
int8_t *parent_missing;
|
int8_t *parent_missing;
|
||||||
int *kid;
|
int *kid;
|
||||||
|
|
||||||
|
@ -419,21 +419,6 @@ cnki_pdf(cnki_t **param)
|
||||||
|
|
||||||
int outline = _pdf_cnki_outline(param, &pdf);
|
int outline = _pdf_cnki_outline(param, &pdf);
|
||||||
|
|
||||||
if ((*param)->stat > 1)
|
|
||||||
printf("Searching for catalog object\n");
|
|
||||||
|
|
||||||
int catalog = pdf_get_catalog_id(&pdf);
|
|
||||||
|
|
||||||
if (catalog != 0) {
|
|
||||||
if ((*param)->stat > 0)
|
|
||||||
printf("Catalog object is %d.\n", catalog);
|
|
||||||
} else {
|
|
||||||
if ((*param)->stat > 0)
|
|
||||||
printf("Catalog object is missing\n");
|
|
||||||
|
|
||||||
if ((*param)->stat > 1)
|
|
||||||
printf("Generating catalog object\n");
|
|
||||||
|
|
||||||
snprintf(buf, 64,
|
snprintf(buf, 64,
|
||||||
"<<\n/Type /Catalog\n/Pages %d 0 R\n",
|
"<<\n/Type /Catalog\n/Pages %d 0 R\n",
|
||||||
root);
|
root);
|
||||||
|
@ -448,6 +433,29 @@ cnki_pdf(cnki_t **param)
|
||||||
|
|
||||||
strcat(dictionary, ">>");
|
strcat(dictionary, ">>");
|
||||||
|
|
||||||
|
if ((*param)->stat > 1)
|
||||||
|
printf("Searching for catalog object\n");
|
||||||
|
|
||||||
|
int catalog = pdf_get_catalog_id(&pdf);
|
||||||
|
|
||||||
|
if (catalog != 0) {
|
||||||
|
if ((*param)->stat > 0)
|
||||||
|
printf("Catalog object is %d.\n", catalog);
|
||||||
|
|
||||||
|
if ((*param)->stat > 1)
|
||||||
|
printf("Replacing catalog object\n");
|
||||||
|
|
||||||
|
pdf_obj_replace(&pdf, catalog, NULL, dictionary, NULL, 0);
|
||||||
|
|
||||||
|
if ((*param)->stat > 0)
|
||||||
|
printf("Replaced catalog object\n");
|
||||||
|
} else {
|
||||||
|
if ((*param)->stat > 0)
|
||||||
|
printf("Catalog object is missing\n");
|
||||||
|
|
||||||
|
if ((*param)->stat > 1)
|
||||||
|
printf("Generating catalog object\n");
|
||||||
|
|
||||||
pdf_obj_append(&pdf, 0, NULL, dictionary, NULL, 0);
|
pdf_obj_append(&pdf, 0, NULL, dictionary, NULL, 0);
|
||||||
|
|
||||||
if ((*param)->stat > 0)
|
if ((*param)->stat > 0)
|
||||||
|
|
Loading…
Reference in a new issue