diff --git a/Userland/Libraries/LibPDF/Document.cpp b/Userland/Libraries/LibPDF/Document.cpp index 62989271e4..3e4e7a0115 100644 --- a/Userland/Libraries/LibPDF/Document.cpp +++ b/Userland/Libraries/LibPDF/Document.cpp @@ -451,7 +451,15 @@ PDFErrorOr Document::create_destination_from_parameters(NonnullRefP VERIFY_NOT_REACHED(); } - return Destination { type, page_number_by_index_ref.get(page_ref.as_ref_index()), parameters }; + // The spec requires page_ref to be an indirect reference to a page object, + // but in practice it's sometimes a page index. + Optional page_number; + if (page_ref.has()) + page_number = page_ref.get(); + else + page_number = page_number_by_index_ref.get(page_ref.as_ref_index()); + + return Destination { type, page_number, parameters }; } PDFErrorOr>> Document::get_inheritable_object(DeprecatedFlyString const& name, NonnullRefPtr object)