mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 14:14:45 +03:00
pdf: Add a --dump-outline flag
This commit is contained in:
parent
361e29cfc9
commit
005bdd210a
Notes:
sideshowbarker
2024-07-16 21:51:02 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/005bdd210a Pull-request: https://github.com/SerenityOS/serenity/pull/21301
@ -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 New Issue
Block a user