mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
pdf: Add a --dump-outline flag
This commit is contained in:
parent
361e29cfc9
commit
005bdd210a
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