14#include "build/build_config.h"
15#include "core/fpdfapi/parser/cpdf_document.h"
16#include "core/fxge/cfx_defaultrenderdevice.h"
17#include "fpdfsdk/cpdfsdk_helpers.h"
18#include "fpdfsdk/fpdf_view_c_api_test.h"
19#include "public/cpp/fpdf_scopers.h"
20#include "public/fpdfview.h"
21#include "testing/embedder_test.h"
22#include "testing/embedder_test_constants.h"
23#include "testing/embedder_test_environment.h"
24#include "testing/fx_string_testhelpers.h"
25#include "testing/gtest/include/gtest/gtest.h"
26#include "testing/utils/file_util.h"
27#include "testing/utils/hash.h"
28#include "testing/utils/path_service.h"
30#if defined(PDF_USE_SKIA)
31#include "third_party/skia/include/core/SkCanvas.h"
32#include "third_party/skia/include/core/SkColor.h"
33#include "third_party/skia/include/core/SkColorType.h"
34#include "third_party/skia/include/core/SkImage.h"
35#include "third_party/skia/include/core/SkImageInfo.h"
36#include "third_party/skia/include/core/SkPicture.h"
37#include "third_party/skia/include/core/SkPictureRecorder.h"
38#include "third_party/skia/include/core/SkRefCnt.h"
39#include "third_party/skia/include/core/SkSize.h"
40#include "third_party/skia/include/core/SkSurface.h"
43using pdfium::ManyRectanglesChecksum;
47constexpr char kFirstAlternate[] =
"FirstAlternate";
48constexpr char kLastAlternate[] =
"LastAlternate";
51const char kExpectedRectanglePostScript[] = R"(
52save
53/im/initmatrix load def
54/n/newpath load def/m/moveto load def/l/lineto load def/c/curveto load def/h/closepath load def
55/f/fill load def/F/eofill load def/s/stroke load def/W/clip load def/W*/eoclip load def
56/rg/setrgbcolor load def/k/setcmykcolor load def
57/J/setlinecap load def/j/setlinejoin load def/w/setlinewidth load def/M/setmiterlimit load def/d/setdash load def
58/q/gsave load def/Q/grestore load def/iM/imagemask load def
59/Tj/show load def/Ff/findfont load def/Fs/scalefont load def/Sf/setfont load def
60/cm/concat load def/Cm/currentmatrix load def/mx/matrix load def/sm/setmatrix load def
610 300 m 0 0 l 200 0 l 200 300 l 0 300 l h W n
62q
630 300 m 0 0 l 200 0 l 200 300 l 0 300 l h W n
64q
650 J
66[]0 d
670 j
681 w
6910 M
70mx Cm [1 0 0 -1 0 300]cm 0 290 m 10 290 l 10 300 l 0 300 l 0 290 l h 0 0 0 rg
71q F Q s sm
72mx Cm [1 0 0 -1 0 300]cm 10 150 m 60 150 l 60 180 l 10 180 l 10 150 l h q F Q s sm
73mx Cm [1 0 0 -1 0 300]cm 190 290 m 200 290 l 200 300 l 190 300 l 190 290 l h 0 0 1 rg
74q F Q 0 0 0 rg
75s sm
76mx Cm [1 0 0 -1 0 300]cm 70 232 m 120 232 l 120 262 l 70 262 l 70 232 l h 0 0 1 rg
77q F Q 0 0 0 rg
78s sm
79mx Cm [1 0 0 -1 0 300]cm 190 0 m 200 0 l 200 10 l 190 10 l 190 0 l h 0 1 0 rg
80q F Q 0 0 0 rg
81s sm
82mx Cm [1 0 0 -1 0 300]cm 130 150 m 180 150 l 180 180 l 130 180 l 130 150 l h 0 1 0 rg
83q F Q 0 0 0 rg
84s sm
85mx Cm [1 0 0 -1 0 300]cm 0 0 m 10 0 l 10 10 l 0 10 l 0 0 l h 1 0 0 rg
86q F Q 0 0 0 rg
87s sm
88mx Cm [1 0 0 -1 0 300]cm 70 67 m 120 67 l 120 97 l 70 97 l 70 67 l h 1 0 0 rg
89q F Q 0 0 0 rg
90s sm
91Q
92Q
93Q
94
95restore
96)";
99class MockDownloadHints
final :
public FX_DOWNLOADHINTS {
101 static void SAddSegment(FX_DOWNLOADHINTS* pThis, size_t offset, size_t size) {
104 MockDownloadHints() {
109 ~MockDownloadHints() =
default;
112#if defined(PDF_USE_SKIA)
113ScopedFPDFBitmap SkImageToPdfiumBitmap(
const SkImage& image) {
114 ScopedFPDFBitmap bitmap(
115 FPDFBitmap_Create(image.width(), image.height(), 1));
117 ADD_FAILURE() <<
"Could not create FPDF_BITMAP";
121 if (!image.readPixels(
nullptr,
122 image.imageInfo().makeColorType(kBGRA_8888_SkColorType),
123 FPDFBitmap_GetBuffer(bitmap.get()),
124 FPDFBitmap_GetStride(bitmap.get()),
126 ADD_FAILURE() <<
"Could not read pixels from SkImage";
133ScopedFPDFBitmap SkPictureToPdfiumBitmap(sk_sp<SkPicture> picture,
134 const SkISize& size) {
135 sk_sp<SkSurface> surface =
136 SkSurfaces::Raster(SkImageInfo::MakeN32Premul(size));
138 ADD_FAILURE() <<
"Could not create SkSurface";
142 surface->getCanvas()->clear(SK_ColorWHITE);
143 surface->getCanvas()->drawPicture(picture);
144 sk_sp<SkImage> image = surface->makeImageSnapshot();
146 ADD_FAILURE() <<
"Could not snapshot SkSurface";
150 return SkImageToPdfiumBitmap(*image);
165 const FS_MATRIX& matrix,
166 const FS_RECTF& rect,
167 const char* expected_checksum) {
168 ScopedFPDFBitmap bitmap(FPDFBitmap_Create(bitmap_width, bitmap_height, 0));
169 FPDFBitmap_FillRect(bitmap.get(), 0, 0, bitmap_width, bitmap_height,
171 FPDF_RenderPageBitmapWithMatrix(bitmap.get(), page, &matrix, &rect, 0);
177 const char* expected_checksum) {
180 ScopedFPDFBitmap bitmap(FPDFBitmap_Create(bitmap_width, bitmap_height, 0));
181 FPDFBitmap_FillRect(bitmap.get(), 0, 0, bitmap_width, bitmap_height,
183 FPDF_RenderPageBitmap(bitmap.get(), page, 0, 0, bitmap_width, bitmap_height,
190 const char* expected_checksum) {
192 page
, format
, 0
, expected_checksum
);
199 const char* expected_checksum) {
203 ASSERT_NE(0, bytes_per_pixel);
205 ScopedFPDFBitmap bitmap(FPDFBitmap_CreateEx(
206 bitmap_width, bitmap_height, format,
nullptr, bitmap_stride));
207 RenderPageToBitmapAndCheck(page, bitmap.get(), expected_checksum);
212 const char* expected_checksum) {
215 ASSERT_NE(0, bytes_per_pixel);
217 int bitmap_stride = bytes_per_pixel * bitmap_width;
218 return TestRenderPageBitmapWithExternalMemoryImpl(
219 page, format, bitmap_stride, expected_checksum);
225 const char* expected_checksum) {
226 return TestRenderPageBitmapWithExternalMemoryImpl(
227 page, format, 0, expected_checksum);
230#if defined(PDF_USE_SKIA)
254 void TestRenderPageBitmapWithExternalMemoryImpl(
258 const char* expected_checksum) {
262 std::vector<uint8_t> external_memory(bitmap_stride * bitmap_height);
263 ScopedFPDFBitmap bitmap(FPDFBitmap_CreateEx(bitmap_width, bitmap_height,
264 format, external_memory.data(),
266 RenderPageToBitmapAndCheck(page, bitmap.get(), expected_checksum);
269 void RenderPageToBitmapAndCheck(FPDF_PAGE page,
271 const char* expected_checksum) {
285 ASSERT_TRUE(OpenDocument(
"about_blank.pdf"));
286 FPDF_PAGE page = LoadPage(0);
290 const double kTolerance = 0.0001;
308 device_x
, device_y
, &page_x
, &page_y
));
309 EXPECT_NEAR(9.5625, page_x, kTolerance);
310 EXPECT_NEAR(775.5, page_y, kTolerance);
315 device_x
, device_y
, &page_x
, &page_y
));
316 EXPECT_NEAR(12.75, page_x, kTolerance);
317 EXPECT_NEAR(12.375, page_y, kTolerance);
322 device_x
, device_y
, &page_x
, &page_y
));
323 EXPECT_NEAR(602.4374, page_x, kTolerance);
324 EXPECT_NEAR(16.5, page_y, kTolerance);
329 device_x
, device_y
, &page_x
, &page_y
));
330 EXPECT_NEAR(599.25, page_x, kTolerance);
331 EXPECT_NEAR(779.625, page_y, kTolerance);
338 device_x
, device_y
, &page_x
, &page_y
));
339 EXPECT_NEAR(9.5625, page_x, kTolerance);
340 EXPECT_NEAR(775.5, page_y, kTolerance);
346 device_x
, device_y
, &page_x
, &page_y
));
347 EXPECT_NEAR(device_x, page_x, kTolerance);
348 EXPECT_NEAR(device_y, page_y, kTolerance);
354 rotate
, device_x
, device_y
, &page_x
, &page_y
));
356 EXPECT_NEAR(1234.0, page_x, kTolerance);
357 EXPECT_NEAR(5678.0, page_y, kTolerance);
361 device_x
, device_y
, nullptr, nullptr));
368 ASSERT_TRUE(OpenDocument(
"about_blank.pdf"));
369 FPDF_PAGE page = LoadPage(0);
383 double page_y = 775.0;
388 page_x
, page_y
, &device_x
, &device_y
));
390 EXPECT_EQ(9, device_x);
391 EXPECT_EQ(10, device_y);
396 page_x
, page_y
, &device_x
, &device_y
));
397 EXPECT_EQ(626, device_x);
398 EXPECT_EQ(7, device_y);
403 page_x
, page_y
, &device_x
, &device_y
));
404 EXPECT_EQ(631, device_x);
405 EXPECT_EQ(470, device_y);
410 page_x
, page_y
, &device_x
, &device_y
));
411 EXPECT_EQ(14, device_x);
412 EXPECT_EQ(473, device_y);
419 page_x
, page_y
, &device_x
, &device_y
));
420 EXPECT_EQ(9, device_x);
421 EXPECT_EQ(10, device_y);
427 page_x
, page_y
, &device_x
, &device_y
));
428 EXPECT_EQ(start_x, device_x);
429 EXPECT_EQ(start_y, device_y);
435 rotate
, page_x
, page_y
, &device_x
, &device_y
));
437 EXPECT_EQ(1234, device_x);
438 EXPECT_EQ(5678, device_y);
442 page_x
, page_y
, nullptr, nullptr));
451 ASSERT_TRUE(OpenDocument(
"about_blank.pdf"));
464 for (
int i = 0; i < 3; ++i) {
465 if (!OpenDocument(
"about_blank.pdf"))
479 ASSERT_TRUE(OpenDocument(
"about_blank.pdf"));
480 EXPECT_EQ(1, GetPageCount());
481 EXPECT_EQ(0, GetFirstPageNum());
484 EXPECT_TRUE(FPDF_GetFileVersion(document(), &version));
485 EXPECT_EQ(14, version);
488 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocPermissions(document()));
489 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocUserPermissions(document()));
490 EXPECT_EQ(-1, FPDF_GetSecurityHandlerRevision(document()));
494 ASSERT_TRUE(OpenDocument(
"about_blank.pdf"));
495 EXPECT_EQ(1, GetPageCount());
496 EXPECT_EQ(0, GetFirstPageNum());
499 EXPECT_TRUE(FPDF_GetFileVersion(document(), &version));
500 EXPECT_EQ(14, version);
503 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocPermissions(document()));
504 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocUserPermissions(document()));
505 EXPECT_EQ(-1, FPDF_GetSecurityHandlerRevision(document()));
511 ASSERT_FALSE(file_path.empty());
513 std::vector<uint8_t> file_contents = GetFileContents(file_path.c_str());
514 ASSERT_FALSE(file_contents.empty());
515 ScopedFPDFDocument doc(FPDF_LoadMemDocument64(file_contents.data(),
516 file_contents.size(),
nullptr));
520 EXPECT_TRUE(FPDF_GetFileVersion(doc.get(), &version));
521 EXPECT_EQ(14, version);
531 ASSERT_TRUE(OpenDocument(
"no_page_count.pdf"));
532 ASSERT_EQ(6, FPDF_GetPageCount(document()));
536 ASSERT_TRUE(OpenDocument(
"page_tree_empty_node.pdf"));
537 ASSERT_EQ(2, FPDF_GetPageCount(document()));
542 CreateEmptyDocument();
545 EXPECT_FALSE(FPDF_GetFileVersion(document(), &version));
546 EXPECT_EQ(0, version);
548 EXPECT_EQ(0U, FPDF_GetDocPermissions(document()));
549 EXPECT_EQ(-1, FPDF_GetSecurityHandlerRevision(document()));
550 EXPECT_EQ(0, FPDF_GetPageCount(document()));
551 EXPECT_TRUE(FPDF_VIEWERREF_GetPrintScaling(document()));
552 EXPECT_EQ(1, FPDF_VIEWERREF_GetNumCopies(document()));
553 EXPECT_EQ(DuplexUndefined, FPDF_VIEWERREF_GetDuplex(document()));
556 EXPECT_EQ(0U, FPDF_VIEWERREF_GetName(document(),
"foo",
nullptr, 0));
557 EXPECT_EQ(0U, FPDF_VIEWERREF_GetName(document(),
"foo", buf,
sizeof(buf)));
558 EXPECT_EQ(0u, FPDF_CountNamedDests(document()));
565 CreateEmptyDocument();
566 len = FPDF_GetMetaText(document(),
"CreationDate", buf,
sizeof(buf));
568 EXPECT_NE(0u, buf[0]);
572 CreateEmptyDocument();
573 len = FPDF_GetMetaText(document(),
"CreationDate", buf,
sizeof(buf));
575 EXPECT_EQ(0u, buf[0]);
578 constexpr unsigned long kNoSuchPolicy = 102;
580 CreateEmptyDocument();
581 len = FPDF_GetMetaText(document(),
"CreationDate", buf,
sizeof(buf));
583 EXPECT_EQ(0u, buf[0]);
587 CreateEmptyDocument();
588 len = FPDF_GetMetaText(document(),
"CreationDate", buf,
sizeof(buf));
590 EXPECT_NE(0u, buf[0]);
595 ASSERT_TRUE(OpenDocumentLinearized(
"feature_linearized_loading.pdf"));
597 EXPECT_TRUE(FPDF_GetFileVersion(document(), &version));
598 EXPECT_EQ(16, version);
607 std::string file_contents_string;
608 ScopedFPDFDocument doc;
612 ASSERT_FALSE(pdf_path.empty());
613 std::vector<uint8_t> file_contents = GetFileContents(pdf_path.c_str());
614 ASSERT_FALSE(file_contents.empty());
615 std::copy(file_contents.begin(), file_contents.end(),
616 std::back_inserter(file_contents_string));
620 FPDF_FILEACCESS file_access = {};
621 file_access.m_FileLen = file_contents_string.size();
622 file_access.m_GetBlock = GetBlockFromString;
623 file_access.m_Param = &file_contents_string;
629 ScopedFPDFPage page(FPDF_LoadPage(doc.get(), 0));
631 EXPECT_FLOAT_EQ(200.0f, FPDF_GetPageWidthF(page.get()));
632 EXPECT_FLOAT_EQ(300.0f, FPDF_GetPageHeightF(page.get()));
636 ASSERT_TRUE(OpenDocument(
"about_blank.pdf"));
637 FPDF_PAGE page = LoadPage(0);
645 EXPECT_EQ(0.0, rect.left);
646 EXPECT_EQ(0.0, rect.bottom);
647 EXPECT_EQ(612.0, rect.right);
648 EXPECT_EQ(792.0, rect.top);
657 EXPECT_FALSE(LoadPage(1));
661 ASSERT_TRUE(OpenDocument(
"about_blank.pdf"));
662 EXPECT_TRUE(FPDF_VIEWERREF_GetPrintScaling(document()));
663 EXPECT_EQ(1, FPDF_VIEWERREF_GetNumCopies(document()));
664 EXPECT_EQ(DuplexUndefined, FPDF_VIEWERREF_GetDuplex(document()));
667 EXPECT_EQ(0U, FPDF_VIEWERREF_GetName(document(),
"foo",
nullptr, 0));
668 EXPECT_EQ(0U, FPDF_VIEWERREF_GetName(document(),
"foo", buf,
sizeof(buf)));
670 FPDF_PAGERANGE page_range = FPDF_VIEWERREF_GetPrintPageRange(document());
671 EXPECT_FALSE(page_range);
672 EXPECT_EQ(0U, FPDF_VIEWERREF_GetPrintPageRangeCount(page_range));
673 EXPECT_EQ(-1, FPDF_VIEWERREF_GetPrintPageRangeElement(page_range, 0));
674 EXPECT_EQ(-1, FPDF_VIEWERREF_GetPrintPageRangeElement(page_range, 1));
678 ASSERT_TRUE(OpenDocument(
"viewer_ref.pdf"));
679 EXPECT_TRUE(FPDF_VIEWERREF_GetPrintScaling(document()));
680 EXPECT_EQ(5, FPDF_VIEWERREF_GetNumCopies(document()));
681 EXPECT_EQ(DuplexUndefined, FPDF_VIEWERREF_GetDuplex(document()));
685 EXPECT_EQ(0U, FPDF_VIEWERREF_GetName(document(),
"", buf,
sizeof(buf)));
686 EXPECT_EQ(0U, FPDF_VIEWERREF_GetName(document(),
"foo",
nullptr, 0));
687 EXPECT_EQ(0U, FPDF_VIEWERREF_GetName(document(),
"foo", buf,
sizeof(buf)));
692 EXPECT_EQ(4U, FPDF_VIEWERREF_GetName(document(),
"Foo", buf, 1));
693 EXPECT_STREQ(
"ABCD", buf);
697 FPDF_VIEWERREF_GetName(document(),
"Foo",
nullptr,
sizeof(buf)));
698 ASSERT_EQ(4U, FPDF_VIEWERREF_GetName(document(),
"Foo", buf,
sizeof(buf)));
699 EXPECT_STREQ(
"foo", buf);
703 0U, FPDF_VIEWERREF_GetName(document(),
"HideToolbar", buf,
sizeof(buf)));
705 FPDF_VIEWERREF_GetName(document(),
"NumCopies", buf,
sizeof(buf)));
709 FPDF_VIEWERREF_GetName(document(),
"Direction", buf,
sizeof(buf)));
710 EXPECT_STREQ(
"R2L", buf);
712 FPDF_VIEWERREF_GetName(document(),
"ViewArea", buf,
sizeof(buf)));
713 EXPECT_STREQ(
"CropBox", buf);
715 FPDF_PAGERANGE page_range = FPDF_VIEWERREF_GetPrintPageRange(document());
716 EXPECT_TRUE(page_range);
717 EXPECT_EQ(4U, FPDF_VIEWERREF_GetPrintPageRangeCount(page_range));
718 EXPECT_EQ(0, FPDF_VIEWERREF_GetPrintPageRangeElement(page_range, 0));
719 EXPECT_EQ(2, FPDF_VIEWERREF_GetPrintPageRangeElement(page_range, 1));
720 EXPECT_EQ(4, FPDF_VIEWERREF_GetPrintPageRangeElement(page_range, 2));
721 EXPECT_EQ(4, FPDF_VIEWERREF_GetPrintPageRangeElement(page_range, 3));
722 EXPECT_EQ(-1, FPDF_VIEWERREF_GetPrintPageRangeElement(page_range, 4));
726 ASSERT_TRUE(OpenDocument(
"named_dests.pdf"));
727 EXPECT_EQ(6u, FPDF_CountNamedDests(document()));
730 char fixed_buffer[512];
734 buffer_size = 2000000;
735 dest = FPDF_GetNamedDest(document(), 0,
nullptr, &buffer_size);
737 EXPECT_EQ(12, buffer_size);
741 dest = FPDF_GetNamedDest(document(), 0, fixed_buffer, &buffer_size);
743 EXPECT_EQ(-1, buffer_size);
748 dest = FPDF_GetNamedDest(document(), 0, fixed_buffer, &buffer_size);
750 EXPECT_EQ(12, buffer_size);
756 buffer_size =
sizeof(fixed_buffer);
757 dest = FPDF_GetNamedDest(document(), 1, fixed_buffer, &buffer_size);
759 EXPECT_EQ(10, buffer_size);
766 buffer_size =
sizeof(fixed_buffer);
767 dest = FPDF_GetNamedDest(document(), 2, fixed_buffer, &buffer_size);
769 EXPECT_EQ(
sizeof(fixed_buffer),
770 static_cast<size_t>(buffer_size));
774 buffer_size =
sizeof(fixed_buffer);
775 dest = FPDF_GetNamedDest(document(), 3, fixed_buffer, &buffer_size);
777 EXPECT_EQ(
sizeof(fixed_buffer),
778 static_cast<size_t>(buffer_size));
782 buffer_size =
sizeof(fixed_buffer);
783 dest = FPDF_GetNamedDest(document(), 4, fixed_buffer, &buffer_size);
785 EXPECT_EQ(30, buffer_size);
786 EXPECT_EQ(kFirstAlternate,
792 buffer_size =
sizeof(fixed_buffer);
793 dest = FPDF_GetNamedDest(document(), 5, fixed_buffer, &buffer_size);
795 EXPECT_EQ(28, buffer_size);
796 EXPECT_EQ(kLastAlternate,
800 buffer_size =
sizeof(fixed_buffer);
801 dest = FPDF_GetNamedDest(document(), 6, fixed_buffer, &buffer_size);
803 EXPECT_EQ(
sizeof(fixed_buffer),
804 static_cast<size_t>(buffer_size));
807 buffer_size =
sizeof(fixed_buffer);
808 dest = FPDF_GetNamedDest(document(),
std::numeric_limits<
int>::max(),
809 fixed_buffer, &buffer_size);
811 EXPECT_EQ(
sizeof(fixed_buffer),
812 static_cast<size_t>(buffer_size));
814 buffer_size =
sizeof(fixed_buffer);
815 dest = FPDF_GetNamedDest(document(),
std::numeric_limits<
int>::min(),
816 fixed_buffer, &buffer_size);
818 EXPECT_EQ(
sizeof(fixed_buffer),
819 static_cast<size_t>(buffer_size));
821 buffer_size =
sizeof(fixed_buffer);
822 dest = FPDF_GetNamedDest(document(), -1, fixed_buffer, &buffer_size);
824 EXPECT_EQ(
sizeof(fixed_buffer),
825 static_cast<size_t>(buffer_size));
829 ASSERT_TRUE(OpenDocument(
"named_dests.pdf"));
832 FPDF_DEST dest = FPDF_GetNamedDestByName(document(),
nullptr);
836 dest = FPDF_GetNamedDestByName(document(),
"");
840 dest = FPDF_GetNamedDestByName(document(),
"First");
844 FPDF_DEST dest_by_index =
845 FPDF_GetNamedDest(document(), 0,
nullptr, &ignore_len);
846 EXPECT_EQ(dest_by_index, dest);
849 dest = FPDF_GetNamedDestByName(document(), kFirstAlternate);
853 dest_by_index = FPDF_GetNamedDest(document(), 4,
nullptr, &ignore_len);
854 EXPECT_EQ(dest_by_index, dest);
857 dest = FPDF_GetNamedDestByName(document(),
"WrongType");
861 dest = FPDF_GetNamedDestByName(document(),
"Bogus");
866 ASSERT_TRUE(OpenDocument(
"named_dests_old_style.pdf"));
867 EXPECT_EQ(2u, FPDF_CountNamedDests(document()));
870 EXPECT_FALSE(FPDF_GetNamedDestByName(document(),
nullptr));
871 EXPECT_FALSE(FPDF_GetNamedDestByName(document(),
""));
872 EXPECT_FALSE(FPDF_GetNamedDestByName(document(),
"NoSuchName"));
875 EXPECT_TRUE(FPDF_GetNamedDestByName(document(), kFirstAlternate));
876 EXPECT_TRUE(FPDF_GetNamedDestByName(document(), kLastAlternate));
879 constexpr long kBufferSize =
sizeof(buffer);
880 long size = kBufferSize;
883 EXPECT_FALSE(FPDF_GetNamedDest(document(), -1, buffer, &size));
884 EXPECT_EQ(kBufferSize, size);
886 EXPECT_FALSE(FPDF_GetNamedDest(document(), 2, buffer, &size));
887 EXPECT_EQ(kBufferSize, size);
891 ASSERT_TRUE(FPDF_GetNamedDest(document(), 0, buffer, &size));
892 ASSERT_EQ(
static_cast<
int>(
sizeof(kFirstAlternate) * 2), size);
893 EXPECT_EQ(kFirstAlternate,
896 ASSERT_TRUE(FPDF_GetNamedDest(document(), 1, buffer, &size));
897 ASSERT_EQ(
static_cast<
int>(
sizeof(kLastAlternate) * 2), size);
898 EXPECT_EQ(kLastAlternate,
904 ASSERT_TRUE(OpenDocument(
"bug_113.pdf"));
909 EXPECT_FALSE(OpenDocument(
"bug_451830.pdf"));
913 ASSERT_TRUE(OpenDocument(
"bug_452455.pdf"));
914 FPDF_PAGE page = LoadPage(0);
921 EXPECT_FALSE(OpenDocument(
"bug_454695.pdf"));
925 ASSERT_TRUE(OpenDocument(
"bug_572871.pdf"));
931 ASSERT_TRUE(OpenDocument(
"bug_213.pdf"));
936 EXPECT_FALSE(OpenDocument(
"bug_298.pdf"));
940 ASSERT_TRUE(OpenDocument(
"bug_773229.pdf"));
948 ASSERT_TRUE(OpenDocument(
"bug_xrefv4_loop.pdf"));
949 MockDownloadHints hints;
955 ret = FPDFAvail_IsDocAvail(avail(), &hints);
962 EXPECT_FALSE(OpenDocument(
"bug_343.pdf"));
968 EXPECT_FALSE(OpenDocument(
"bug_344.pdf"));
974 EXPECT_FALSE(OpenDocument(
"bug_355.pdf"));
978 EXPECT_FALSE(OpenDocument(
"bug_360.pdf"));
984 ASSERT_TRUE(OpenDocumentLinearized(
"linearized_bug_1055.pdf"));
986 EXPECT_TRUE(FPDF_GetFileVersion(document(), &version));
987 EXPECT_EQ(16, version);
991 const char* clipped_checksum = []() {
993 return "d2929fae285593cd1c1d446750d47d60";
995 return "a84cab93c102b9b9290fba3047ba702c";
997 const char* top_left_quarter_checksum = []() {
999 return "31d24d8c6a2bac380b2f5c393e77ecc9";
1001 return "f11a11137c8834389e31cf555a4a6979";
1003 const char* hori_stretched_checksum = []() {
1005 return "6d3776d7bb21cbb7195126b8e95dfba2";
1007 return "48ef9205941ed19691ccfa00d717187e";
1009 const char* rotated_90_clockwise_checksum = []() {
1011 return "b4baa001d201baed576cd6d5d0d5a160";
1013 return "d8da2c7bf77521550d0f2752b9cf3482";
1015 const char* rotated_180_clockwise_checksum = []() {
1017 return "51819227d0863222aed366d5d7c5d9c8";
1019 return "0113386bb0bd45125bacc6dee78bfe78";
1021 const char* rotated_270_clockwise_checksum = []() {
1023 return "f2b046e46c2751cebc777a9725ae2f3e";
1025 return "a287e0f74ce203699cda89f9cc97a240";
1027 const char* mirror_hori_checksum = []() {
1029 return "c7fbec322b4fc6bcf46ec1eb89661c41";
1031 return "6e8d7a6fde39d8e720fb9e620102918c";
1033 const char* mirror_vert_checksum = []() {
1035 return "a8b00bc40677a73c15a08b9769d1b576";
1037 return "8f3a555ef9c0d5031831ae3715273707";
1039 const char* larger_top_left_quarter_checksum = []() {
1041 return "35deb5ed4b73675ce33f68328a33c687";
1043 return "172a2f4adafbadbe98017b1c025b9e27";
1045 const char* larger_rotated_diagonal_checksum = []() {
1047 return "85c41bb892c1a09882f432aa2f4a5ef6";
1049 return "3d62417468bdaff0eb14391a0c30a3b1";
1051 const char* tile_checksum = []() {
1053 return "387be3a84774f39aaa955314d2fe7106";
1055 return "0a190003c97220bf8877684c8d7e89cf";
1057 const char kLargerChecksum[] =
"c806145641c3e6fc4e022c7065343749";
1058 const char kLargerClippedChecksum[] =
"091d3b1c7933c8f6945eb2cb41e588e9";
1059 const char kLargerRotatedChecksum[] =
"115f13353ebfc82ddb392d1f0059eb12";
1060 const char kLargerRotatedLandscapeChecksum[] =
1061 "c901239d17d84ac84cb6f2124da71b0d";
1063 ASSERT_TRUE(OpenDocument(
"rectangles.pdf"));
1064 FPDF_PAGE page = LoadPage(0);
1068 EXPECT_FLOAT_EQ(200, page_width);
1069 EXPECT_FLOAT_EQ(300, page_height);
1071 using pdfium::RectanglesChecksum;
1072 ScopedFPDFBitmap bitmap = RenderLoadedPage(page);
1075 FS_RECTF page_rect{0, 0, page_width, page_height};
1079 FS_MATRIX identity_matrix{1, 0, 0, 1, 0, 0};
1080 TestRenderPageBitmapWithMatrix(page, page_width, page_height, identity_matrix,
1084 FS_RECTF middle_of_page_rect{page_width / 4, page_height / 4,
1085 page_width * 3 / 4, page_height * 3 / 4};
1086 TestRenderPageBitmapWithMatrix(page, page_width, page_height, identity_matrix,
1087 middle_of_page_rect, clipped_checksum);
1090 FS_MATRIX half_scale_matrix{0.5, 0, 0, 0.5, 0, 0};
1091 TestRenderPageBitmapWithMatrix(page, page_width, page_height,
1092 half_scale_matrix, page_rect,
1093 top_left_quarter_checksum);
1097 FS_MATRIX stretch_x_matrix{2, 0, 0, 1, 0, 0};
1098 TestRenderPageBitmapWithMatrix(page, page_width, page_height,
1099 stretch_x_matrix, page_rect,
1100 hori_stretched_checksum);
1104 FS_MATRIX rotate_90_matrix{0, 1, -1, 0, page_width, 0};
1105 TestRenderPageBitmapWithMatrix(page, page_width, page_height,
1106 rotate_90_matrix, page_rect,
1107 rotated_90_clockwise_checksum);
1110 FS_MATRIX rotate_180_matrix{-1, 0, 0, -1, page_width, page_height};
1111 TestRenderPageBitmapWithMatrix(page, page_width, page_height,
1112 rotate_180_matrix, page_rect,
1113 rotated_180_clockwise_checksum);
1116 FS_MATRIX rotate_270_matrix{0, -1, 1, 0, 0, page_width};
1117 TestRenderPageBitmapWithMatrix(page, page_width, page_height,
1118 rotate_270_matrix, page_rect,
1119 rotated_270_clockwise_checksum);
1122 FS_MATRIX mirror_hori_matrix{-1, 0, 0, 1, page_width, 0};
1123 TestRenderPageBitmapWithMatrix(page, page_width, page_height,
1124 mirror_hori_matrix, page_rect,
1125 mirror_hori_checksum);
1128 FS_MATRIX mirror_vert_matrix{1, 0, 0, -1, 0, page_height};
1129 TestRenderPageBitmapWithMatrix(page, page_width, page_height,
1130 mirror_vert_matrix, page_rect,
1131 mirror_vert_checksum);
1134 const float bitmap_width = page_width * 2;
1135 const float bitmap_height = page_height * 2;
1138 FS_RECTF bitmap_rect{0, 0, bitmap_width, bitmap_height};
1139 TestRenderPageBitmapWithMatrix(page, bitmap_width, bitmap_height,
1140 identity_matrix, bitmap_rect,
1141 larger_top_left_quarter_checksum);
1144 FS_MATRIX double_scale_matrix{2, 0, 0, 2, 0, 0};
1145 TestRenderPageBitmapWithMatrix(page, bitmap_width, bitmap_height,
1146 double_scale_matrix, bitmap_rect,
1150 FS_RECTF middle_of_bitmap_rect{bitmap_width / 4, bitmap_height / 4,
1151 bitmap_width * 3 / 4, bitmap_height * 3 / 4};
1152 TestRenderPageBitmapWithMatrix(page, bitmap_width, bitmap_height,
1153 double_scale_matrix, middle_of_bitmap_rect,
1154 kLargerClippedChecksum);
1158 FS_MATRIX rotate_90_scale_2_matrix{0, 2, -2, 0, bitmap_width, 0};
1159 TestRenderPageBitmapWithMatrix(page, bitmap_width, bitmap_height,
1160 rotate_90_scale_2_matrix, bitmap_rect,
1161 kLargerRotatedChecksum);
1165 const float landscape_bitmap_width = bitmap_height;
1166 const float landscape_bitmap_height = bitmap_width;
1167 FS_RECTF landscape_bitmap_rect{0, 0, landscape_bitmap_width,
1168 landscape_bitmap_height};
1169 FS_MATRIX landscape_rotate_90_scale_2_matrix{
1170 0, 2, -2, 0, landscape_bitmap_width, 0};
1171 TestRenderPageBitmapWithMatrix(
1172 page, landscape_bitmap_width, landscape_bitmap_height,
1173 landscape_rotate_90_scale_2_matrix, landscape_bitmap_rect,
1174 kLargerRotatedLandscapeChecksum);
1178 const float sqrt2 = 1.41421356f;
1179 const float diagonal_bitmap_size =
1180 ceil((bitmap_width + bitmap_height) / sqrt2);
1181 FS_RECTF diagonal_bitmap_rect{0, 0, diagonal_bitmap_size,
1182 diagonal_bitmap_size};
1183 FS_MATRIX rotate_45_scale_2_matrix{
1184 sqrt2, sqrt2, -sqrt2, sqrt2, bitmap_height / sqrt2, 0};
1185 TestRenderPageBitmapWithMatrix(page, diagonal_bitmap_size,
1186 diagonal_bitmap_size, rotate_45_scale_2_matrix,
1187 diagonal_bitmap_rect,
1188 larger_rotated_diagonal_checksum);
1192 const float scale = 7.0;
1193 const int tile_size = 50;
1194 const int tile_x = 2;
1195 const int tile_y = 1;
1196 float tile_bitmap_size = scale * tile_size;
1197 FS_RECTF tile_bitmap_rect{0, 0, tile_bitmap_size, tile_bitmap_size};
1198 FS_MATRIX tile_2_1_matrix{scale,
1202 -tile_x * tile_bitmap_size,
1203 -tile_y * tile_bitmap_size};
1204 TestRenderPageBitmapWithMatrix(page, tile_bitmap_size, tile_bitmap_size,
1205 tile_2_1_matrix, tile_bitmap_rect,
1212 ASSERT_TRUE(OpenDocument(
"rectangles.pdf"));
1216 EXPECT_FALSE(FPDF_GetPageSizeByIndexF(document(), 0,
nullptr));
1219 EXPECT_FALSE(FPDF_GetPageSizeByIndexF(document(), -1, &size));
1222 EXPECT_FALSE(FPDF_GetPageSizeByIndexF(document(), 1, &size));
1225 EXPECT_TRUE(FPDF_GetPageSizeByIndexF(document(), 0, &size));
1226 EXPECT_FLOAT_EQ(200.0f, size.width);
1227 EXPECT_FLOAT_EQ(300.0f, size.height);
1229 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document());
1230#ifdef PDF_ENABLE_XFA
1232 EXPECT_EQ(1u, pDoc->GetParsedPageCountForTesting());
1238 FPDF_PAGE page = LoadPage(0);
1247 ASSERT_TRUE(OpenDocument(
"rectangles.pdf"));
1253 EXPECT_FALSE(FPDF_GetPageSizeByIndex(document(), 0,
nullptr, &height));
1254 EXPECT_FALSE(FPDF_GetPageSizeByIndex(document(), 0, &width,
nullptr));
1257 EXPECT_FALSE(FPDF_GetPageSizeByIndex(document(), -1, &width, &height));
1260 EXPECT_FALSE(FPDF_GetPageSizeByIndex(document(), 1, &width, &height));
1263 EXPECT_TRUE(FPDF_GetPageSizeByIndex(document(), 0, &width, &height));
1264 EXPECT_EQ(200.0, width);
1265 EXPECT_EQ(300.0, height);
1267 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document());
1268#ifdef PDF_ENABLE_XFA
1270 EXPECT_EQ(1u, pDoc->GetParsedPageCountForTesting());
1276 FPDF_PAGE page = LoadPage(0);
1285 ASSERT_TRUE(OpenDocument(
"simple_xfa.pdf"));
1287 static constexpr struct {
1289 size_t content_length;
1290 const char* content_checksum;
1291 } kExpectedResults[]{
1292 {
"preamble", 124u,
"71be364e53292596412242bfcdb46eab"},
1293 {
"config", 642u,
"bcd1ca1d420ee31a561273a54a06435f"},
1294 {
"template", 541u,
"0f48cb2fa1bb9cbf9eee802d66e81bf4"},
1295 {
"localeSet", 3455u,
"bb1f253d3e5c719ac0da87d055bc164e"},
1296 {
"postamble", 11u,
"6b79e25da35d86634ea27c38f64cf243"},
1299 ASSERT_EQ(
static_cast<
int>(
std::size(kExpectedResults)),
1300 FPDF_GetXFAPacketCount(document()));
1301 for (size_t i = 0; i <
std::size(kExpectedResults); ++i) {
1302 char name_buffer[20] = {};
1303 ASSERT_EQ(strlen(kExpectedResults[i].name) + 1,
1304 FPDF_GetXFAPacketName(document(), i,
nullptr, 0));
1306 strlen(kExpectedResults[i].name) + 1,
1307 FPDF_GetXFAPacketName(document(), i, name_buffer,
sizeof(name_buffer)));
1308 EXPECT_STREQ(kExpectedResults[i].name, name_buffer);
1310 unsigned long buflen;
1311 ASSERT_TRUE(FPDF_GetXFAPacketContent(document(), i,
nullptr, 0, &buflen));
1312 ASSERT_EQ(kExpectedResults[i].content_length, buflen);
1313 std::vector<uint8_t> data_buffer(buflen);
1314 EXPECT_TRUE(FPDF_GetXFAPacketContent(document(), i, data_buffer.data(),
1315 data_buffer.size(), &buflen));
1316 EXPECT_EQ(kExpectedResults[i].content_length, buflen);
1317 EXPECT_STREQ(kExpectedResults[i].content_checksum,
1318 GenerateMD5Base16(data_buffer).c_str());
1325 EXPECT_EQ(0u, FPDF_GetXFAPacketName(document(), -1,
nullptr, 0));
1326 EXPECT_EQ(0u, FPDF_GetXFAPacketName(document(),
std::size(kExpectedResults),
1329 unsigned long buflen = 123;
1331 EXPECT_EQ(123u, buflen);
1332 EXPECT_FALSE(FPDF_GetXFAPacketContent(document(), -1,
nullptr, 0, &buflen));
1333 EXPECT_EQ(123u, buflen);
1334 EXPECT_FALSE(FPDF_GetXFAPacketContent(document(),
std::size(kExpectedResults),
1335 nullptr, 0, &buflen));
1336 EXPECT_EQ(123u, buflen);
1337 EXPECT_FALSE(FPDF_GetXFAPacketContent(document(), 0,
nullptr, 0,
nullptr));
1341 ASSERT_TRUE(OpenDocument(
"bug_1265.pdf"));
1343 ASSERT_EQ(1, FPDF_GetXFAPacketCount(document()));
1345 char name_buffer[20] = {};
1346 ASSERT_EQ(1u, FPDF_GetXFAPacketName(document(), 0,
nullptr, 0));
1347 EXPECT_EQ(1u, FPDF_GetXFAPacketName(document(), 0, name_buffer,
1348 sizeof(name_buffer)));
1349 EXPECT_STREQ(
"", name_buffer);
1351 unsigned long buflen;
1352 ASSERT_TRUE(FPDF_GetXFAPacketContent(document(), 0,
nullptr, 0, &buflen));
1353 ASSERT_EQ(121u, buflen);
1354 std::vector<uint8_t> data_buffer(buflen);
1355 EXPECT_TRUE(FPDF_GetXFAPacketContent(document(), 0, data_buffer.data(),
1356 data_buffer.size(), &buflen));
1357 EXPECT_EQ(121u, buflen);
1358 EXPECT_STREQ(
"8f912eaa1e66c9341cb3032ede71e147",
1359 GenerateMD5Base16(data_buffer).c_str());
1363 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
1365 EXPECT_EQ(0, FPDF_GetXFAPacketCount(document()));
1369 ASSERT_TRUE(OpenDocument(
"text_form.pdf"));
1371 EXPECT_EQ(0, FPDF_GetXFAPacketCount(document()));
1385 RecordUnsupportedErrorDelegate delegate;
1386 SetDelegate(&delegate);
1387 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
1388 EXPECT_EQ(delegate
.type_, -1);
1389 SetDelegate(
nullptr);
1393 RecordUnsupportedErrorDelegate delegate;
1394 SetDelegate(&delegate);
1395 ASSERT_TRUE(OpenDocument(
"unsupported_feature.pdf"));
1397 SetDelegate(
nullptr);
1401 std::string file_path =
1403 ASSERT_FALSE(file_path.empty());
1405 RecordUnsupportedErrorDelegate delegate;
1406 SetDelegate(&delegate);
1408 ScopedFPDFDocument doc(FPDF_LoadDocument(file_path.c_str(),
""));
1412 SetDelegate(
nullptr);
1416 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
1417 EXPECT_TRUE(FPDF_DocumentHasValidCrossReferenceTable(document()));
1423 ASSERT_TRUE(OpenDocument(
"bug_664284.pdf"));
1424 EXPECT_FALSE(FPDF_DocumentHasValidCrossReferenceTable(document()));
1429 ASSERT_TRUE(OpenDocument(
"empty_xref.pdf"));
1430 EXPECT_TRUE(FPDF_DocumentHasValidCrossReferenceTable(document()));
1433 ASSERT_FALSE(file_path.empty());
1435 ScopedFPDFDocument doc(FPDF_LoadDocument(file_path.c_str(),
""));
1437 EXPECT_TRUE(FPDF_DocumentHasValidCrossReferenceTable(doc.get()));
1440 std::vector<uint8_t> file_contents = GetFileContents(file_path.c_str());
1441 ASSERT_FALSE(file_contents.empty());
1442 ScopedFPDFDocument doc(
1443 FPDF_LoadMemDocument(file_contents.data(), file_contents.size(),
""));
1445 EXPECT_TRUE(FPDF_DocumentHasValidCrossReferenceTable(doc.get()));
1463 const char* original_checksum = []() {
1465#if BUILDFLAG(IS_WIN)
1466 return "1c5d8217aca4f6fa86a8ed192f34b210";
1467#elif BUILDFLAG(IS_APPLE)
1468 return "b7ac2ca2b934f4e213ab4ba36c5f8ffd";
1470 return "29cb8045c21cfa2c920fdf43de70efd8";
1473#if BUILDFLAG(IS_APPLE)
1474 return "0e339d606aafb63077f49e238dc27cb0";
1476 return "288502887ffc63291f35a0573b944375";
1479 static const char kNoNativeTextChecksum[] =
1480 "288502887ffc63291f35a0573b944375";
1481 ASSERT_TRUE(OpenDocument(
"bug_664284.pdf"));
1482 FPDF_PAGE page = LoadPage(0);
1485 TestRenderPageBitmapWithFlags(page, 0, original_checksum);
1487 kNoNativeTextChecksum);
1493 const char* annotation_checksum = []() {
1495 return "eaece6b8041c0cb9b33398e5b6d5ddda";
1497 return "c108ba6e0a9743652f12e4bc223f9b32";
1499 static const char kPrintingChecksum[] =
"3e235b9f88f652f2b97b1fc393924849";
1500 ASSERT_TRUE(OpenDocument(
"bug_1658.pdf"));
1501 FPDF_PAGE page = LoadPage(0);
1505 TestRenderPageBitmapWithFlags(page,
FPDF_ANNOT, annotation_checksum);
1518 ASSERT_TRUE(OpenDocument(
"bug_1396264.pdf"));
1519 ScopedFPDFPage page(FPDF_LoadPage(document(), 0));
1522 TestRenderPageBitmapWithFlags(page.get(), 0,
1523 "81e7f4498090977c848a21b5c6510d3a");
1525 "505ba6d1c7f4044c11c91873452a8bde");
1529 static const char kNormalChecksum[] =
"4bcd56cae1ca2622403e8af07242e71a";
1530 static const char kGrayscaleChecksum[] =
"fe45ad56efe868ba82285fa5ffedc0cb";
1532 ASSERT_TRUE(OpenDocument(
"jpx_lzw.pdf"));
1533 FPDF_PAGE page = LoadPage(0);
1536 TestRenderPageBitmapWithFlags(page, 0, kNormalChecksum);
1537 TestRenderPageBitmapWithFlags(page,
FPDF_ANNOT, kNormalChecksum);
1538 TestRenderPageBitmapWithFlags(page,
FPDF_LCD_TEXT, kNormalChecksum);
1540 TestRenderPageBitmapWithFlags(page,
FPDF_GRAYSCALE, kGrayscaleChecksum);
1545 TestRenderPageBitmapWithFlags(page,
FPDF_PRINTING, kNormalChecksum);
1557 const char* grayscale_checksum = []() {
1559 return "b596ac8bbe64e7bff31888ab05e4dcf4";
1561 return "7b553f1052069a9c61237a05db0955d6";
1563 const char* no_smoothpath_checksum = []() {
1565 return "4d71ed53d9f6e6a761876ebb4ff23e19";
1567 return "ff6e5c509d1f6984bcdfd18b26a4203a";
1570 ASSERT_TRUE(OpenDocument(
"many_rectangles.pdf"));
1571 FPDF_PAGE page = LoadPage(0);
1579 TestRenderPageBitmapWithFlags(page,
FPDF_GRAYSCALE, grayscale_checksum);
1590 no_smoothpath_checksum);
1596 ASSERT_TRUE(OpenDocument(
"many_rectangles.pdf"));
1597 FPDF_PAGE page = LoadPage(0);
1600 const char* bgr_checksum = []() {
1602 return "4d52e5cc1d4a8067bf918b85b232fff0";
1604 return "ab6312e04c0d3f4e46fb302a45173d05";
1606 static constexpr int kBgrStride = 600;
1607 TestRenderPageBitmapWithInternalMemory(page,
FPDFBitmap_BGR, bgr_checksum);
1608 TestRenderPageBitmapWithInternalMemoryAndStride(page,
FPDFBitmap_BGR,
1609 kBgrStride, bgr_checksum);
1610 TestRenderPageBitmapWithExternalMemory(page,
FPDFBitmap_BGR, bgr_checksum);
1611 TestRenderPageBitmapWithExternalMemoryAndNoStride(page,
FPDFBitmap_BGR,
1614 const char* gray_checksum = []() {
1616 return "3dfe1fc3889123d68e1748fefac65e72";
1618 return "b561c11edc44dc3972125a9b8744fa2f";
1621 TestRenderPageBitmapWithInternalMemory(page,
FPDFBitmap_Gray, gray_checksum);
1622 static constexpr int kGrayStride = 200;
1623 TestRenderPageBitmapWithInternalMemoryAndStride(page,
FPDFBitmap_Gray,
1624 kGrayStride, gray_checksum);
1625 TestRenderPageBitmapWithExternalMemory(page,
FPDFBitmap_Gray, gray_checksum);
1626 TestRenderPageBitmapWithExternalMemoryAndNoStride(page,
FPDFBitmap_Gray,
1629 static constexpr int kBgrxStride = 800;
1632 TestRenderPageBitmapWithInternalMemoryAndStride(
1636 TestRenderPageBitmapWithExternalMemoryAndNoStride(page,
FPDFBitmap_BGRx,
1641 TestRenderPageBitmapWithInternalMemoryAndStride(
1645 TestRenderPageBitmapWithExternalMemoryAndNoStride(page,
FPDFBitmap_BGRA,
1652 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
1653 FPDF_PAGE page = LoadPage(0);
1656 using pdfium::HelloWorldChecksum;
1670 const char* lcd_text_checksum = []() {
1672#if BUILDFLAG(IS_WIN)
1673 return "496d1f907349b153c5ecdc87c8073c7b";
1674#elif BUILDFLAG(IS_APPLE)
1675 return "b110924c4af6e87232249ea2a564f0e4";
1677 return "d1decde2de1c07b5274cc8cb44f92427";
1680#if BUILDFLAG(IS_APPLE)
1681 return "6eef7237f7591f07616e238422086737";
1683 return "09152e25e51fa8ca31fc28d0937bf477";
1686 const char* no_smoothtext_checksum = []() {
1688#if BUILDFLAG(IS_WIN)
1689 return "04dcf7d221437081034ca1152c717a8a";
1690#elif BUILDFLAG(IS_APPLE)
1691 return "8c99ca392ecff724da0d04b17453a45a";
1693 return "cd5bbe9407c3fcc85d365172a9a55abd";
1696#if BUILDFLAG(IS_APPLE)
1697 return "6eef7237f7591f07616e238422086737";
1699 return "6dec98c848028fa4be3ad38d6782e304";
1703 TestRenderPageBitmapWithFlags(page,
FPDF_LCD_TEXT, lcd_text_checksum);
1705 no_smoothtext_checksum);
1710 no_smoothtext_checksum);
1718#define MAYBE_LargeImageDoesNotRenderBlank LargeImageDoesNotRenderBlank
1720#define MAYBE_LargeImageDoesNotRenderBlank DISABLED_LargeImageDoesNotRenderBlank
1723 static const char kChecksum[] =
"a6056db6961f4e65c42ab2e246171fe1";
1725 ASSERT_TRUE(OpenDocument(
"bug_1646.pdf"));
1726 FPDF_PAGE page = LoadPage(0);
1729 constexpr int kWidth = 40000;
1730 constexpr int kHeight = 100;
1731 TestRenderPageBitmapWithMatrix(page, kWidth, kHeight, {1000, 0, 0, 1, 0, 0},
1732 {0, 0, kWidth, kHeight}, kChecksum);
1737#if BUILDFLAG(IS_WIN)
1738TEST_F(FPDFViewEmbedderTest, FPDFRenderPageEmf) {
1739 ASSERT_TRUE(OpenDocument(
"rectangles.pdf"));
1740 FPDF_PAGE page = LoadPage(0);
1743 std::vector<uint8_t> emf_normal = RenderPageWithFlagsToEmf(page, 0);
1744 EXPECT_EQ(3772u, emf_normal.size());
1747 std::vector<uint8_t> emf_reverse_byte_order =
1748 RenderPageWithFlagsToEmf(page, FPDF_REVERSE_BYTE_ORDER);
1749 EXPECT_EQ(emf_normal, emf_reverse_byte_order);
1754class PostScriptRenderEmbedderTestBase :
public FPDFViewEmbedderTest {
1756 ~PostScriptRenderEmbedderTestBase() override =
default;
1759 void TearDown() override {
1760 FPDF_SetPrintMode(FPDF_PRINTMODE_EMF);
1761 FPDFViewEmbedderTest::TearDown();
1765class PostScriptLevel2EmbedderTest :
public PostScriptRenderEmbedderTestBase {
1767 PostScriptLevel2EmbedderTest() =
default;
1768 ~PostScriptLevel2EmbedderTest() override =
default;
1772 void SetUp() override {
1773 FPDFViewEmbedderTest::SetUp();
1774 FPDF_SetPrintMode(FPDF_PRINTMODE_POSTSCRIPT2);
1778class PostScriptLevel3EmbedderTest :
public PostScriptRenderEmbedderTestBase {
1780 PostScriptLevel3EmbedderTest() =
default;
1781 ~PostScriptLevel3EmbedderTest() override =
default;
1785 void SetUp() override {
1786 FPDFViewEmbedderTest::SetUp();
1787 FPDF_SetPrintMode(FPDF_PRINTMODE_POSTSCRIPT3);
1791TEST_F(PostScriptLevel2EmbedderTest, Rectangles) {
1792 ASSERT_TRUE(OpenDocument(
"rectangles.pdf"));
1793 FPDF_PAGE page = LoadPage(0);
1796 std::vector<uint8_t> emf_normal = RenderPageWithFlagsToEmf(page, 0);
1797 std::string ps_data = GetPostScriptFromEmf(emf_normal);
1798 EXPECT_STREQ(kExpectedRectanglePostScript, ps_data.c_str());
1801 std::vector<uint8_t> emf_reverse_byte_order =
1802 RenderPageWithFlagsToEmf(page, FPDF_REVERSE_BYTE_ORDER);
1803 EXPECT_EQ(emf_normal, emf_reverse_byte_order);
1808TEST_F(PostScriptLevel3EmbedderTest, Rectangles) {
1809 ASSERT_TRUE(OpenDocument(
"rectangles.pdf"));
1810 FPDF_PAGE page = LoadPage(0);
1813 std::vector<uint8_t> emf_normal = RenderPageWithFlagsToEmf(page, 0);
1814 std::string ps_data = GetPostScriptFromEmf(emf_normal);
1815 EXPECT_STREQ(kExpectedRectanglePostScript, ps_data.c_str());
1818 std::vector<uint8_t> emf_reverse_byte_order =
1819 RenderPageWithFlagsToEmf(page, FPDF_REVERSE_BYTE_ORDER);
1820 EXPECT_EQ(emf_normal, emf_reverse_byte_order);
1825TEST_F(PostScriptLevel2EmbedderTest, Image) {
1826 const char kExpected[] =
1829 "/im/initmatrix load def\n"
1830 "/n/newpath load def/m/moveto load def/l/lineto load def/c/curveto load "
1831 "def/h/closepath load def\n"
1832 "/f/fill load def/F/eofill load def/s/stroke load def/W/clip load "
1833 "def/W*/eoclip load def\n"
1834 "/rg/setrgbcolor load def/k/setcmykcolor load def\n"
1835 "/J/setlinecap load def/j/setlinejoin load def/w/setlinewidth load "
1836 "def/M/setmiterlimit load def/d/setdash load def\n"
1837 "/q/gsave load def/Q/grestore load def/iM/imagemask load def\n"
1838 "/Tj/show load def/Ff/findfont load def/Fs/scalefont load def/Sf/setfont "
1840 "/cm/concat load def/Cm/currentmatrix load def/mx/matrix load "
1841 "def/sm/setmatrix load def\n"
1842 "0 792 m 0 0 l 612 0 l 612 792 l 0 792 l h W n\n"
1844 "0 792 m 0 0 l 612 0 l 612 792 l 0 792 l h W n\n"
1848 "281 106.7 m 331 106.7 l 331 56.7 l 281 56.7 l 281 106.7 l h W* n\n"
1850 "[49.9 0 0 -50 281.1 106.6]cm 50 50 8[50 0 0 -50 0 "
1851 "50]currentfile/ASCII85Decode filter /DCTDecode filter false 3 "
1853 "s4IA0!\"_al8O`[\\!<<*#!!*'\"s4[N@!!ic5#6k>;#6tJ?#m^kH'FbHY$Odmc'+Yct)"
1855 ",VCGe+tOrY*%3`p/2/e81c-:%3B]>W4>&EH1B6)/"
1856 "6NIK\"#n.1M(_$ok1*IV\\1,:U?1,:U?1,:U?\r\n"
1857 "1,:U?1,:U?1,:U?1,:U?1,:U?1,:U?1,:U?1,:U?1,:U?1,AmF!\"fJ:1&s'3!?qLF&HMtG!"
1859 "*rl9A\"T\\W)!<E3$z!!!!\"!WrQ/\"pYD?$4HmP!4<@<!W`B*!X&T/"
1860 "\"U\"r.!!.KK!WrE*&Hrdj0gQ!W\r\n"
1861 ";.0\\RE>10ZOeE%*6F\"?A;UOtZ1LbBV#mqFa(`=5<-7:2j.Ps\"@2`NfY6UX@47n?3D;"
1863 "@q9._B4u!oF*)PJGBeCZK7nr5LPUeEP*;,qQC!u,R\\HRQV5C/"
1864 "hWN*81['d?O\\@K2f_o0O6a2lBF\r\n"
1865 "daQ^rf%8R-g>V&OjQ5OekiqC&o(2MHp@n@XqZ\"J6*ru?D!<E3%!<E3%!<<*\"!!!!\"!"
1867 "$4HmP!4<C=!W`?*\"9Sc3\"U\"r.!<RHF!<N?8\"9fr'\"qj4!#@VTc+u4]T'LIqUZ,$_"
1869 "(*k`q-1Mcg)&ahL-n-W'2E*TU3^Z;(7Rp!@8lJ\\h<``C+>%;)SAnPdkC3+K>G'A1VH@gd&"
1871 "M2II[Pa.Q$R$jD;USO``Vl6SpZEppG[^WcW]#)A'`Q#s>ai`&\\eCE.%f\\,!<j5f="
1873 "p@n@XqZ#7L$j-M1!YGMH!'^JZre`+s!fAD!!fAD!!fAD!!fAD!!fAD!!fAD!!fAD!!fAD!!"
1875 "!fAD!!fAD!!fAD!!fAD!!fAD!!fAD!&-(;~>\n"
1887 ASSERT_TRUE(OpenDocument(
"tagged_alt_text.pdf"));
1888 FPDF_PAGE page = LoadPage(0);
1891 std::vector<uint8_t> emf = RenderPageWithFlagsToEmf(page, 0);
1892 std::string ps_data = GetPostScriptFromEmf(emf);
1893 EXPECT_STREQ(kExpected, ps_data.c_str());
1898TEST_F(PostScriptLevel3EmbedderTest, Image) {
1899 const char kExpected[] = R"(
1900save
1901/im/initmatrix load def
1902/n/newpath load def/m/moveto load def/l/lineto load def/c/curveto load def/h/closepath load def
1903/f/fill load def/F/eofill load def/s/stroke load def/W/clip load def/W*/eoclip load def
1904/rg/setrgbcolor load def/k/setcmykcolor load def
1905/J/setlinecap load def/j/setlinejoin load def/w/setlinewidth load def/M/setmiterlimit load def/d/setdash load def
1906/q/gsave load def/Q/grestore load def/iM/imagemask load def
1907/Tj/show load def/Ff/findfont load def/Fs/scalefont load def/Sf/setfont load def
1908/cm/concat load def/Cm/currentmatrix load def/mx/matrix load def/sm/setmatrix load def
19090 792 m 0 0 l 612 0 l 612 792 l 0 792 l h W n
1910q
19110 792 m 0 0 l 612 0 l 612 792 l 0 792 l h W n
1912q
1913Q
1914q
1915281 106.7 m 331 106.7 l 331 56.7 l 281 56.7 l 281 106.7 l h W* n
1916q
1917[49.9 0 0 -50 281.1 106.6]cm 50 50 8[50 0 0 -50 0 50]currentfile/ASCII85Decode filter /FlateDecode filter false 3 colorimage
1918Gb"0;0`_7S!5bE%:[N')TE"rlzGQSs[!!*~>
1919Q
1920Q
1921q
1922q
1923Q
1924Q
1925Q
1926Q
1927
1928restore
1929)";
1931 ASSERT_TRUE(OpenDocument(
"tagged_alt_text.pdf"));
1932 FPDF_PAGE page = LoadPage(0);
1935 std::vector<uint8_t> emf = RenderPageWithFlagsToEmf(page, 0);
1936 std::string ps_data = GetPostScriptFromEmf(emf);
1937 EXPECT_STREQ(kExpected, ps_data.c_str());
1942TEST_F(FPDFViewEmbedderTest, ImageMask) {
1943 ASSERT_TRUE(OpenDocument(
"bug_674771.pdf"));
1944 FPDF_PAGE page = LoadPage(0);
1948 FPDF_SetPrintMode(FPDF_PRINTMODE_EMF_IMAGE_MASKS);
1949 std::vector<uint8_t> emf_image_masks = RenderPageWithFlagsToEmf(page, 0);
1952 FPDF_SetPrintMode(FPDF_PRINTMODE_EMF);
1953 std::vector<uint8_t> emf_normal = RenderPageWithFlagsToEmf(page, 0);
1955 EXPECT_LT(emf_image_masks.size(), emf_normal.size());
1962 ASSERT_TRUE(OpenDocument(
"two_signatures.pdf"));
1965 unsigned long size = FPDF_GetTrailerEnds(document(),
nullptr, 0);
1966 const std::vector<
unsigned int> kExpectedEnds{633, 1703, 2781};
1967 ASSERT_EQ(kExpectedEnds.size(), size);
1968 std::vector<
unsigned int> ends(size);
1969 ASSERT_EQ(size, FPDF_GetTrailerEnds(document(), ends.data(), size));
1970 ASSERT_EQ(kExpectedEnds, ends);
1978 size = FPDF_GetTrailerEnds(document(), ends.data(), ends.size());
1979 ASSERT_EQ(kExpectedEnds.size(), size);
1980 EXPECT_EQ(0U, ends[0]);
1981 EXPECT_EQ(1U, ends[1]);
1986 ASSERT_TRUE(OpenDocument(
"hello_world.pdf"));
1989 unsigned long size = FPDF_GetTrailerEnds(document(),
nullptr, 0);
1990 const std::vector<
unsigned int> kExpectedEnds{840};
1991 ASSERT_EQ(kExpectedEnds.size(), size);
1992 std::vector<
unsigned int> ends(size);
1993 ASSERT_EQ(size, FPDF_GetTrailerEnds(document(), ends.data(), size));
1994 ASSERT_EQ(kExpectedEnds, ends);
1999 ASSERT_TRUE(OpenDocument(
"annotation_stamp_with_ap.pdf"));
2002 unsigned long size = FPDF_GetTrailerEnds(document(),
nullptr, 0);
2003 const std::vector<
unsigned int> kExpectedEnds{441, 7945, 101719};
2004 ASSERT_EQ(kExpectedEnds.size(), size);
2005 std::vector<
unsigned int> ends(size);
2006 ASSERT_EQ(size, FPDF_GetTrailerEnds(document(), ends.data(), size));
2007 ASSERT_EQ(kExpectedEnds, ends);
2012 FileAccessForTesting file_acc(
"linearized.pdf");
2018 SetDocumentFromAvail();
2019 ASSERT_TRUE(document());
2022 unsigned long size = FPDF_GetTrailerEnds(document(),
nullptr, 0);
2023 const std::vector<
unsigned int> kExpectedEnds{474, 11384};
2024 ASSERT_EQ(kExpectedEnds.size(), size);
2025 std::vector<
unsigned int> ends(size);
2026 ASSERT_EQ(size, FPDF_GetTrailerEnds(document(), ends.data(), size));
2027 ASSERT_EQ(kExpectedEnds, ends);
2032 ASSERT_TRUE(OpenDocument(
"trailer_end_trailing_space.pdf"));
2034 unsigned long size = FPDF_GetTrailerEnds(document(),
nullptr, 0);
2035 const std::vector<
unsigned int> kExpectedEnds{1193};
2038 ASSERT_EQ(kExpectedEnds.size(), size);
2039 std::vector<
unsigned int> ends(size);
2040 ASSERT_EQ(size, FPDF_GetTrailerEnds(document(), ends.data(), size));
2041 EXPECT_EQ(kExpectedEnds, ends);
2045 ASSERT_TRUE(OpenDocument(
"simple_xfa.pdf"));
2047 FPDF_PAGE page = LoadPage(0);
2056#if defined(PDF_USE_SKIA)
2057TEST_F(FPDFViewEmbedderTest, RenderPageToSkp) {
2058 if (!CFX_DefaultRenderDevice::UseSkiaRenderer()) {
2059 GTEST_SKIP() <<
"FPDF_RenderPageSkp() only makes sense with Skia";
2062 ASSERT_TRUE(OpenDocument(
"rectangles.pdf"));
2064 FPDF_PAGE page = LoadPage(0);
2067 TestRenderPageSkp(page, pdfium::RectanglesChecksum());
2072TEST_F(FPDFViewEmbedderTest, RenderXfaPageToSkp) {
2073 if (!CFX_DefaultRenderDevice::UseSkiaRenderer()) {
2074 GTEST_SKIP() <<
"FPDF_RenderPageSkp() only makes sense with Skia";
2077 ASSERT_TRUE(OpenDocument(
"simple_xfa.pdf"));
2079 FPDF_PAGE page = LoadPage(0);
2083 TestRenderPageSkp(page, pdfium::kBlankPage612By792Checksum);
2088TEST_F(FPDFViewEmbedderTest, Bug2087) {
2089 FPDF_DestroyLibrary();
2091 std::string agg_checksum;
2093 FPDF_LIBRARY_CONFIG config = {
2095 .m_pUserFontPaths =
nullptr,
2096 .m_pIsolate =
nullptr,
2097 .m_v8EmbedderSlot = 0,
2098 .m_pPlatform =
nullptr,
2099 .m_RendererType = FPDF_RENDERERTYPE_AGG,
2101 FPDF_InitLibraryWithConfig(&config);
2103 ASSERT_TRUE(OpenDocument(
"rectangles.pdf"));
2104 FPDF_PAGE page = LoadPage(0);
2105 ScopedFPDFBitmap bitmap = RenderPage(page);
2106 agg_checksum = HashBitmap(bitmap.get());
2109 FPDF_DestroyLibrary();
2112 std::string skia_checksum;
2114 FPDF_LIBRARY_CONFIG config = {
2116 .m_pUserFontPaths =
nullptr,
2117 .m_pIsolate =
nullptr,
2118 .m_v8EmbedderSlot = 0,
2120 FPDF_InitLibraryWithConfig(&config);
2122 ASSERT_TRUE(OpenDocument(
"rectangles.pdf"));
2123 FPDF_PAGE page = LoadPage(0);
2124 ScopedFPDFBitmap bitmap = RenderPage(page);
2125 skia_checksum = HashBitmap(bitmap.get());
2130 EXPECT_NE(agg_checksum, skia_checksum);
2132 EmbedderTestEnvironment::GetInstance()->TearDown();
2133 EmbedderTestEnvironment::GetInstance()->SetUp();
2138 ASSERT_TRUE(OpenDocument(
"bug_1919.pdf"));
2139 FPDF_PAGE page = LoadPage(0);
2142 const char* checksum = []() {
2143#if BUILDFLAG(IS_WIN)
2144 if (CFX_DefaultRenderDevice::UseSkiaRenderer()) {
2145 return "d97d0a9da6a5955f68a58a3f25466bd7";
2147#elif !BUILDFLAG(IS_APPLE)
2148 if (CFX_DefaultRenderDevice::UseSkiaRenderer()) {
2149 return "ceeb93d2bcdb586d62c95b33cadcd873";
2152 return "5f99e2fa2bad09393d6428e105a83c96";
2160 ASSERT_TRUE(OpenDocument(
"bug_1302355.pdf"));
2161 FPDF_PAGE page = LoadPage(0);
2164 constexpr int kWidth = 200;
2165 constexpr int kHeight = 200;
2169 ScopedFPDFBitmap bitmap(FPDFBitmap_Create(kWidth, kHeight,
true));
2170 FPDFBitmap_FillRect(bitmap.get(), 0, 0, kWidth, kHeight, 0xFFFFFFFF);
2171 FPDF_RenderPageBitmap(bitmap.get(), page, 0, 0,
2172 kWidth, kHeight, 0, 0);
2174 EXPECT_EQ(
"eee4600ac08b458ac7ac2320e225674c", HashBitmap(bitmap.get()));
2180 constexpr int kWidth = 595;
2181 constexpr int kHeight = 842;
2182 constexpr int kStride = kWidth * 3;
2183 std::vector<uint8_t> vec(kStride * kHeight);
2184 ScopedFPDFBitmap bitmap(FPDFBitmap_CreateEx(kWidth, kHeight,
FPDFBitmap_BGR,
2185 vec.data(), kStride));
static bool UseSkiaRenderer()
uint32_t GetParsedPageCountForTesting()
static EmbedderTestEnvironment * GetInstance()
static void CompareBitmap(FPDF_BITMAP bitmap, int expected_width, int expected_height, const char *expected_md5sum)
static int BytesPerPixelForFormat(int format)
void TestRenderPageBitmapWithExternalMemoryAndNoStride(FPDF_PAGE page, int format, const char *expected_checksum)
void TestRenderPageBitmapWithMatrix(FPDF_PAGE page, int bitmap_width, int bitmap_height, const FS_MATRIX &matrix, const FS_RECTF &rect, const char *expected_checksum)
void TestRenderPageBitmapWithInternalMemoryAndStride(FPDF_PAGE page, int format, int bitmap_stride, const char *expected_checksum)
void TestRenderPageBitmapWithInternalMemory(FPDF_PAGE page, int format, const char *expected_checksum)
void TestRenderPageBitmapWithExternalMemory(FPDF_PAGE page, int format, const char *expected_checksum)
void TestRenderPageBitmapWithFlags(FPDF_PAGE page, int flags, const char *expected_checksum)
void SetWholeFileAvailable()
FX_FILEAVAIL * GetFileAvail() const
FPDF_FILEACCESS * GetFileAccess() const
static std::string GetTestFilePath(const std::string &file_name)
void UnsupportedHandler(int type) override
~RecordUnsupportedErrorDelegate() override=default
RecordUnsupportedErrorDelegate()=default
#define PDF_DATA_NOTAVAIL
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_HasTransparency(FPDF_PAGE page)
#define FPDF_UNSP_DOC_PORTABLECOLLECTION
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetLastError()
FPDF_EXPORT void FPDF_CALLCONV FPDF_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_DeviceToPage(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, int rotate, int device_x, int device_y, double *page_x, double *page_y)
FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_LoadCustomDocument(FPDF_FILEACCESS *pFileAccess, FPDF_BYTESTRING password)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_PageToDevice(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, int rotate, double page_x, double page_y, int *device_x, int *device_y)
FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BYTESTRING password)
FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetHeight(FPDF_BITMAP bitmap)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_DocumentHasValidCrossReferenceTable(FPDF_DOCUMENT document)
FPDF_EXPORT float FPDF_CALLCONV FPDF_GetPageHeightF(FPDF_PAGE page)
FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyLibrary()
FPDF_EXPORT int FPDF_CALLCONV FPDF_GetXFAPacketCount(FPDF_DOCUMENT document)
FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_index, double *width, double *height)
FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageWidth(FPDF_PAGE page)
FPDF_EXPORT void FPDF_CALLCONV FPDF_InitLibrary()
FPDF_EXPORT void FPDF_CALLCONV FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, int rotate, int flags)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetPageBoundingBox(FPDF_PAGE page, FS_RECTF *rect)
FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top, int width, int height, FPDF_DWORD color)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetPageSizeByIndexF(FPDF_DOCUMENT document, int page_index, FS_SIZEF *size)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetXFAPacketContent(FPDF_DOCUMENT document, int index, void *buffer, unsigned long buflen, unsigned long *out_buflen)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetXFAPacketName(FPDF_DOCUMENT document, int index, void *buffer, unsigned long buflen)
FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page)
FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetWidth(FPDF_BITMAP bitmap)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetTrailerEnds(FPDF_DOCUMENT document, unsigned int *buffer, unsigned long length)
FPDF_EXPORT float FPDF_CALLCONV FPDF_GetPageWidthF(FPDF_PAGE page)
#define MAYBE_LargeImageDoesNotRenderBlank
TEST_F(FPDFViewEmbedderTest, DeviceCoordinatesToPageCoordinates)
#define FPDF_RENDER_LIMITEDIMAGECACHE
#define FPDF_RENDER_NO_SMOOTHTEXT
#define FPDF_RENDER_NO_SMOOTHIMAGE
#define FPDF_REVERSE_BYTE_ORDER
#define FPDF_POLICY_MACHINETIME_ACCESS
#define FPDF_RENDER_FORCEHALFTONE
#define FPDF_NO_NATIVETEXT
#define FPDF_RENDER_NO_SMOOTHPATH
TEST(FXCRYPT, MD5GenerateEmtpyData)
std::string GetPlatformString(FPDF_WIDESTRING wstr)
const char kBlankPage612By792Checksum[]
const char * RectanglesChecksum()
const char * HelloWorldChecksum()
const char * ManyRectanglesChecksum()
void(* AddSegment)(struct _FX_DOWNLOADHINTS *pThis, size_t offset, size_t size)