-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
project(saucer-bindings-pdf LANGUAGES CXX VERSION 5.0.0) | ||
|
||
# -------------------------------------------------------------------------------------------------------- | ||
# Setup library | ||
# -------------------------------------------------------------------------------------------------------- | ||
|
||
add_library(${PROJECT_NAME} SHARED) | ||
add_library(saucer::bindings::pdf ALIAS ${PROJECT_NAME}) | ||
|
||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_23) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 23 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON) | ||
|
||
# -------------------------------------------------------------------------------------------------------- | ||
# Include directories | ||
# -------------------------------------------------------------------------------------------------------- | ||
|
||
target_include_directories(${PROJECT_NAME} PUBLIC "include") | ||
target_include_directories(${PROJECT_NAME} PRIVATE "include/saucer") | ||
|
||
# -------------------------------------------------------------------------------------------------------- | ||
# Add Sources | ||
# -------------------------------------------------------------------------------------------------------- | ||
|
||
target_sources(${PROJECT_NAME} PRIVATE | ||
"src/pdf.cpp" | ||
) | ||
|
||
# -------------------------------------------------------------------------------------------------------- | ||
# Setup Dependencies | ||
# -------------------------------------------------------------------------------------------------------- | ||
|
||
CPMFindPackage( | ||
NAME saucer-pdf | ||
VERSION 1.0.1 | ||
GIT_REPOSITORY "https://github.com/saucer/pdf" | ||
) | ||
|
||
target_link_libraries(${PROJECT_NAME} PRIVATE saucer::pdf) | ||
saucer_bindings_add_module(${PROJECT_NAME} "SAUCER_PDF_EXPORT") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
#include "export.h" | ||
|
||
#include <saucer/webview.h> | ||
|
||
enum SAUCER_LAYOUT | ||
{ | ||
SAUCER_LAYOUT_PORTRAIT, | ||
SAUCER_LAYOUT_LANDSCAPE, | ||
}; | ||
|
||
struct saucer_print_settings; | ||
|
||
SAUCER_PDF_EXPORT saucer_print_settings *saucer_print_settings_new(); | ||
SAUCER_PDF_EXPORT void saucer_print_settings_free(saucer_print_settings *); | ||
|
||
SAUCER_PDF_EXPORT void saucer_print_settings_set_file(saucer_print_settings *, const char *file); | ||
SAUCER_PDF_EXPORT void saucer_print_settings_set_orientation(saucer_print_settings *, SAUCER_LAYOUT orientation); | ||
|
||
SAUCER_PDF_EXPORT void saucer_print_settings_set_width(saucer_print_settings *, double width); | ||
SAUCER_PDF_EXPORT void saucer_print_settings_set_height(saucer_print_settings *, double height); | ||
|
||
struct saucer_pdf; | ||
|
||
SAUCER_PDF_EXPORT saucer_pdf *saucer_pdf_new(saucer_handle *webview); | ||
SAUCER_PDF_EXPORT void saucer_pdf_free(saucer_pdf *); | ||
|
||
SAUCER_PDF_EXPORT void saucer_pdf_save(saucer_pdf *, saucer_print_settings *settings); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "pdf.h" | ||
|
||
#include "webview.hpp" | ||
#include "utils/handle.hpp" | ||
|
||
#include <saucer/modules/pdf.hpp> | ||
|
||
struct saucer_print_settings : bindings::handle<saucer_print_settings, saucer::modules::print_settings> | ||
{ | ||
}; | ||
|
||
struct saucer_pdf : bindings::handle<saucer_pdf, saucer::modules::pdf> | ||
{ | ||
}; | ||
|
||
extern "C" | ||
{ | ||
saucer_print_settings *saucer_print_settings_new() | ||
{ | ||
return saucer_print_settings::make(); | ||
} | ||
|
||
void saucer_print_settings_free(saucer_print_settings *handle) | ||
{ | ||
delete handle; | ||
} | ||
|
||
void saucer_print_settings_set_file(saucer_print_settings *handle, const char *file) | ||
{ | ||
handle->value().file = file; | ||
} | ||
|
||
void saucer_print_settings_set_orientation(saucer_print_settings *handle, SAUCER_LAYOUT orientation) | ||
{ | ||
handle->value().orientation = static_cast<saucer::modules::layout>(orientation); | ||
} | ||
|
||
void saucer_print_settings_set_width(saucer_print_settings *handle, double width) | ||
{ | ||
handle->value().size.first = width; | ||
} | ||
|
||
void saucer_print_settings_set_height(saucer_print_settings *handle, double height) | ||
{ | ||
handle->value().size.second = height; | ||
} | ||
|
||
saucer_pdf *saucer_pdf_new(saucer_handle *webview) | ||
{ | ||
return saucer_pdf::make(webview); | ||
} | ||
|
||
void saucer_pdf_free(saucer_pdf *handle) | ||
{ | ||
delete handle; | ||
} | ||
|
||
void saucer_pdf_save(saucer_pdf *handle, saucer_print_settings *settings) | ||
{ | ||
handle->value().save(settings->value()); | ||
} | ||
} |