Commit 145d499a authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Split printing code from PDFiumEngine into PDFiumPrint.

Change-Id: I431828148e9f93eadd290493e848331f996cbd69
Reviewed-on: https://chromium-review.googlesource.com/1043657Reviewed-by: default avatarHenrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556147}
parent a680f208
......@@ -92,6 +92,8 @@ if (enable_pdf) {
"pdfium/pdfium_mem_buffer_file_write.h",
"pdfium/pdfium_page.cc",
"pdfium/pdfium_page.h",
"pdfium/pdfium_print.cc",
"pdfium/pdfium_print.h",
"pdfium/pdfium_range.cc",
"pdfium/pdfium_range.h",
]
......
This diff is collapsed.
......@@ -11,7 +11,6 @@
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/macros.h"
......@@ -21,6 +20,7 @@
#include "pdf/pdf_engine.h"
#include "pdf/pdfium/pdfium_form_filler.h"
#include "pdf/pdfium/pdfium_page.h"
#include "pdf/pdfium/pdfium_print.h"
#include "pdf/pdfium/pdfium_range.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/buffer_dev.h"
......@@ -316,12 +316,6 @@ class PDFiumEngine : public PDFEngine,
bool ExtendSelection(int page_index, int char_index);
FPDF_DOCUMENT CreateSinglePageRasterPdf(
double source_page_width,
double source_page_height,
const PP_PrintSettings_Dev& print_settings,
PDFiumPage* page_to_print);
pp::Buffer_Dev PrintPagesAsRasterPDF(
const PP_PrintPageNumberRange_Dev* page_ranges,
uint32_t page_range_count,
......@@ -331,20 +325,6 @@ class PDFiumEngine : public PDFEngine,
uint32_t page_range_count,
const PP_PrintSettings_Dev& print_settings);
bool FlattenPrintData(FPDF_DOCUMENT doc);
pp::Buffer_Dev GetPrintData(FPDF_DOCUMENT doc);
pp::Buffer_Dev GetFlattenedPrintData(FPDF_DOCUMENT doc);
// Perform N-up PDF generation from |doc| based on the parameters in
// |print_settings|. On success, the returned buffer contains the N-up version
// of |doc|. On failure, the returned buffer is empty.
pp::Buffer_Dev NupPdfToPdf(FPDF_DOCUMENT doc,
const PP_PrintSettings_Dev& print_settings);
void FitContentsToPrintableAreaIfRequired(
FPDF_DOCUMENT doc,
const PP_PrintSettings_Dev& print_settings);
// Checks if |page| has selected text in a form element. If so, sets that as
// the plugin's text selection.
void SetFormSelectedText(FPDF_FORMHANDLE form_handle, FPDF_PAGE page);
......@@ -447,10 +427,6 @@ class PDFiumEngine : public PDFEngine,
// triggers as necessary.
void SetCurrentPage(int index);
// Transform |page| contents to fit in the selected printer paper size.
void TransformPDFPageForPrinting(FPDF_PAGE page,
const PP_PrintSettings_Dev& print_settings);
void DrawPageShadow(const pp::Rect& page_rect,
const pp::Rect& shadow_rect,
const pp::Rect& clip_rect,
......@@ -695,6 +671,7 @@ class PDFiumEngine : public PDFEngine,
bool edit_mode_;
PDFiumFormFiller form_filler_;
PDFiumPrint print_;
DISALLOW_COPY_AND_ASSIGN(PDFiumEngine);
};
......
This diff is collapsed.
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PDF_PDFIUM_PDFIUM_PRINT_H_
#define PDF_PDFIUM_PDFIUM_PRINT_H_
#include <vector>
#include "base/macros.h"
#include "ppapi/cpp/dev/buffer_dev.h"
#include "third_party/pdfium/public/fpdfview.h"
struct PP_PrintSettings_Dev;
struct PP_PrintPageNumberRange_Dev;
namespace chrome_pdf {
class PDFiumEngine;
class PDFiumPage;
class PDFiumPrint {
public:
explicit PDFiumPrint(PDFiumEngine* engine);
~PDFiumPrint();
static std::vector<uint32_t> GetPageNumbersFromPrintPageNumberRange(
const PP_PrintPageNumberRange_Dev* page_ranges,
uint32_t page_range_count);
pp::Buffer_Dev PrintPagesAsRasterPDF(
const PP_PrintPageNumberRange_Dev* page_ranges,
uint32_t page_range_count,
const PP_PrintSettings_Dev& print_settings);
pp::Buffer_Dev PrintPagesAsPDF(const PP_PrintPageNumberRange_Dev* page_ranges,
uint32_t page_range_count,
const PP_PrintSettings_Dev& print_settings);
private:
FPDF_DOCUMENT CreateSinglePageRasterPdf(
double source_page_width,
double source_page_height,
const PP_PrintSettings_Dev& print_settings,
PDFiumPage* page_to_print);
// Perform N-up PDF generation from |doc| based on the parameters in
// |print_settings|. On success, the returned buffer contains the N-up version
// of |doc|. On failure, the returned buffer is empty.
pp::Buffer_Dev NupPdfToPdf(FPDF_DOCUMENT doc,
const PP_PrintSettings_Dev& print_settings);
bool FlattenPrintData(FPDF_DOCUMENT doc);
pp::Buffer_Dev GetPrintData(FPDF_DOCUMENT doc);
pp::Buffer_Dev GetFlattenedPrintData(FPDF_DOCUMENT doc);
PDFiumEngine* const engine_;
DISALLOW_COPY_AND_ASSIGN(PDFiumPrint);
};
} // namespace chrome_pdf
#endif // PDF_PDFIUM_PDFIUM_PRINT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment