-
Notifications
You must be signed in to change notification settings - Fork 0
/
chtmltopdf_handler.h
81 lines (52 loc) · 2.76 KB
/
chtmltopdf_handler.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef CEF_CHTMLTOPDFHANDLER_H
#define CEF_CHTMLTOPDFHANDLER_H
#include <list>
#include "include/cef_client.h"
class CHtmlToPdfHandler : public CefClient,
public CefDisplayHandler,
public CefLifeSpanHandler,
public CefLoadHandler,
public CefPdfPrintCallback,
public CefRenderHandler {
public:
// Provide access to the single global instance of this object.
static CHtmlToPdfHandler* GetInstance();
virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int httpStatusCode) override;
virtual void OnPdfPrintFinished(const CefString &path, bool ok);
virtual void OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects,
const void *buffer, int width, int height);
virtual bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect);
virtual bool GetScreenPoint(CefRefPtr<CefBrowser> browser, int viewX, int viewY, int &screenX,
int &screenY) override;
virtual bool GetRootScreenRect(CefRefPtr<CefBrowser> browser, CefRect &rect) override;
void setFileName(std::string str);
CHtmlToPdfHandler();
~CHtmlToPdfHandler();
virtual void OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, ErrorCode errorCode,
const CefString &errorText, const CefString &failedUrl) override;
virtual void OnLoadStart(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefLoadHandler::TransitionType transition_type) override;
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
virtual bool DoClose(CefRefPtr<CefBrowser> browser) override;
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
void CloseAllBrowsers(bool force_close);
void setPageSize(int height, int width);
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler();
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler();
virtual CefRefPtr<CefLoadHandler> GetLoadHandler();
virtual CefRefPtr<CefRenderHandler> GetRenderHandler();
void PrintStart(CefRefPtr<CefBrowser> browser);
void setPrintOnLoad(bool printOnLoad);
virtual bool OnConsoleMessage(CefRefPtr<CefBrowser> browser, const CefString &message, const CefString &source,
int line) override;
private:
typedef std::list<CefRefPtr<CefBrowser> > BrowserList;
BrowserList browser_list_;
int page_height;
int page_width;
bool is_closing_;
CefRefPtr<CefBrowser> browser_;
std::string pdf_file_name;
bool printOnLoad;
IMPLEMENT_REFCOUNTING(CHtmlToPdfHandler);
};
#endif //CEF_CHTMLTOPDFHANDLER_H