LibPDF: Add a basic parser and Document structure

This commit adds a parser as well as the Reader class, which serves
as a utility to aid in reading the PDF both forwards and in reverse.
The parser currently is capable of reading xref tables, as well as
all values. We don't really do anything with any of this information,
however.
This commit is contained in:
Matthew Olsson 2021-04-30 18:33:13 -07:00 committed by Andreas Kling
commit 72f693e9ed
Notes: sideshowbarker 2024-07-18 18:23:52 +09:00
7 changed files with 1008 additions and 0 deletions

View file

@ -0,0 +1,22 @@
/*
* Copyright (c) 2021, Matthew Olsson <mattco@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibPDF/Document.h>
#include <LibPDF/Parser.h>
namespace PDF {
Document::Document(const ReadonlyBytes& bytes)
: m_parser(Parser({}, bytes))
{
VERIFY(m_parser.perform_validation());
auto [xref_table, trailer] = m_parser.parse_last_xref_table_and_trailer();
m_xref_table = xref_table;
m_trailer = trailer;
}
}