summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-02 18:01:26 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-02 18:01:26 +0000
commit3d3cf800a8aae4cd7ff237714e31f9a217667ad8 (patch)
tree2b982ec2f89eaf4f4d18324d7bd2126f98ea61a1 /fpdfsdk
parente8b02fb54234ed66eeab30927b4495ecc9ca1669 (diff)
downloadpdfium-3d3cf800a8aae4cd7ff237714e31f9a217667ad8.tar.xz
Normalize widget bounding boxes when flattening.
BUG=chromium:890322 Change-Id: I11050b84cf440f8d6bb00c661360de4e389dc031 Reviewed-on: https://pdfium-review.googlesource.com/c/43290 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_flatten.cpp1
-rw-r--r--fpdfsdk/fpdf_flatten_embeddertest.cpp17
2 files changed, 18 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp
index 01f3cd7e1e..a27d79f09e 100644
--- a/fpdfsdk/fpdf_flatten.cpp
+++ b/fpdfsdk/fpdf_flatten.cpp
@@ -364,6 +364,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
rcStream = pAPDic->GetRectFor("Rect");
else if (pAPDic->KeyExist("BBox"))
rcStream = pAPDic->GetRectFor("BBox");
+ rcStream.Normalize();
if (rcStream.IsEmpty())
continue;
diff --git a/fpdfsdk/fpdf_flatten_embeddertest.cpp b/fpdfsdk/fpdf_flatten_embeddertest.cpp
index a8915fe60c..c861d75711 100644
--- a/fpdfsdk/fpdf_flatten_embeddertest.cpp
+++ b/fpdfsdk/fpdf_flatten_embeddertest.cpp
@@ -37,3 +37,20 @@ TEST_F(FPDFFlattenEmbeddertest, FlatPrint) {
EXPECT_EQ(FLATTEN_SUCCESS, FPDFPage_Flatten(page, FLAT_PRINT));
UnloadPage(page);
}
+
+TEST_F(FPDFFlattenEmbeddertest, BUG_890322) {
+ static const char md5_hash[] = "6c674642154408e877d88c6c082d67e9";
+ EXPECT_TRUE(OpenDocument("bug_890322.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ ASSERT_TRUE(page);
+
+ ScopedFPDFBitmap bitmap = RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 200, 200, md5_hash);
+
+ EXPECT_EQ(FLATTEN_SUCCESS, FPDFPage_Flatten(page, FLAT_PRINT));
+ EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0));
+
+ UnloadPage(page);
+
+ VerifySavedDocument(200, 200, md5_hash);
+}