Add options to custom print settings in printToPDF API.

This commit is contained in:
Haojian Wu 2015-05-31 14:52:41 +08:00
parent 9cf9229308
commit ce8bbb689c
6 changed files with 40 additions and 11 deletions

View file

@ -16,6 +16,7 @@
#include "native_mate/callback.h"
#include "native_mate/constructor.h"
#include "native_mate/dictionary.h"
#include "printing/print_job_constants.h"
#include "ui/gfx/geometry/rect.h"
#include "atom/common/node_includes.h"
@ -430,8 +431,13 @@ void Window::Print(mate::Arguments* args) {
window_->Print(settings.silent, settings.print_background);
}
void Window::PrintToPDF() {
window_->PrintToPDF();
void Window::PrintToPDF(mate::Arguments* args) {
mate::Dictionary options;
if (args->Length() == 1 && !args->GetNext(&options)) {
args->ThrowError();
return;
}
window_->PrintToPDF(options);
}
void Window::SetProgressBar(double progress) {

View file

@ -132,7 +132,7 @@ class Window : public mate::EventEmitter,
bool IsDocumentEdited();
void CapturePage(mate::Arguments* args);
void Print(mate::Arguments* args);
void PrintToPDF();
void PrintToPDF(mate::Arguments* args);
void SetProgressBar(double progress);
void SetOverlayIcon(const gfx::Image& overlay,
const std::string& description);

View file

@ -265,9 +265,9 @@ void NativeWindow::Print(bool silent, bool print_background) {
PrintNow(silent, print_background);
}
void NativeWindow::PrintToPDF() {
void NativeWindow::PrintToPDF(const mate::Dictionary& options) {
printing::PrintPreviewMessageHandler::FromWebContents(GetWebContents())->
HandleGetPreview(NULL);
HandleGetPreview(options);
}
void NativeWindow::ShowDefinitionForSelection() {

View file

@ -158,7 +158,7 @@ class NativeWindow : public CommonWebContentsDelegate,
virtual void Print(bool silent, bool print_background);
// Print current page as PDF.
virtual void PrintToPDF();
virtual void PrintToPDF(const mate::Dictionary& options);
// Show popup dictionary.
virtual void ShowDefinitionForSelection();