mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2025-04-17 05:56:48 +02:00
Implement support for multiple index arrays (Issue #8)
This commit is contained in:
parent
3e4b01239e
commit
cd5158bae0
20
pdfio-file.c
20
pdfio-file.c
@ -1160,6 +1160,8 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
|
||||
pdfio_obj_t *obj; // Object
|
||||
size_t i; // Looping var
|
||||
pdfio_array_t *index_array; // Index array
|
||||
size_t index_n, // Current element in array
|
||||
index_count; // Number of values in index array
|
||||
pdfio_array_t *w_array; // W array
|
||||
size_t w[3]; // Size of each cross-reference field
|
||||
size_t w_2, // Offset to second field
|
||||
@ -1225,18 +1227,9 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
|
||||
obj->stream_offset = _pdfioFileTell(pdf);
|
||||
|
||||
if ((index_array = pdfioDictGetArray(trailer.value.dict, "Index")) != NULL)
|
||||
{
|
||||
if (index_array->num_values > 2)
|
||||
{
|
||||
// TODO: Support Index array with multiple values in xref streams
|
||||
_pdfioFileError(pdf, "Multiple indices not supported in cross-reference stream.");
|
||||
return (false);
|
||||
}
|
||||
|
||||
number = (intmax_t)pdfioArrayGetNumber(index_array, 0);
|
||||
}
|
||||
index_count = index_array->num_values;
|
||||
else
|
||||
number = 0;
|
||||
index_count = 0;
|
||||
|
||||
if ((w_array = pdfioDictGetArray(trailer.value.dict, "W")) == NULL)
|
||||
{
|
||||
@ -1263,6 +1256,10 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
|
||||
return (false);
|
||||
}
|
||||
|
||||
for (index_n = 0; index_n < index_count; index_n ++)
|
||||
{
|
||||
number = (intmax_t)pdfioArrayGetNumber(index_array, index_n);
|
||||
|
||||
while (pdfioStreamRead(st, buffer, w_total) > 0)
|
||||
{
|
||||
PDFIO_DEBUG("load_xref: %02X%02X%02X%02X%02X\n", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4]);
|
||||
@ -1328,6 +1325,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
|
||||
|
||||
number ++;
|
||||
}
|
||||
}
|
||||
|
||||
pdfioStreamClose(st);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user