mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-07 10:06:03 +00: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: 005bdd210a
Pull-request: https://github.com/SerenityOS/serenity/pull/21301
1 changed files with 11 additions and 0 deletions
|
@ -150,6 +150,9 @@ static PDF::PDFErrorOr<int> pdf_main(Main::Arguments arguments)
|
||||||
bool dump_contents = false;
|
bool dump_contents = false;
|
||||||
args_parser.add_option(dump_contents, "Dump page contents", "dump-contents", {});
|
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;
|
u32 page_number = 1;
|
||||||
args_parser.add_option(page_number, "Page number (1-based)", "page", {}, "PAGE");
|
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;
|
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) {
|
if (dump_contents) {
|
||||||
TRY(document->dump_page(page_index));
|
TRY(document->dump_page(page_index));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue