diff options
author | Matthew Olsson <matthewcolsson@gmail.com> | 2021-05-26 22:52:05 -0700 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-12 22:45:01 +0430 |
commit | e23bfd72521258921978134bfef88285dcb2f9ec (patch) | |
tree | 80a1f5fbb9047f48ba7d702cc70a49e6f4c9b502 /Userland/Libraries/LibPDF/Parser.h | |
parent | be1be47613d4c9357df9c172eb45c532650035a5 (diff) | |
download | serenity-e23bfd72521258921978134bfef88285dcb2f9ec.zip |
LibPDF: Parse linearized PDF files
This is a big step, as most PDFs which are downloaded online will be
linearized. Pretty much the only difference is that the xref structure
is slightly different.
Diffstat (limited to 'Userland/Libraries/LibPDF/Parser.h')
-rw-r--r-- | Userland/Libraries/LibPDF/Parser.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/Userland/Libraries/LibPDF/Parser.h b/Userland/Libraries/LibPDF/Parser.h index 6227898a1d..abcc4dad05 100644 --- a/Userland/Libraries/LibPDF/Parser.h +++ b/Userland/Libraries/LibPDF/Parser.h @@ -37,10 +37,28 @@ public: RefPtr<DictObject> conditionally_parse_page_tree_node(u32 object_index, bool& ok); private: + struct LinearizationDictionary { + u32 length_of_file { 0 }; + u32 primary_hint_stream_offset { 0 }; + u32 primary_hint_stream_length { 0 }; + u32 overflow_hint_stream_offset { 0 }; + u32 overflow_hint_stream_length { 0 }; + u32 first_page_object_number { 0 }; + u32 offset_of_first_page_end { 0 }; + u16 number_of_pages { 0 }; + u32 offset_of_main_xref_table { 0 }; + u32 first_page { 0 }; // The page to initially open (I think, the spec isn't all that clear here) + }; + + friend struct AK::Formatter<LinearizationDictionary>; + explicit Parser(const ReadonlyBytes&); bool parse_header(); - Optional<XRefTable> parse_xref_table(); + bool initialize_linearization_dict(); + bool initialize_linearized_xref_table(); + bool initialize_non_linearized_xref_table(); + RefPtr<XRefTable> parse_xref_table(); RefPtr<DictObject> parse_file_trailer(); bool navigate_to_before_eof_marker(); @@ -85,8 +103,9 @@ private: Reader m_reader; RefPtr<Document> m_document; - XRefTable m_xref_table; + RefPtr<XRefTable> m_xref_table; RefPtr<DictObject> m_trailer; + Optional<LinearizationDictionary> m_linearization_dictionary; }; -} +}; |