diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/fpdf_transformpage.cpp | 18 | ||||
-rw-r--r-- | fpdfsdk/fpdf_transformpage_embeddertest.cpp | 42 | ||||
-rw-r--r-- | fpdfsdk/fpdf_view_c_api_test.c | 2 |
3 files changed, 62 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp index d1f7fceebc..7595086c87 100644 --- a/fpdfsdk/fpdf_transformpage.cpp +++ b/fpdfsdk/fpdf_transformpage.cpp @@ -80,6 +80,15 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetCropBox(FPDF_PAGE page, CFX_FloatRect(left, bottom, right, top)); } +FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetArtBox(FPDF_PAGE page, + float left, + float bottom, + float right, + float top) { + SetBoundingBox(CPDFPageFromFPDFPage(page), pdfium::page_object::kArtBox, + CFX_FloatRect(left, bottom, right, top)); +} + FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetMediaBox(FPDF_PAGE page, float* left, float* bottom, @@ -100,6 +109,15 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetCropBox(FPDF_PAGE page, top); } +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetArtBox(FPDF_PAGE page, + float* left, + float* bottom, + float* right, + float* top) { + return GetBoundingBox(CPDFPageFromFPDFPage(page), + pdfium::page_object::kArtBox, left, bottom, right, top); +} + FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_TransFormWithClip(FPDF_PAGE page, FS_MATRIX* matrix, diff --git a/fpdfsdk/fpdf_transformpage_embeddertest.cpp b/fpdfsdk/fpdf_transformpage_embeddertest.cpp index 0a8e3e72e3..3904b0c321 100644 --- a/fpdfsdk/fpdf_transformpage_embeddertest.cpp +++ b/fpdfsdk/fpdf_transformpage_embeddertest.cpp @@ -37,6 +37,17 @@ TEST_F(FPDFTransformEmbedderTest, GetBoundingBoxes) { EXPECT_EQ(150, cropbox_right); EXPECT_EQ(150, cropbox_top); + float artbox_left; + float artbox_bottom; + float artbox_right; + float artbox_top; + EXPECT_TRUE(FPDFPage_GetArtBox(page, &artbox_left, &artbox_bottom, + &artbox_right, &artbox_top)); + EXPECT_EQ(50, artbox_left); + EXPECT_EQ(60, artbox_bottom); + EXPECT_EQ(135, artbox_right); + EXPECT_EQ(140, artbox_top); + UnloadPage(page); } @@ -76,6 +87,17 @@ TEST_F(FPDFTransformEmbedderTest, GetBoundingBoxes) { &cropbox_right, nullptr)); EXPECT_FALSE(FPDFPage_GetCropBox(page, nullptr, nullptr, nullptr, nullptr)); + float artbox_left; + float artbox_bottom; + float artbox_right; + float artbox_top; + EXPECT_TRUE(FPDFPage_GetArtBox(page, &artbox_left, &artbox_bottom, + &artbox_right, &artbox_top)); + EXPECT_EQ(140, artbox_left); + EXPECT_EQ(145, artbox_bottom); + EXPECT_EQ(65, artbox_right); + EXPECT_EQ(70, artbox_top); + UnloadPage(page); } } @@ -120,3 +142,23 @@ TEST_F(FPDFTransformEmbedderTest, ClipPath) { FPDF_DestroyClipPath(clip); UnloadPage(page); } + +TEST_F(FPDFTransformEmbedderTest, NoArtBox) { + ASSERT_TRUE(OpenDocument("hello_world.pdf")); + ASSERT_EQ(1, FPDF_GetPageCount(document())); + + FPDF_PAGE page = LoadPage(0); + ASSERT_TRUE(page); + + float left = -1.0f; + float bottom = -1.0f; + float right = 3.0f; + float top = 0.0f; + EXPECT_FALSE(FPDFPage_GetArtBox(page, &left, &bottom, &right, &top)); + EXPECT_EQ(-1.0f, left); + EXPECT_EQ(-1.0f, bottom); + EXPECT_EQ(3.0f, right); + EXPECT_EQ(0.0f, top); + + UnloadPage(page); +} diff --git a/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c index 0fc28c31f4..3aa40cacf2 100644 --- a/fpdfsdk/fpdf_view_c_api_test.c +++ b/fpdfsdk/fpdf_view_c_api_test.c @@ -332,9 +332,11 @@ int CheckPDFiumCApi() { // fpdf_transformpage.h CHK(FPDFPageObj_TransformClipPath); + CHK(FPDFPage_GetArtBox); CHK(FPDFPage_GetCropBox); CHK(FPDFPage_GetMediaBox); CHK(FPDFPage_InsertClipPath); + CHK(FPDFPage_SetArtBox); CHK(FPDFPage_SetCropBox); CHK(FPDFPage_SetMediaBox); CHK(FPDFPage_TransFormWithClip); |