From c5471937c9c6c79cc932d52c235fac3e4a26a9ae Mon Sep 17 00:00:00 2001 From: erikn69 Date: Tue, 30 Dec 2025 12:57:12 -0500 Subject: [PATCH] Implement XRefStm handling in PDFUtilFnc Added handling for XRefStm in PDF trailer processing. --- src/PDFUtilFnc.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/PDFUtilFnc.php b/src/PDFUtilFnc.php index 4f3148b..0f18714 100644 --- a/src/PDFUtilFnc.php +++ b/src/PDFUtilFnc.php @@ -347,6 +347,16 @@ public static function get_xref_1_4(&$_buffer, $xref_pos, $depth = null) { // Get the trailer object $trailer_obj = PDFUtilFnc::get_trailer($_buffer, $trailer_pos); + if (isset($trailer_obj['XRefStm'])) { + $xrefstm_pos = $trailer_obj['XRefStm']->get_int(); + [ $xrefstm_table ] = PDFUtilFnc::get_xref_1_5($_buffer, $xrefstm_pos, $depth); + + foreach ($xrefstm_table as $oid => $val) { + if (!isset($xref_table[$oid])) { + $xref_table[$oid] = $val; + } + } + } // If there exists a previous xref (for incremental PDFs), get it and merge the objects that do not exist in the current xref table if (isset($trailer_obj['Prev'])) {