summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfview.cpp13
-rw-r--r--fpdfsdk/fpdfview_c_api_test.c1
-rw-r--r--fpdfsdk/fpdfview_embeddertest.cpp9
3 files changed, 23 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index aad29462cc..cec44a48f9 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -726,6 +726,19 @@ FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page) {
return pPage ? pPage->GetPageHeight() : 0.0;
}
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetPageBoundingBox(FPDF_PAGE page,
+ FS_RECTF* rect) {
+ if (!rect)
+ return false;
+
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
+ return false;
+
+ FSRECTFFromCFXFloatRect(pPage->GetPageBBox(), rect);
+ return true;
+}
+
#if defined(_WIN32)
namespace {
diff --git a/fpdfsdk/fpdfview_c_api_test.c b/fpdfsdk/fpdfview_c_api_test.c
index ad1d8a70ce..53d8776be0 100644
--- a/fpdfsdk/fpdfview_c_api_test.c
+++ b/fpdfsdk/fpdfview_c_api_test.c
@@ -332,6 +332,7 @@ int CheckPDFiumCApi() {
CHK(FPDF_LoadPage);
CHK(FPDF_GetPageWidth);
CHK(FPDF_GetPageHeight);
+ CHK(FPDF_GetPageBoundingBox);
CHK(FPDF_GetPageSizeByIndex);
#ifdef _WIN32
CHK(FPDF_RenderPage);
diff --git a/fpdfsdk/fpdfview_embeddertest.cpp b/fpdfsdk/fpdfview_embeddertest.cpp
index 0055099dd8..7e93574059 100644
--- a/fpdfsdk/fpdfview_embeddertest.cpp
+++ b/fpdfsdk/fpdfview_embeddertest.cpp
@@ -99,8 +99,17 @@ TEST_F(FPDFViewEmbeddertest, Page) {
EXPECT_TRUE(OpenDocument("about_blank.pdf"));
FPDF_PAGE page = LoadPage(0);
EXPECT_NE(nullptr, page);
+
EXPECT_EQ(612.0, FPDF_GetPageWidth(page));
EXPECT_EQ(792.0, FPDF_GetPageHeight(page));
+
+ FS_RECTF rect;
+ EXPECT_TRUE(FPDF_GetPageBoundingBox(page, &rect));
+ EXPECT_EQ(0.0, rect.left);
+ EXPECT_EQ(0.0, rect.bottom);
+ EXPECT_EQ(612.0, rect.right);
+ EXPECT_EQ(792.0, rect.top);
+
UnloadPage(page);
EXPECT_EQ(nullptr, LoadPage(1));
}