10#include "core/fpdfapi/parser/cpdf_dictionary.h"
11#include "core/fpdfapi/parser/cpdf_document.h"
12#include "core/fpdfapi/parser/cpdf_reference.h"
13#include "core/fxcrt/bytestring.h"
14#include "core/fxcrt/fx_safe_types.h"
15#include "core/fxge/cfx_defaultrenderdevice.h"
16#include "fpdfsdk/cpdfsdk_helpers.h"
17#include "public/cpp/fpdf_scopers.h"
18#include "public/fpdf_doc.h"
19#include "public/fpdf_edit.h"
20#include "public/fpdfview.h"
21#include "testing/embedder_test.h"
22#include "testing/fx_string_testhelpers.h"
23#include "testing/gtest/include/gtest/gtest.h"
28int CountPageEntries(
const std::string& data) {
29 static constexpr char kNeedle[] =
"/Type/Page";
30 static constexpr size_t kNeedleLen =
std::size(kNeedle) - 1;
34 while (pos < data.size()) {
35 const size_t found_pos = data.find(kNeedle, pos);
36 if (found_pos == std::string::npos) {
40 FX_SAFE_SIZE_T next_pos = found_pos;
41 next_pos += kNeedleLen;
42 pos = next_pos.ValueOrDefault(std::string::npos);
43 if (pos < data.size() && data[pos] ==
's') {
54int CountStreamEntries(
const std::string& data) {
55 static constexpr char kNeedle[] =
">stream\r\n";
56 static constexpr size_t kNeedleLen =
std::size(kNeedle) - 1;
60 while (pos < data.size()) {
61 const size_t found_pos = data.find(kNeedle, pos);
62 if (found_pos == std::string::npos) {
66 FX_SAFE_SIZE_T next_pos = found_pos;
67 next_pos += kNeedleLen;
68 pos = next_pos.ValueOrDefault(std::string::npos);
79 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
80 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document());
82 std::set<FPDF_PAGE> unique_pages;
83 std::vector<ScopedFPDFPage> owned_pages(4);
84 for (
auto& ref : owned_pages) {
85 ref.reset(FPDF_LoadPage(document(), 0));
86 unique_pages.insert(ref.get());
89 EXPECT_EQ(1u, unique_pages.size());
90 EXPECT_EQ(1u, pDoc->GetParsedPageCountForTesting());
92 EXPECT_EQ(4u, unique_pages.size());
98 ASSERT_TRUE(OpenDocument(
"named_dests.pdf"));
102 EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(),
nullptr));
105 FPDF_DEST dest = FPDF_GetNamedDestByName(document(),
"First");
107 EXPECT_EQ(1, FPDFDest_GetDestPageIndex(document(), dest));
110 dest = FPDF_GetNamedDestByName(document(),
"Next");
112 EXPECT_EQ(1, FPDFDest_GetDestPageIndex(document(), dest));
115 dest = FPDF_GetNamedDestByName(document(),
"FirstAlternate");
117 EXPECT_EQ(11, FPDFDest_GetDestPageIndex(document(), dest));
120 dest = FPDF_GetNamedDestByName(document(),
"LastAlternate");
122 EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), dest));
126 ASSERT_TRUE(OpenDocument(
"named_dests.pdf"));
128 unsigned long numParams;
132 std::fill_n(params, 4, 42.4242f);
135 EXPECT_EQ(0U, numParams);
136 EXPECT_FLOAT_EQ(42.4242f, params[0]);
139 std::fill_n(params, 4, 42.4242f);
140 FPDF_DEST dest = FPDF_GetNamedDestByName(document(),
"First");
144 EXPECT_EQ(3U, numParams);
145 EXPECT_FLOAT_EQ(0, params[0]);
146 EXPECT_FLOAT_EQ(0, params[1]);
147 EXPECT_FLOAT_EQ(1, params[2]);
148 EXPECT_FLOAT_EQ(42.4242f, params[3]);
151 std::fill_n(params, 4, 42.4242f);
152 dest = FPDF_GetNamedDestByName(document(),
"Next");
156 EXPECT_EQ(0U, numParams);
157 EXPECT_FLOAT_EQ(42.4242f, params[0]);
160 std::fill_n(params, 4, 42.4242f);
161 dest = FPDF_GetNamedDestByName(document(),
"FirstAlternate");
165 EXPECT_EQ(3U, numParams);
166 EXPECT_FLOAT_EQ(200, params[0]);
167 EXPECT_FLOAT_EQ(400, params[1]);
168 EXPECT_FLOAT_EQ(800, params[2]);
169 EXPECT_FLOAT_EQ(42.4242f, params[3]);
172 std::fill_n(params, 4, 42.4242f);
173 dest = FPDF_GetNamedDestByName(document(),
"LastAlternate");
177 EXPECT_EQ(3U, numParams);
178 EXPECT_FLOAT_EQ(0, params[0]);
179 EXPECT_FLOAT_EQ(0, params[1]);
180 EXPECT_FLOAT_EQ(-200, params[2]);
181 EXPECT_FLOAT_EQ(42.4242f, params[3]);
185 ASSERT_TRUE(OpenDocument(
"named_dests.pdf"));
187 FPDF_DEST dest = FPDF_GetNamedDestByName(document(),
"First");
192 FPDF_BOOL hasZoom = 0;
195 FS_FLOAT zoom = -1.0f;
206 EXPECT_TRUE(hasZoom);
213 ASSERT_TRUE(OpenDocument(
"bug_1506.pdf"));
215 FPDF_DEST dest = FPDF_GetNamedDestByName(document(),
"First");
217 EXPECT_EQ(3, FPDFDest_GetDestPageIndex(document(), dest));
221 ASSERT_TRUE(OpenDocument(
"bug_1506.pdf"));
223 std::vector<FPDF_PAGE> pages;
225 pages.push_back(LoadPage(i));
227 FPDF_DEST dest = FPDF_GetNamedDestByName(document(),
"First");
229 EXPECT_EQ(3, FPDFDest_GetDestPageIndex(document(), dest));
231 for (FPDF_PAGE page : pages)
236 ASSERT_TRUE(OpenDocument(
"bug_1506.pdf"));
238 std::vector<FPDF_PAGE> pages;
239 for (
int i : {0, 1, 3})
240 pages.push_back(LoadPage(i));
242 FPDF_DEST dest = FPDF_GetNamedDestByName(document(),
"First");
244 EXPECT_EQ(3, FPDFDest_GetDestPageIndex(document(), dest));
246 for (FPDF_PAGE page : pages)
251 ASSERT_TRUE(OpenDocument(
"bug_680376.pdf"));
254 FPDF_DEST dest = FPDF_GetNamedDestByName(document(),
"First");
256 EXPECT_EQ(-1, FPDFDest_GetDestPageIndex(document(), dest));
260 ASSERT_TRUE(OpenDocument(
"bug_821454.pdf"));
262 FPDF_PAGE page = LoadPage(0);
277 FPDF_DEST dest1 = FPDFLink_GetDest(document(), link1);
279 FPDF_DEST dest2 = FPDFLink_GetDest(document(), link2);
285 EXPECT_FALSE(FPDFLink_GetDest(document(),
nullptr));
287 EXPECT_EQ(0, FPDFDest_GetDestPageIndex(document(), dest1));
288 EXPECT_EQ(0, FPDFDest_GetDestPageIndex(document(), dest2));
291 FPDF_BOOL has_x_coord;
292 FPDF_BOOL has_y_coord;
298 dest1
, &has_x_coord
, &has_y_coord
, &has_zoom
, &x
, &y
, &zoom
);
299 ASSERT_TRUE(success);
300 EXPECT_TRUE(has_x_coord);
301 EXPECT_TRUE(has_y_coord);
302 EXPECT_FALSE(has_zoom);
303 EXPECT_FLOAT_EQ(100.0f, x);
304 EXPECT_FLOAT_EQ(200.0f, y);
307 FPDF_BOOL has_x_coord;
308 FPDF_BOOL has_y_coord;
314 dest2
, &has_x_coord
, &has_y_coord
, &has_zoom
, &x
, &y
, &zoom
);
315 ASSERT_TRUE(success);
316 EXPECT_TRUE(has_x_coord);
317 EXPECT_TRUE(has_y_coord);
318 EXPECT_FALSE(has_zoom);
319 EXPECT_FLOAT_EQ(150.0f, x);
320 EXPECT_FLOAT_EQ(250.0f, y);
327 ASSERT_TRUE(OpenDocument(
"launch_action.pdf"));
332 EXPECT_FALSE(FPDFAction_GetDest(document(),
nullptr));
335 EXPECT_EQ(0u, FPDFAction_GetURIPath(document(),
nullptr,
nullptr, 0));
339 ASSERT_TRUE(OpenDocument(
"launch_action.pdf"));
341 FPDF_PAGE page = LoadPage(0);
353 const char kExpectedResult[] =
"test.pdf";
354 const unsigned long kExpectedLength =
sizeof(kExpectedResult);
356 EXPECT_EQ(kExpectedLength, bufsize);
360 EXPECT_STREQ(kExpectedResult, buf);
363 EXPECT_FALSE(FPDFAction_GetDest(document(), action));
364 EXPECT_EQ(0u, FPDFAction_GetURIPath(document(), action, buf,
sizeof(buf)));
370 ASSERT_TRUE(OpenDocument(
"uri_action.pdf"));
372 FPDF_PAGE page = LoadPage(0);
384 const char kExpectedResult[] =
"https://example.com/page.html";
385 const unsigned long kExpectedLength =
sizeof(kExpectedResult);
386 unsigned long bufsize = FPDFAction_GetURIPath(document(), action,
nullptr, 0);
387 ASSERT_EQ(kExpectedLength, bufsize);
390 EXPECT_EQ(bufsize, FPDFAction_GetURIPath(document(), action, buf, bufsize));
391 EXPECT_STREQ(kExpectedResult, buf);
394 EXPECT_FALSE(FPDFAction_GetDest(document(), action));
401 ASSERT_TRUE(OpenDocument(
"uri_action_nonascii.pdf"));
403 FPDF_PAGE page = LoadPage(0);
417 const char kExpectedResult[] =
418 "https://example.com/\xA5octal\xC7"
420 const unsigned long kExpectedLength =
sizeof(kExpectedResult);
421 unsigned long bufsize = FPDFAction_GetURIPath(document(), action,
nullptr, 0);
422 ASSERT_EQ(kExpectedLength, bufsize);
425 EXPECT_EQ(bufsize, FPDFAction_GetURIPath(document(), action, buf, bufsize));
426 EXPECT_STREQ(kExpectedResult, buf);
432 ASSERT_TRUE(OpenDocument(
"annots.pdf"));
433 FPDF_PAGE page = LoadPage(0);
438 EXPECT_EQ(0, FPDFPage_GetAnnotIndex(page, first_annot.get()));
442 EXPECT_EQ(1, FPDFPage_GetAnnotIndex(page, second_annot.get()));
454 ASSERT_TRUE(OpenDocument(
"goto_action.pdf"));
456 FPDF_PAGE page = LoadPage(0);
468 EXPECT_TRUE(FPDFAction_GetDest(document(), action));
473 EXPECT_EQ(0u, FPDFAction_GetURIPath(document(), action, buf,
sizeof(buf)));
479 ASSERT_TRUE(OpenDocument(
"gotoe_action.pdf"));
481 FPDF_PAGE page = LoadPage(0);
493 FPDF_DEST dest = FPDFAction_GetDest(document(), action);
496 unsigned long num_params = 42;
498 std::fill_n(params, 4, 42.4242f);
501 EXPECT_EQ(0u, num_params);
502 EXPECT_FLOAT_EQ(42.4242f, params[0]);
504 const char kExpectedResult[] =
"ExampleFile.pdf";
505 const unsigned long kExpectedLength =
sizeof(kExpectedResult);
508 EXPECT_EQ(kExpectedLength, bufsize);
510 EXPECT_STREQ(kExpectedResult, buf);
516 ASSERT_TRUE(OpenDocument(
"nonesuch_action.pdf"));
518 FPDF_PAGE page = LoadPage(0);
532 EXPECT_FALSE(FPDFAction_GetDest(document(), action));
534 EXPECT_EQ(0u, FPDFAction_GetURIPath(document(), action, buf,
sizeof(buf)));
540 unsigned short buf[128];
543 ASSERT_TRUE(OpenDocument(
"named_dests.pdf"));
548 EXPECT_FALSE(FPDFBookmark_GetFirstChild(document(),
nullptr));
550 EXPECT_FALSE(FPDFBookmark_GetNextSibling(document(),
nullptr));
552 EXPECT_FALSE(FPDFBookmark_Find(document(),
nullptr));
554 EXPECT_FALSE(FPDFBookmark_GetDest(document(),
nullptr));
559 unsigned short buf[128];
562 ASSERT_TRUE(OpenDocument(
"bookmarks.pdf"));
564 FPDF_BOOKMARK child = FPDFBookmark_GetFirstChild(document(),
nullptr);
571 EXPECT_FALSE(FPDFBookmark_GetDest(document(), child));
574 FPDF_BOOKMARK grand_child = FPDFBookmark_GetFirstChild(document(), child);
575 EXPECT_FALSE(grand_child);
577 FPDF_BOOKMARK sibling = FPDFBookmark_GetNextSibling(document(), child);
578 EXPECT_TRUE(sibling);
584 FPDF_BOOKMARK sibling2 = FPDFBookmark_GetNextSibling(document(), sibling);
585 EXPECT_TRUE(sibling2);
590 EXPECT_FALSE(FPDFBookmark_GetNextSibling(document(), sibling2));
592 grand_child = FPDFBookmark_GetFirstChild(document(), sibling);
593 EXPECT_TRUE(grand_child);
597 EXPECT_TRUE(FPDFBookmark_GetDest(document(), grand_child));
599 EXPECT_FALSE(FPDFBookmark_GetNextSibling(document(), grand_child));
603 unsigned short buf[128];
606 ASSERT_TRUE(OpenDocument(
"bookmarks.pdf"));
610 FPDF_BOOKMARK child = FPDFBookmark_Find(document(), title.get());
618 EXPECT_EQ(child, FPDFBookmark_GetFirstChild(document(),
nullptr));
622 EXPECT_FALSE(FPDFBookmark_Find(document(), bad_title.get()));
628 ASSERT_TRUE(OpenDocument(
"bookmarks_circular.pdf"));
632 EXPECT_FALSE(FPDFBookmark_Find(document(), title.get()));
636 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
637 EXPECT_EQ(1, FPDF_GetPageCount(document()));
640 EXPECT_EQ(1, FPDF_GetPageCount(document()));
642 FPDFPage_Delete(document(), -1);
643 EXPECT_EQ(1, FPDF_GetPageCount(document()));
644 FPDFPage_Delete(document(), 1);
645 EXPECT_EQ(1, FPDF_GetPageCount(document()));
647 FPDFPage_Delete(document(), 0);
648 EXPECT_EQ(0, FPDF_GetPageCount(document()));
655 const char* checksum;
657 const std::array<
const PageData, 5> expected_page_data = {{
660 return CFX_DefaultRenderDevice::UseSkiaRenderer()
661 ?
"4b6590a267eae90b8be1607e808fb57f"
662 :
"1e5d1cf19ffbb9cf9dbf099483cea327";
666 return CFX_DefaultRenderDevice::UseSkiaRenderer()
667 ?
"e8edd3655f6629ff489bd8c3bb110c82"
668 :
"65c80685916aa36e767dd2270ba4d72b";
672 return CFX_DefaultRenderDevice::UseSkiaRenderer()
673 ?
"a2bde6b68d7981e665ab25bc633746aa"
674 :
"a53b21c68edf43c1cddb5c06e361bb45";
678 return CFX_DefaultRenderDevice::UseSkiaRenderer()
679 ?
"a8c5b3e626f665eddf593c6d4c32ae9e"
680 :
"dcd768be15efb9c6e5093cf74508752c";
684 return CFX_DefaultRenderDevice::UseSkiaRenderer()
685 ?
"72eb157853ae2d19b70ea62e3f5ac202"
686 :
"7a3f8f79ebcb350854c0d69607729ec5";
691 ASSERT_TRUE(OpenDocument(
"rectangles_multi_pages.pdf"));
692 EXPECT_EQ(5, FPDF_GetPageCount(document()));
693 for (
int i = 0; i < 5; ++i) {
694 FPDF_PAGE page = LoadPage(i);
696 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
697 const PageData& expected = expected_page_data[i];
698 CompareBitmap(bitmap.get(), expected.width, expected.height,
704 FPDFPage_Delete(document(), 0);
705 EXPECT_EQ(4, FPDF_GetPageCount(document()));
706 for (
int i = 0; i < 4; ++i) {
707 FPDF_PAGE page = LoadPage(i);
709 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
710 const PageData& expected = expected_page_data[i + 1];
711 CompareBitmap(bitmap.get(), expected.width, expected.height,
717 FPDFPage_Delete(document(), 3);
718 EXPECT_EQ(3, FPDF_GetPageCount(document()));
719 for (
int i = 0; i < 3; ++i) {
720 FPDF_PAGE page = LoadPage(i);
722 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
723 const PageData& expected = expected_page_data[i + 1];
724 CompareBitmap(bitmap.get(), expected.width, expected.height,
730 FPDFPage_Delete(document(), 1);
731 EXPECT_EQ(2, FPDF_GetPageCount(document()));
732 for (
int i = 0; i < 2; ++i) {
733 FPDF_PAGE page = LoadPage(i);
735 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
736 int adjusted_index = i == 0 ? 1 : 3;
737 const PageData& expected = expected_page_data[adjusted_index];
738 CompareBitmap(bitmap.get(), expected.width, expected.height,
746 ASSERT_TRUE(OpenDocument(
"bookmarks.pdf"));
748 EXPECT_EQ(2, FPDF_GetPageCount(document()));
749 FPDFPage_Delete(document(), 0);
750 EXPECT_EQ(1, FPDF_GetPageCount(document()));
752 ASSERT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
753 EXPECT_EQ(1, CountPageEntries(GetString()));
754 EXPECT_EQ(1, CountStreamEntries(GetString()));
759 ASSERT_TRUE(OpenDocument(
"hello_world_2_pages_custom_object.pdf"));
761 EXPECT_EQ(2, FPDF_GetPageCount(document()));
762 FPDFPage_Delete(document(), 0);
763 EXPECT_EQ(1, FPDF_GetPageCount(document()));
765 ASSERT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
766 EXPECT_EQ(1, CountPageEntries(GetString()));
767 EXPECT_EQ(1, CountStreamEntries(GetString()));
771 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
773 EXPECT_EQ(1, FPDF_GetPageCount(document()));
776 ScopedFPDFPage new_page(FPDFPage_New(document(), 1, 300, 200));
777 ASSERT_TRUE(new_page);
778 EXPECT_EQ(2, FPDF_GetPageCount(document()));
781 CPDF_Document* doc = CPDFDocumentFromFPDFDocument(document());
784 CPDF_Page* page = CPDFPageFromFPDFPage(new_page.get());
788 ASSERT_TRUE(root_dict);
789 root_dict->SetNewFor<CPDF_Reference>(
"CustomField", doc,
790 page->GetDict()->GetObjNum());
793 FPDFPage_Delete(document(), 1);
794 EXPECT_EQ(1, FPDF_GetPageCount(document()));
796 ASSERT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
797 EXPECT_EQ(1, CountPageEntries(GetString()));
798 EXPECT_EQ(1, CountStreamEntries(GetString()));
803 ASSERT_TRUE(OpenDocument(
"bug_1229106.pdf"));
805 EXPECT_EQ(4, FPDF_GetPageCount(document()));
806 FPDFPage_Delete(document(), 0);
807 EXPECT_EQ(3, FPDF_GetPageCount(document()));
809 ASSERT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
810 EXPECT_EQ(2, CountPageEntries(GetString()));
811 EXPECT_EQ(2, CountStreamEntries(GetString()));
814 FPDFPage_Delete(document(), 0);
815 EXPECT_EQ(2, FPDF_GetPageCount(document()));
817 ASSERT_TRUE(FPDF_SaveAsCopy(document(),
this, 0));
818 EXPECT_EQ(1, CountPageEntries(GetString()));
819 EXPECT_EQ(1, CountStreamEntries(GetString()));
823 ASSERT_TRUE(OpenDocument(
"split_streams.pdf"));
824 constexpr size_t kMd5Length = 17;
825 char buf[kMd5Length];
827 FPDF_GetFileIdentifier(document(),
static_cast<FPDF_FILEIDTYPE>(-1),
830 FPDF_GetFileIdentifier(document(),
static_cast<FPDF_FILEIDTYPE>(2),
832 EXPECT_EQ(0u, FPDF_GetFileIdentifier(
nullptr, FILEIDTYPE_PERMANENT, buf,
834 EXPECT_EQ(kMd5Length, FPDF_GetFileIdentifier(document(), FILEIDTYPE_PERMANENT,
837 constexpr char kExpectedPermanent[] =
838 "\xF3\x41\xAE\x65\x4A\x77\xAC\xD5\x06\x5A\x76\x45\xE5\x96\xE6\xE6";
839 ASSERT_EQ(kMd5Length, FPDF_GetFileIdentifier(document(), FILEIDTYPE_PERMANENT,
841 EXPECT_EQ(kExpectedPermanent,
ByteString(buf));
843 constexpr char kExpectedChanging[] =
844 "\xBC\x37\x29\x8A\x3F\x87\xF4\x79\x22\x9B\xCE\x99\x7C\xA7\x91\xF7";
845 ASSERT_EQ(kMd5Length, FPDF_GetFileIdentifier(document(), FILEIDTYPE_CHANGING,
847 EXPECT_EQ(kExpectedChanging,
ByteString(buf));
851 ASSERT_TRUE(OpenDocument(
"non_hex_file_id.pdf"));
854 constexpr char kPermanentNonHex[] =
"permanent non-hex";
855 ASSERT_EQ(18u, FPDF_GetFileIdentifier(document(), FILEIDTYPE_PERMANENT, buf,
859 constexpr char kChangingNonHex[] =
"changing non-hex";
860 ASSERT_EQ(17u, FPDF_GetFileIdentifier(document(), FILEIDTYPE_CHANGING, buf,
866 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
868 0u, FPDF_GetFileIdentifier(document(), FILEIDTYPE_PERMANENT,
nullptr, 0));
870 0u, FPDF_GetFileIdentifier(document(), FILEIDTYPE_CHANGING,
nullptr, 0));
874 ASSERT_TRUE(OpenDocument(
"bug_601362.pdf"));
877 unsigned short buf[128];
878 EXPECT_EQ(0u, FPDF_GetMetaText(document(),
nullptr, buf,
sizeof(buf)));
882 EXPECT_EQ(2u, FPDF_GetMetaText(document(),
"", buf,
sizeof(buf)));
883 EXPECT_EQ(2u, FPDF_GetMetaText(document(),
"foo", buf,
sizeof(buf)));
884 ASSERT_EQ(2u, FPDF_GetMetaText(document(),
"Title", buf,
sizeof(buf)));
885 ASSERT_EQ(2u, FPDF_GetMetaText(document(),
"Author", buf,
sizeof(buf)));
886 ASSERT_EQ(2u, FPDF_GetMetaText(document(),
"Subject", buf,
sizeof(buf)));
887 ASSERT_EQ(2u, FPDF_GetMetaText(document(),
"Keywords", buf,
sizeof(buf)));
888 ASSERT_EQ(2u, FPDF_GetMetaText(document(),
"Producer", buf,
sizeof(buf)));
890 ASSERT_EQ(30u, FPDF_GetMetaText(document(),
"Creator", buf,
sizeof(buf)));
894 FPDF_GetMetaText(document(),
"CreationDate", buf,
sizeof(buf)));
897 ASSERT_EQ(48u, FPDF_GetMetaText(document(),
"ModDate", buf,
sizeof(buf)));
902 ASSERT_TRUE(OpenDocument(
"utf-8.pdf"));
904 unsigned short buf[128];
906 ASSERT_EQ(34u, FPDF_GetMetaText(document(),
"Producer", buf,
sizeof(buf)));
909 FPDF_BOOKMARK child = FPDFBookmark_GetFirstChild(document(),
nullptr);
916 ASSERT_TRUE(OpenDocument(
"bug_182.pdf"));
918 unsigned short buf[128];
920 ASSERT_EQ(48u, FPDF_GetMetaText(document(),
"Title", buf,
sizeof(buf)));
925 ASSERT_TRUE(OpenDocument(
"annotation_highlight_square_with_ap.pdf"));
930 unsigned short buf[128];
931 ASSERT_EQ(48u, FPDF_GetMetaText(document(),
"ModDate", buf,
sizeof(buf)));
936 ASSERT_TRUE(OpenDocument(
"embedded_attachments.pdf"));
939 unsigned short buf[128];
940 ASSERT_EQ(48u, FPDF_GetMetaText(document(),
"ModDate", buf,
sizeof(buf)));
946 unsigned short buf[128];
947 EXPECT_EQ(2u, FPDF_GetMetaText(empty_doc.get(),
"Title", buf,
sizeof(buf)));
951 ASSERT_TRUE(OpenDocument(
"get_page_aaction.pdf"));
952 FPDF_PAGE page = LoadPage(0);
964 const char kExpectedResult[] =
"\\\\127.0.0.1\\c$\\Program Files\\test.exe";
965 const unsigned long kExpectedLength =
sizeof(kExpectedResult);
969 EXPECT_EQ(kExpectedLength, bufsize);
971 EXPECT_STREQ(kExpectedResult, buf);
983 ASSERT_TRUE(OpenDocument(
"about_blank.pdf"));
984 EXPECT_EQ(1, FPDF_GetPageCount(document()));
986 ASSERT_EQ(0u, FPDF_GetPageLabel(document(), 0,
nullptr, 0));
990 ASSERT_TRUE(OpenDocument(
"page_labels.pdf"));
991 EXPECT_EQ(7, FPDF_GetPageCount(document()));
995 SetWholeFileAvailable();
997 unsigned short buf[128];
998 EXPECT_EQ(0u, FPDF_GetPageLabel(document(), -2, buf,
sizeof(buf)));
999 EXPECT_EQ(0u, FPDF_GetPageLabel(document(), -1, buf,
sizeof(buf)));
1001 ASSERT_EQ(4u, FPDF_GetPageLabel(document(), 0, buf,
sizeof(buf)));
1004 ASSERT_EQ(6u, FPDF_GetPageLabel(document(), 1, buf,
sizeof(buf)));
1007 ASSERT_EQ(4u, FPDF_GetPageLabel(document(), 2, buf,
sizeof(buf)));
1010 ASSERT_EQ(4u, FPDF_GetPageLabel(document(), 3, buf,
sizeof(buf)));
1013 ASSERT_EQ(8u, FPDF_GetPageLabel(document(), 4, buf,
sizeof(buf)));
1016 ASSERT_EQ(8u, FPDF_GetPageLabel(document(), 5, buf,
sizeof(buf)));
1019 ASSERT_EQ(2u, FPDF_GetPageLabel(document(), 6, buf,
sizeof(buf)));
1022 ASSERT_EQ(0u, FPDF_GetPageLabel(document(), 7, buf,
sizeof(buf)));
1023 ASSERT_EQ(0u, FPDF_GetPageLabel(document(), 8, buf,
sizeof(buf)));
1026#ifdef PDF_ENABLE_XFA
1027TEST_F(FPDFDocEmbedderTest, GetXFALinks) {
1028 ASSERT_TRUE(OpenDocument(
"simple_xfa.pdf"));
1030 ScopedFPDFPage page(FPDF_LoadPage(document(), 0));
1033 FPDFLink_GetLinkAtPoint(page.get(), 150, 360);
1034 FPDFLink_GetLinkAtPoint(page.get(), 150, 420);
fxcrt::ByteString ByteString
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
uint32_t GetParsedPageCountForTesting()
ByteString(const char *ptr)
FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDFLink_GetAction(FPDF_LINK link)
FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFLink_GetDest(FPDF_DOCUMENT document, FPDF_LINK link)
FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDFBookmark_GetAction(FPDF_BOOKMARK bookmark)
FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTION action)
FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFDest_GetView(FPDF_DEST dest, unsigned long *pNumParams, FS_FLOAT *pParams)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark, void *buffer, unsigned long buflen)
FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDF_GetPageAAction(FPDF_PAGE page, int aa_type)
FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark)
FPDF_EXPORT int FPDF_CALLCONV FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y)
FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetFilePath(FPDF_ACTION action, void *buffer, unsigned long buflen)
FPDF_EXPORT int FPDF_CALLCONV FPDFBookmark_GetCount(FPDF_BOOKMARK bookmark)
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFLink_GetAnnot(FPDF_PAGE page, FPDF_LINK link_annot)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetType(FPDF_ACTION action)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFDest_GetLocationInPage(FPDF_DEST dest, FPDF_BOOL *hasXVal, FPDF_BOOL *hasYVal, FPDF_BOOL *hasZoomVal, FS_FLOAT *x, FS_FLOAT *y, FS_FLOAT *zoom)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetURIPath(FPDF_DOCUMENT document, FPDF_ACTION action, void *buffer, unsigned long buflen)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetMetaText(FPDF_DOCUMENT document, FPDF_BYTESTRING tag, void *buffer, unsigned long buflen)
FPDF_EXPORT FPDF_LINK FPDF_CALLCONV FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y)
FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark)
FPDF_EXPORT int FPDF_CALLCONV FPDFDest_GetDestPageIndex(FPDF_DOCUMENT document, FPDF_DEST dest)
#define PDFDEST_VIEW_UNKNOWN_MODE
#define PDFACTION_EMBEDDEDGOTO
#define PDFACTION_UNSUPPORTED
TEST_F(FPDFDocEmbedderTest, MultipleSamePage)
FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument()
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_Delete(FPDF_DOCUMENT document, int page_index)
std::unique_ptr< FPDF_WCHAR, pdfium::FreeDeleter > ScopedFPDFWideString
std::wstring GetPlatformWString(FPDF_WIDESTRING wstr)