summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfppo_embeddertest.cpp
diff options
context:
space:
mode:
authorxlou <xlou@chromium.org>2018-01-31 22:24:05 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-31 22:24:05 +0000
commit66ce22c6cdb38ca5941c175aea371df92ae9cb8b (patch)
tree4557f587133e3005bde76d9b4fc12d19bd899b74 /fpdfsdk/fpdfppo_embeddertest.cpp
parentbb04c59ec30b00cae6c902fa8bc128220bcff4df (diff)
downloadpdfium-66ce22c6cdb38ca5941c175aea371df92ae9cb8b.tar.xz
Experimental API for N-up feature support for print
FPDF_ImportNPagesToOne function is added to support N-up feature for print. If numPagesOnXAxis * numPagesOnYAxis == 0 Returns a nullptr. If numPagesOnXAxis * numPagesOnYAxis == 1 Creates a new PDF document, and import one page to each output page of the PDF document If numPagesOnXAxis * numPagesOnYAxis > 1, FPDF_ImportNPagesToOne imports multiple pages onto the same page. This feature is intended for print pipeline to use. Change-Id: Iec1afffe377ff9b7fef3cb33414b29b324154fa4 Reviewed-on: https://pdfium-review.googlesource.com/22050 Commit-Queue: Shirleen Lou <xlou@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfppo_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdfppo_embeddertest.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfppo_embeddertest.cpp b/fpdfsdk/fpdfppo_embeddertest.cpp
index c642b71ac0..deb87b533a 100644
--- a/fpdfsdk/fpdfppo_embeddertest.cpp
+++ b/fpdfsdk/fpdfppo_embeddertest.cpp
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <string>
+#include "public/cpp/fpdf_deleters.h"
#include "public/fpdf_edit.h"
#include "public/fpdf_ppo.h"
#include "public/fpdf_save.h"
@@ -57,6 +58,47 @@ TEST_F(FPDFPPOEmbeddertest, ImportPages) {
UnloadPage(page);
}
+TEST_F(FPDFPPOEmbeddertest, ImportNPages) {
+ ASSERT_TRUE(OpenDocument("hello_world_multi_pages.pdf"));
+
+ std::unique_ptr<void, FPDFDocumentDeleter> output_doc_2up(
+ FPDF_ImportNPagesToOne(document(), 612, 792, 2, 1));
+ ASSERT_TRUE(output_doc_2up);
+ EXPECT_EQ(3, FPDF_GetPageCount(output_doc_2up.get()));
+ std::unique_ptr<void, FPDFDocumentDeleter> output_doc_5up(
+ FPDF_ImportNPagesToOne(document(), 612, 792, 5, 1));
+ ASSERT_TRUE(output_doc_5up);
+ EXPECT_EQ(1, FPDF_GetPageCount(output_doc_5up.get()));
+ std::unique_ptr<void, FPDFDocumentDeleter> output_doc_8up(
+ FPDF_ImportNPagesToOne(document(), 792, 612, 8, 1));
+ ASSERT_TRUE(output_doc_8up);
+ EXPECT_EQ(1, FPDF_GetPageCount(output_doc_8up.get()));
+ std::unique_ptr<void, FPDFDocumentDeleter> output_doc_128up(
+ FPDF_ImportNPagesToOne(document(), 792, 612, 128, 1));
+ ASSERT_TRUE(output_doc_128up);
+ EXPECT_EQ(1, FPDF_GetPageCount(output_doc_128up.get()));
+}
+
+TEST_F(FPDFPPOEmbeddertest, BadNupParams) {
+ ASSERT_TRUE(OpenDocument("hello_world_multi_pages.pdf"));
+
+ FPDF_DOCUMENT output_doc_zero_row =
+ FPDF_ImportNPagesToOne(document(), 612, 792, 0, 3);
+ ASSERT_FALSE(output_doc_zero_row);
+ FPDF_DOCUMENT output_doc_zero_col =
+ FPDF_ImportNPagesToOne(document(), 612, 792, 2, 0);
+ ASSERT_FALSE(output_doc_zero_col);
+ FPDF_DOCUMENT output_doc_zero_width =
+ FPDF_ImportNPagesToOne(document(), 0, 792, 2, 1);
+ ASSERT_FALSE(output_doc_zero_width);
+ FPDF_DOCUMENT output_doc_zero_height =
+ FPDF_ImportNPagesToOne(document(), 612, 0, 7, 1);
+ ASSERT_FALSE(output_doc_zero_height);
+}
+
+// TODO(Xlou): Add more tests to check output doc content of
+// FPDF_ImportNPagesToOne()
+
TEST_F(FPDFPPOEmbeddertest, BadRepeatViewerPref) {
ASSERT_TRUE(OpenDocument("repeat_viewer_ref.pdf"));