mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-21 18:15:58 +00:00
pdf: Add a --dump-outline flag
This commit is contained in:
parent
361e29cfc9
commit
005bdd210a
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue