Rework token reading to be separate from the PDF file so we can add support

for compressed object streams.
This commit is contained in:
Michael R Sweet
2021-05-08 07:38:44 -04:00
parent 923409ceff
commit 9a919d478f
9 changed files with 211 additions and 166 deletions

View File

@@ -521,6 +521,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
num_objects, // Number of objects
offset; // Offset in file
int generation; // Generation number
_pdfio_token_t tb; // Token buffer/stack
while (!done)
@@ -581,7 +582,9 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
return (false);
}
if (!_pdfioValueRead(pdf, &trailer))
_pdfioTokenInit(&tb, pdf, (_pdfio_tconsume_cb_t)_pdfioFileConsume, (_pdfio_tpeek_cb_t)_pdfioFilePeek, pdf);
if (!_pdfioValueRead(pdf, &tb, &trailer))
{
_pdfioFileError(pdf, "Unable to read cross-reference stream dictionary.");
return (false);
@@ -594,7 +597,7 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
obj->value = trailer;
if (!_pdfioFileGetToken(pdf, line, sizeof(line)) || strcmp(line, "stream"))
if (!_pdfioTokenGet(&tb, line, sizeof(line)) || strcmp(line, "stream"))
{
_pdfioFileError(pdf, "Unable to get stream after xref dictionary.");
return (false);
@@ -748,7 +751,9 @@ load_xref(pdfio_file_t *pdf, // I - PDF file
return (false);
}
if (!_pdfioValueRead(pdf, &trailer))
_pdfioTokenInit(&tb, pdf, (_pdfio_tconsume_cb_t)_pdfioFileConsume, (_pdfio_tpeek_cb_t)_pdfioFilePeek, pdf);
if (!_pdfioValueRead(pdf, &tb, &trailer))
{
_pdfioFileError(pdf, "Unable to read trailer dictionary.");
return (false);