forked from CinemaMod/java-cef
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCefPrintHandlerAdapter.java
More file actions
60 lines (51 loc) · 2.02 KB
/
CefPrintHandlerAdapter.java
File metadata and controls
60 lines (51 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
package org.cef.handler;
import org.cef.browser.CefBrowser;
import org.cef.callback.CefNativeAdapter;
import org.cef.callback.CefPrintDialogCallback;
import org.cef.callback.CefPrintJobCallback;
import org.cef.misc.CefPrintSettings;
import java.awt.Dimension;
/**
* An abstract adapter class for receiving print events on Linux.
* The methods in this class are empty.
* This class exists as convenience for creating handler objects.
*/
public abstract class CefPrintHandlerAdapter extends CefNativeAdapter implements CefPrintHandler {
@Override
public void onPrintStart(CefBrowser browser) {
// The default implementation does nothing
}
@Override
public void onPrintSettings(
CefBrowser browser, CefPrintSettings settings, boolean getDefaults) {
// The default implementation does nothing
}
@Override
public boolean onPrintDialog(
CefBrowser browser, boolean hasSelection, CefPrintDialogCallback callback) {
// The default implementation does nothing
return false;
}
@Override
public boolean onPrintJob(CefBrowser browser, String documentName, String pdfFilePath,
CefPrintJobCallback callback) {
// The default implementation does nothing
return false;
}
@Override
public void onPrintReset(CefBrowser browser) {
// The default implementation does nothing
}
@Override
public Dimension getPdfPaperSize(CefBrowser browser, int deviceUnitsPerInch) {
// default implementation is A4 letter size
// @ 300 DPI, A4 is 2480 x 3508
// @ 150 DPI, A4 is 1240 x 1754
int adjustedWidth = (int) (((double) deviceUnitsPerInch / 300d) * 2480d);
int adjustedHeight = (int) (((double) deviceUnitsPerInch / 300d) * 3508d);
return new Dimension(adjustedWidth, adjustedHeight);
}
}