pdf: Add a --dump-outline flag

This commit is contained in:
Nico Weber 2023-10-02 19:00:15 -04:00 committed by Andreas Kling
parent 361e29cfc9
commit 005bdd210a
Notes: sideshowbarker 2024-07-16 21:51:02 +09:00

View File

@ -150,6 +150,9 @@ static PDF::PDFErrorOr<int> pdf_main(Main::Arguments arguments)
bool dump_contents = false;
args_parser.add_option(dump_contents, "Dump page contents", "dump-contents", {});
bool dump_outline = false;
args_parser.add_option(dump_outline, "Dump document outline", "dump-outline", {});
u32 page_number = 1;
args_parser.add_option(page_number, "Page number (1-based)", "page", {}, "PAGE");
@ -194,6 +197,14 @@ static PDF::PDFErrorOr<int> pdf_main(Main::Arguments arguments)
}
int page_index = page_number - 1;
if (dump_outline) {
if (auto outline = document->outline(); outline)
outln("{}", *outline);
else
outln("(no outline)");
return 0;
}
if (dump_contents) {
TRY(document->dump_page(page_index));
return 0;