Make FPDFAnnot_SetAP() generate PDF standard compliant AP stream
FPDFAnnot_SetAP() only sets an appearance stream in annotation’s
dictionary and does not create it as a separate XObject.
Other viewers such as Adobe Reader fail to render such annotation as
these readers expect an XObject to be present with the appearance
stream.
This CL modifies FPDFAnnot_SetAP() implementation to create appearance
stream as a XObject following the steps below:
1. Create an indirect PDF stream object.
2. Store appearance stream data in newly created indirect object.
3. Set dictionary values(BBox, Type, SubType) of indirect object.
4. Store a reference to this indirect object in actual annotation
object's dictionary.
The CL includes a newly added test case to validate creation of
appearance stream as a separate XObject.
Bug: pdfium:1404
Change-Id: I5054cb15ad8bad6ed55f4b952197249a9cc2dfad
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/61430
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/BUILD.gn b/fpdfsdk/BUILD.gn
index afdbcf0..73117e1 100644
--- a/fpdfsdk/BUILD.gn
+++ b/fpdfsdk/BUILD.gn
@@ -106,6 +106,7 @@
pdfium_unittest_source_set("unittests") {
sources = [
+ "fpdf_annot_unittest.cpp",
"fpdf_catalog_unittest.cpp",
"fpdf_doc_unittest.cpp",
"fpdf_edit_unittest.cpp",
@@ -114,6 +115,7 @@
deps = [
":fpdfsdk",
"../:pdfium_public_headers",
+ "../constants",
"../core/fpdfapi/page",
"../core/fpdfapi/parser",
"../core/fpdfapi/render",