From e17011dc1f5d046dc60c3347b89c0aad7d674dff Mon Sep 17 00:00:00 2001 From: Jane Liu Date: Wed, 21 Jun 2017 12:18:37 -0400 Subject: Minor change to AP generation logic Current behavior: Our CPVT_GenerateAP::Generate*AP() functions do not get called as long as the annotation dictionary has an "AP" entry. Problem: We always need the "N" entry in AP dictionary to display an annotation. Even though the spec requires "AP" dictionary to have an "N" entry for normal mode appearance, in case of a malformed pdf with "AP" but without "N" in "AP", we won't be able to display the annotation at all. Fix: Always check if "AP" has "N" entry to decide whether AP needs to be generated. If not, then we still need to generate AP, and add to the AP dictionary under the key "N". Bug=pdfium:778 Change-Id: Icf0c6a681b3c8c22b0b67bf8d16ce6fefdc2c45b Reviewed-on: https://pdfium-review.googlesource.com/6692 Reviewed-by: Lei Zhang Commit-Queue: Jane Liu --- fpdfsdk/fpdfannot_embeddertest.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'fpdfsdk') diff --git a/fpdfsdk/fpdfannot_embeddertest.cpp b/fpdfsdk/fpdfannot_embeddertest.cpp index 85f9b68240..b7dee88b78 100644 --- a/fpdfsdk/fpdfannot_embeddertest.cpp +++ b/fpdfsdk/fpdfannot_embeddertest.cpp @@ -13,6 +13,23 @@ class FPDFAnnotEmbeddertest : public EmbedderTest, public TestSaver {}; +TEST_F(FPDFAnnotEmbeddertest, RenderAnnotWithOnlyRolloverAP) { + // Open a file with one annotation and load its first page. + ASSERT_TRUE(OpenDocument("annotation_highlight_rollover_ap.pdf")); + FPDF_PAGE page = FPDF_LoadPage(document(), 0); + ASSERT_TRUE(page); + + // This annotation has a malformed appearance stream, which does not have its + // normal appearance defined, only its rollover appearance. In this case, its + // normal appearance should be generated, allowing the highlight annotation to + // still display. + FPDF_BITMAP bitmap = RenderPageWithFlags(page, FPDF_ANNOT); + CompareBitmap(bitmap, 612, 792, "dc98f06da047bd8aabfa99562d2cbd1e"); + FPDFBitmap_Destroy(bitmap); + + 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")); -- cgit v1.2.3