summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorRalf Sippl <ralf.sippl@gmail.com>2018-03-19 23:30:28 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-03-19 23:30:28 +0000
commitb3a5240832fce3f0b706c16070a1e69c2c1edb86 (patch)
tree36d6f6ab3853a5c241b3b437a1dc181be5329f27 /fpdfsdk
parent3448143cc2aa517958b6551b9419e1e6141fb5cd (diff)
downloadpdfium-b3a5240832fce3f0b706c16070a1e69c2c1edb86.tar.xz
Calculate AP for multi-line markup annotations correctly
Currently, when constructing AP for multi-line markup annotations, we only take into account the first set of quadpoints, resulting in only the first line of the annotation being displayed if the annotation spans multiple lines. This CL, initially written by Jane Liu <janeliulwq@google.com> (https://pdfium-review.googlesource.com/12010) takes into account all the quadpoints, so multi-line annotations can be displayed correctly. BUG=pdfium:876 Change-Id: I8be10ee38e01eb6525ddef556df1b727189455c7 Reviewed-on: https://pdfium-review.googlesource.com/28590 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfannot.cpp2
-rw-r--r--fpdfsdk/fpdfannot_embeddertest.cpp14
2 files changed, 15 insertions, 1 deletions
diff --git a/fpdfsdk/fpdfannot.cpp b/fpdfsdk/fpdfannot.cpp
index 29a6751bff..84c6c03194 100644
--- a/fpdfsdk/fpdfannot.cpp
+++ b/fpdfsdk/fpdfannot.cpp
@@ -614,7 +614,7 @@ FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot,
CPDF_Stream* pStream =
FPDFDOC_GetAnnotAP(pAnnotDict, CPDF_Annot::AppearanceMode::Normal);
if (pStream) {
- CFX_FloatRect newRect = CPDF_Annot::RectFromQuadPoints(pAnnotDict);
+ CFX_FloatRect newRect = CPDF_Annot::BoundingRectFromQuadPoints(pAnnotDict);
if (newRect.Contains(pStream->GetDict()->GetRectFor("BBox")))
pStream->GetDict()->SetRectFor("BBox", newRect);
}
diff --git a/fpdfsdk/fpdfannot_embeddertest.cpp b/fpdfsdk/fpdfannot_embeddertest.cpp
index 61cd2aae3d..b96460a395 100644
--- a/fpdfsdk/fpdfannot_embeddertest.cpp
+++ b/fpdfsdk/fpdfannot_embeddertest.cpp
@@ -45,6 +45,20 @@ TEST_F(FPDFAnnotEmbeddertest, RenderAnnotWithOnlyRolloverAP) {
UnloadPage(page);
}
+TEST_F(FPDFAnnotEmbeddertest, RenderMultilineMarkupAnnotWithoutAP) {
+ const char md5_hash[] = "76512832d88017668d9acc7aacd13dae";
+ // Open a file with two multiline markup annotations.
+ ASSERT_TRUE(OpenDocument("annotation_markup_multiline_no_ap.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ ASSERT_TRUE(page);
+
+ std::unique_ptr<void, FPDFBitmapDeleter> bitmap =
+ RenderLoadedPageWithFlags(page, FPDF_ANNOT);
+ CompareBitmap(bitmap.get(), 595, 842, md5_hash);
+
+ UnloadPage(page);
+}
+
TEST_F(FPDFAnnotEmbeddertest, ExtractHighlightLongContent) {
// Open a file with one annotation and load its first page.
ASSERT_TRUE(OpenDocument("annotation_highlight_long_content.pdf"));