1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:37:46 +00:00

LibPDF: Parse page crop box and user units

This commit is contained in:
Matthew Olsson 2021-05-10 10:44:22 -07:00 committed by Andreas Kling
parent 43724ac282
commit d6a9b41bac
2 changed files with 28 additions and 5 deletions

View file

@ -24,8 +24,10 @@ struct Rectangle {
struct Page {
NonnullRefPtr<DictObject> resources;
Rectangle media_box;
NonnullRefPtr<Object> contents;
Rectangle media_box;
Rectangle crop_box;
float user_unit;
};
class Document final : public RefCounted<Document> {
@ -105,8 +107,13 @@ template<>
struct Formatter<PDF::Page> : Formatter<StringView> {
void format(FormatBuilder& builder, const PDF::Page& page)
{
constexpr auto fmt_string = "Page {{\n resources={}\n contents={}\n media_box={}\n}}";
auto str = String::formatted(fmt_string, page.resources->to_string(1), page.contents->to_string(1), page.media_box);
constexpr auto fmt_string = "Page {{\n resources={}\n contents={}\n media_box={}\n crop_box={}\n user_unit={}\n}}";
auto str = String::formatted(fmt_string,
page.resources->to_string(1),
page.contents->to_string(1),
page.media_box,
page.crop_box,
page.user_unit);
Formatter<StringView>::format(builder, str);
}
};