mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-11-17 02:48:24 +01:00
0a1fe0ce73
pdfioDictGetNumKeys -> pdfioDictGetNumPairs pdfioDictGetKeyByIndex: - only return the key string and then only return a const char * test_mod.c: - changed to contemplate the requested modification
35 lines
732 B
C
35 lines
732 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "pdfio.h"
|
|
|
|
/*
|
|
* Usage: ./test_mod [file.pdf]
|
|
*
|
|
* Compiled as:
|
|
* gcc test_mod.c -L. -lpdfio -lm -lz -o test_mod
|
|
*
|
|
*/
|
|
|
|
|
|
int main (int argc, char **argv)
|
|
{
|
|
pdfio_file_t *pdf = pdfioFileOpen(argv[1], NULL, NULL, NULL, NULL);
|
|
pdfio_obj_t *obj_page = pdfioFileGetPage(pdf, 0);
|
|
pdfio_dict_t *dict_page = pdfioObjGetDict(obj_page);
|
|
|
|
size_t num_keys = pdfioDictGetNumPairs(dict_page);
|
|
printf("Number of keys in this page: %d\n", num_keys);
|
|
|
|
const char *key;
|
|
for (unsigned int i = 0; i < num_keys; ++i)
|
|
{
|
|
key = pdfioDictGetKeyByIndex(dict_page, i);
|
|
pdfio_valtype_t type = pdfioDictGetType(dict_page, key);
|
|
printf("\t%s (%d)\n", key, type);
|
|
}
|
|
|
|
pdfioFileClose(pdf);
|
|
|
|
return 0;
|
|
}
|