Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
spajak committed Jun 18, 2017
2 parents ff7c24e + 503173e commit 3bf7d47
Show file tree
Hide file tree
Showing 38 changed files with 530 additions and 425 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/
cef/
.DS_Store
40 changes: 21 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
Changelog
===
### 0.3.0 (2017-06-18)
* Building with CEF 3.3071.1640.g1ebbf3c / Chromium 59.0.3071.82 (Windows, Linux & OS X, 64bit)
* Now possible to build on Mac OS X. Tested on 10.11.6 with XCode ver. 8.2.0. Experimental
* Bug fixes. Code cleanup and better formatting

### 0.2.1 (2016-12-20)
* Allow only specified schemes when in server mode (ie. block file:// access)
* Added option to enable JavaScript --javascript
* Added --file option to load file from command line
* Disabled standard input (use --file instead)
* Added --background option to print html backgrounds
* Bulding with CEF 3.2883.1540.gedbfb20 / Chromium 55.0.2883.59 version (Windows & Linux, 64bit)
* Bulding with CEF 3.2883.1540.gedbfb20 / Chromium 55.0.2883.59 (Windows & Linux, 64bit)
* Allow only specified schemes when in server mode (ie. block `file://` access)
* Added option to enable JavaScript `--javascript`
* Added `--file` option to load file from command line
* Disabled standard input (use `--file` instead)
* Added `--background` option to print html backgrounds

===
### 0.2.0 (2016-11-29)
* Added HTTP server mode (use with --server flag)
* Added configurable --host and --port when running in server mode
* Bulding with CEF 3.2883.1539.gd7f087e / Chromium 55.0.2883.59 (Windows & Linux, 64bit)
* Added HTTP server mode (use with `--server` flag)
* Added configurable `--host` and `--port` options when running in server mode
* Various fixes and improvements
* Bulding with CEF 3.2883.1539.gd7f087e / Chromium 55.0.2883.59 version (Windows & Linux, 64bit)

===
### 0.1.6 (2016-09-21)
* Fix: small improvements to allow building on Linux (tested on Debian 8.5.0 x64)
* Small changes to build using CEF 3.2743.1449.g90ba67d build
* Small improvements to allow building on Linux (tested on Debian 8.5.0 x64)

===
### 0.1.5 (2016-09-15)
* Add: option to set page margin --margin
* Add: option to list available page sizes --list-sizes
* Change: url is now specified with --url option
* Added option to set page margin `--margin`
* Added option to list available page sizes `--list-sizes`
* Changed url to be specified with `--url` option
* Heavy code refractoring

### 0.1.1 (2016-08-06)
* Add: some paper sizes: US, ANSI and photo
* Add: help message
* Fix: url load error handling
* Added some more paper sizes: US, ANSI and photo
* Added help message
* Fixed url load error handling

### 0.1.0 (2016-08-03)
* Initial release. Working version :)
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@

cmake_minimum_required(VERSION 2.8.12.1)

set(USE_SANDBOX OFF)
set(USE_ATL OFF)
if(APPLE)
set(PROJECT_ARCH x86_64)
endif()

# Only generate Debug and Release configuration types.
set(CMAKE_CONFIGURATION_TYPES Debug Release)
Expand Down Expand Up @@ -156,7 +157,7 @@ set_property(GLOBAL PROPERTY OS_FOLDERS ON)
# files as an example.
# D. Comment in these lines:
#
set(CEF_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/cef")
set(CEF_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/cef" CACHE STRING "Directory where CEF release is located")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake")

# Example 3: The binary distribution is in a separate directory from your
Expand Down Expand Up @@ -200,14 +201,15 @@ find_package(CEF REQUIRED)
# directory.
add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)

set(USE_SANDBOX OFF)
set(USE_ATL OFF)

include_directories("asio")
add_definitions(-DASIO_STANDALONE -DASIO_NO_TYPEID)

# Include application targets.
# Comes from the <target>/CMakeLists.txt file in the current directory.
# TODO: Change these lines to match your project target when you copy this file.
#add_subdirectory(cefclient)
#add_subdirectory(cefsimple)
add_subdirectory(src)

# Display configuration settings.
Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ In addition to POSTing content inside the request body, special HTTP header `Con

### Building

In order to build, [CEF build distribution files](http://opensource.spotify.com/cefbuilds/index.html) must be placed in cef/ subdirectory. `cef-pdf` should compile without problems with cmake/ninja on Windows 7+ and Linux (tested on Debian 8.5.0 x64), using decent C++11 compiler. Mac OS X needs some work (contributors welcome).

### TODO

- Mac OS X versions
- Improve performance
In order to build, [CEF build distribution files](http://opensource.spotify.com/cefbuilds/index.html) must be placed in cef/ subdirectory. `cef-pdf` should compile without problems with cmake/ninja on Windows (7, x64), Linux (tested on Debian 8.5.0, x64) and Mac OS X (10.11.6) using decent C++11 compiler.

### License

Expand Down
32 changes: 32 additions & 0 deletions resource/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cef.cef-pdf.helper</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.9.0</string>
<key>LSUIElement</key>
<string>1</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>© 2017, cef-pdf</string>
</dict>
</plist>
File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions resource/helper-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cef.cefsimple.helper</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>LSFileQuarantineEnabled</key>
<true/>
<key>LSMinimumSystemVersion</key>
<string>10.9.0</string>
<key>LSUIElement</key>
<string>1</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>© 2017, cef-pdf</string>
</dict>
</plist>
55 changes: 37 additions & 18 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@
# can be found in the LICENSE file.

#
# Source files.
# Targets and source files.
#

# cef-pdf sources.
set(CEF_TARGET "cef-pdf")
set(CEF_HELPER_TARGET "cef-pdf Helper")

file(GLOB_RECURSE CEFPDF_SRCS "*.cpp")
source_group(cef-pdf FILES ${CEFPDF_SRCS})
set(CEFPDF_HELPER_SRCS ${CEFPDF_SRCS})
list(FILTER CEFPDF_SRCS EXCLUDE REGEX "subprocess\\.cpp$")
list(FILTER CEFPDF_HELPER_SRCS EXCLUDE REGEX "main\\.cpp$")

source_group("${CEF_TARGET}" FILES ${CEFPDF_SRCS})
#source_group("${CEF_HELPER_TARGET}" FILES ${CEFPDF_HELPER_SRCS})

#
# Shared configuration.
#

# Target executable names.
set(CEF_TARGET "cef-pdf")
if(OS_MACOSX)
set(CEF_HELPER_TARGET "cef-pdf Helper")
endif()

# Logical target used to link the libcef library.
ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}")

Expand All @@ -36,8 +37,8 @@ if(OS_LINUX)
add_executable(${CEF_TARGET} ${CEFPDF_SRCS})
SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS} -Wl,--no-fatal-warnings)
target_compile_options(${CEF_TARGET} PRIVATE -fexceptions)
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
target_compile_options(${CEF_TARGET} PUBLIC -fexceptions)

# Set rpath so that libraries can be placed next to the executable.
set_target_properties(${CEF_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN")
Expand Down Expand Up @@ -71,8 +72,9 @@ if(OS_MACOSX)
add_dependencies(${CEF_HELPER_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_HELPER_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
set_target_properties(${CEF_HELPER_TARGET} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/helper-Info.plist
)
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/resource/helper-Info.plist
)
target_compile_options(${CEF_HELPER_TARGET} PUBLIC -fexceptions -Wno-unused-local-typedef)

# Fix the framework rpath in the helper executable.
FIX_MACOSX_HELPER_FRAMEWORK_RPATH(${CEF_HELPER_TARGET})
Expand All @@ -84,8 +86,9 @@ if(OS_MACOSX)
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
set_target_properties(${CEF_TARGET} PROPERTIES
RESOURCE "${CEFPDF_RESOURCES_SRCS}"
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist
)
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/resource/Info.plist
)
target_compile_options(${CEF_TARGET} PUBLIC -fexceptions -Wno-unused-local-typedef)

# Copy files into the main app bundle.
add_custom_command(
Expand All @@ -95,12 +98,15 @@ if(OS_MACOSX)
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CEF_HELPER_APP}"
"${CEF_APP}/Contents/Frameworks/${CEF_HELPER_TARGET}.app"
# Remove helper bundle
COMMAND ${CMAKE_COMMAND} -E remove_directory
"${CEF_HELPER_APP}"
# Copy the CEF framework into the Frameworks directory.
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CEF_BINARY_DIR}/Chromium Embedded Framework.framework"
"${CEF_APP}/Contents/Frameworks/Chromium Embedded Framework.framework"
VERBATIM
)
)

# Fix the framework rpath in the main executable.
FIX_MACOSX_MAIN_FRAMEWORK_RPATH(${CEF_TARGET})
Expand All @@ -122,9 +128,22 @@ if(OS_WINDOWS)
# Executable target.
add_executable(${CEF_TARGET} WIN32 ${CEFPDF_SRCS})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)

list(APPEND CEF_COMPILER_DEFINES
_HAS_EXCEPTIONS=1
)

list(APPEND CEF_CXX_COMPILER_FLAGS
/EHsc
)

list(APPEND CEF_EXE_LINKER_FLAGS
/entry:mainCRTStartup
/subsystem:console
)

SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_TARGET})
target_link_libraries(${CEF_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
target_compile_definitions(${CEF_TARGET} PRIVATE _HAS_EXCEPTIONS=1)

if(USE_SANDBOX)
# Logical target used to link the cef_sandbox library.
Expand All @@ -133,7 +152,7 @@ if(OS_WINDOWS)
endif()

# Add the custom manifest files to the executable.
ADD_WINDOWS_MANIFEST("${CMAKE_CURRENT_SOURCE_DIR}" "${CEF_TARGET}" "exe")
ADD_WINDOWS_MANIFEST("${CMAKE_SOURCE_DIR}/resource" "${CEF_TARGET}" "exe")

# Copy binary and resource files to the target output directory.
COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}")
Expand Down
6 changes: 2 additions & 4 deletions src/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ Client::Client() :
m_settings.command_line_args_disabled = true;

m_windowInfo.windowless_rendering_enabled = true;
m_windowInfo.transparent_painting_enabled = false;

m_browserSettings.windowless_frame_rate = 1;
CefString(&m_browserSettings.default_encoding).FromString(constants::encoding);
m_browserSettings.caret_browsing = STATE_DISABLED;
m_browserSettings.plugins = STATE_DISABLED;
m_browserSettings.javascript_open_windows = STATE_DISABLED;
m_browserSettings.javascript_close_windows = STATE_DISABLED;
Expand Down Expand Up @@ -105,9 +103,9 @@ CefRefPtr<CefBrowserProcessHandler> Client::GetBrowserProcessHandler()
return this;
}

void Client::OnRegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar)
void Client::OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar)
{
registrar->AddCustomScheme(constants::scheme, true, false, false);
registrar->AddCustomScheme(constants::scheme, true, false, false, false, true, false);
}

void Client::OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line)
Expand Down
14 changes: 7 additions & 7 deletions src/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ class Client : public CefApp,
// Get the number of running job processes
unsigned int GetProcessCount() {
return m_processCount;
};
}

void SetStopAfterLastJob(bool flag) {
m_stopAfterLastJob = flag;
};
}

void SetDisableJavaScript(bool flag) {
m_browserSettings.javascript = flag ? STATE_DISABLED : STATE_ENABLED;
};
}

void SetAllowedSchemes(const std::set<std::string>& schemes) {
for (auto s: schemes) {
m_requestHandler->AddAllowedScheme(s);
}
};
}

void ClearAllowedSchemes() {
m_requestHandler->ClearAllowedSchemes();
};
}

// CefApp methods:
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override;
virtual void OnRegisterCustomSchemes(CefRefPtr<CefSchemeRegistrar> registrar) override;
virtual void OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) override;
virtual void OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line) override;

// CefBrowserProcessHandler methods:
Expand Down Expand Up @@ -124,7 +124,7 @@ class Client : public CefApp,
CefRefPtr<RequestHandler> m_requestHandler;

// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(Client);
IMPLEMENT_REFCOUNTING(Client)
};

} // namespace cefpdf
Expand Down
5 changes: 2 additions & 3 deletions src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ std::string getCurrentWorkingDirectory()
return result;
#else
char result[2*4096];
getcwd(result, 2*4096);
return result;
return getcwd(result, 2*4096);
#endif // OS_WIN
}

Expand Down Expand Up @@ -323,4 +322,4 @@ bool deleteTempFile(const std::string& path)
return 0 == std::remove(path.c_str());
}

} // namespace cefpdf
} // namespace cefpdf
2 changes: 1 addition & 1 deletion src/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ std::string getTempDirectory();

namespace constants {
// cef-pdf version number
const std::string version = "0.2.1";
const std::string version = "0.3.0";
// Internal scheme
const std::string scheme = "cefpdf";
// Default page size
Expand Down
Loading

0 comments on commit 3bf7d47

Please sign in to comment.