Skip to content

Commit

Permalink
Update documentation and static build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
antialize committed Aug 11, 2010
1 parent 1d2d31d commit 2b1fe11
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 70 deletions.
1 change: 1 addition & 0 deletions Doxyfile.lib
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ INPUT += src/lib/pdf.h src/lib/pdf_c_bindings.cc
INPUT += src/lib/image.h src/lib/image_c_bindings.cc
INPUT += src/lib/pdfsettings.hh src/lib/pdfsettings.cc
INPUT += src/lib/imagesettings.hh src/lib/imagesettings.cc
INPUT += src/lib/doc.cc

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
Expand Down
2 changes: 1 addition & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CFLAGS= -I ../include
LDFLAGS=-L ../bin -lwkhtmltox -Wall -ansi -pedantic
LDFLAGS=-L ../bin -lwkhtmltox -Wall -ansi -pedantic -ggdb

EXES=pdf_c_api

Expand Down
2 changes: 1 addition & 1 deletion examples/pdf_c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int main() {
* to the list of pages to convert. Objects are converted in the order in which
* they are added
*/
wkhtmltopdf_add_resource(c, os, NULL);
wkhtmltopdf_add_object(c, os, NULL);

/* Perform the actual convertion */
if (!wkhtmltopdf_convert(c))
Expand Down
31 changes: 20 additions & 11 deletions scripts/static-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,26 @@ EOF
chmod +x build.sh
}

function packandcopylinux() {
WK=${BUILD}/linux-$1/build/wkhtmltopdf
rm -rf ${BASE}/bin/wkhtmltopdf-$1 ${BASE}/bin/wkhtmltoimage-$1 ${BASE}/bin/libwkhtmltopdf-$1.tar.lzma
${BUILD}/${UPX}/upx --best ${WK}/bin/wkhtmltopdf -o ${BASE}/bin/wkhtmltopdf-$1 || exit 1
${BUILD}/${UPX}/upx --best ${WK}/bin/wkhtmltoimage -o ${BASE}/bin/wkhtmltoimage-$1 || exit 1
rm -rf ${WK}/lib
mkdir -p ${WK}/lib
cp ${WK}/bin/libwkhtmltox*.so ${WK}/lib || exit 1
cd ${WK} && tar -c --lzma -f ${BASE}/bin/libwkhtmltopdf-$1.tar.lzma lib include examples/Makefile examples/pdf_c_api.c
}


function build_linux_local() {
cd ${BUILD}
mkdir -p linux-local
cd linux-local
setup_build linux
./build.sh || exit 1
cd ..
${BUILD}/${UPX}/upx --best ${BUILD}/linux-local/wkhtmltopdf/bin/wkhtmltopdf -o ${BASE}/bin/wkhtmltopdf || exit 1
${BUILD}/${UPX}/upx --best ${BUILD}/linux-local/wkhtmltopdf/bin/wkhtmltoimage -o ${BASE}/bin/wkhtmltoimage || exit 1
packandcopylinux local
}

function setup_chroot() {
Expand Down Expand Up @@ -216,14 +227,7 @@ function build_linux_chroot() {
else
sudo chroot ${BUILD}/linux-$1/ /build/buildw.sh || exit 1
fi
WK=${BUILD}/linux-$1/build/wkhtmltopdf
rm -rf ${BASE}/bin/wkhtmltopdf-$1 ${BASE}/bin/wkhtmltoimage-$1 ${BASE}/bin/libwkhtmltopdf-$1.tar.gz
${BUILD}/${UPX}/upx --best ${WK}/bin/wkhtmltopdf -o ${BASE}/bin/wkhtmltopdf-$1 || exit 1
${BUILD}/${UPX}/upx --best ${WK}/bin/wkhtmltoimage -o ${BASE}/bin/wkhtmltoimage-$1 || exit 1
rm -rf ${WK}/lib
mkdir -p ${WK}/lib
cp ${WK}/bin/libwkhtmltox*.so ${WK}/lib || exit 1
cd ${WK} && tar -czf ${BASE}/bin/libwkhtmltopdf-$1.tar.gz lib include examples/Makefile examples/pdf_c_api.c
packandcopylinux $1
}

function build_windows() {
Expand Down Expand Up @@ -281,9 +285,14 @@ EOF
wine mingw32-make -j${J} || exit 1
wine strip.exe bin/wkhtmltopdf.exe || exit 1
wine strip.exe bin/wkhtmltoimage.exe || exit 1
rm -rf ${BASE}/wkhtmltopdf.exe

rm -rf ${BASE}/bin/wkhtmltopdf.exe ${BASE}/bin/wkhtmltoimage.exe ${BASE}/bin/libwkhtmltopdf.zip
${BUILD}/${UPX}/upx --best bin/wkhtmltopdf.exe -o ${BASE}/bin/wkhtmltopdf.exe || exit 1
${BUILD}/${UPX}/upx --best bin/wkhtmltoimage.exe -o ${BASE}/bin/wkhtmltoimage.exe || exit 1
rm -rf lib
mkdir -p lib
cp bin/wkhtmltox*.dll lib || exit 1
zip -9 ${BASE}/bin/libwkhtmltopdf.zip lib include examples/Makefile examples/pdf_c_api.c
}

case "$1" in
Expand Down
23 changes: 23 additions & 0 deletions src/lib/image_c_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@
// You should have received a copy of the GNU Lesser General Public License
// along with wkhtmltopdf. If not, see <http://www.gnu.org/licenses/>.

/**
* \page pagesettings Setting
* \section pageImageGlobal Image settings
* The \ref wkhtmltoimage_global_settings structure contains the following settings:
* - \b crop.left left/x coordinate of the window to capture in pixels. E.g. "200"
* - \b crop.top top/y coordinate of the window to capture in pixels. E.g. "200"
* - \b crop.width Width of the window to capture in pixels. E.g. "200"
* - \b crop.height Heigt of the window to capture in pixels. E.g. "200"
* - \b load.cookieJar Path of file used to load and store cookies.
* - \b load.* Page specific settings related to loading content, see \ref pageLoad.
* - \b web.* See \ref pageWeb.
* - \b transparent When outputting a PNG or SVG, make the white background transparent.
* Must be either "true" or "false"
* - \b in The URL or path of the input file, if "-" stdin is used. E.g. "http://google.com"
* - \b out The path of the output file, if "-" stdout is used, if empty the content is storred
* to a internalBuffer.
* - \b fmt The output format to use, must be either "", "jpg", "png", "bmp" or "svg".
* - \b screenWidth The with of the screen used to render is pixels, e.g "800".
* - \b smartWidth Should we expand the screenWidth if the content does not fit?
* must be either "true" or "false".
* - \b quality The compression factor to use when outputting a JPEG image. E.g. "94".
*/

#ifdef __WKHTMLTOX_UNDEF_QT_DLL__
#ifdef QT_DLL
#undef QT_DLL
Expand Down
177 changes: 120 additions & 57 deletions src/lib/pdf_c_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,60 +34,70 @@
#include <QWebFrame>

#include "dllbegin.inc"
using namespace wkhtmltopdf;

QApplication * a = 0;
int usage = 0;

void MyPdfConverter::warning(const QString & message) {
if (warning_cb) (warning_cb)(reinterpret_cast<wkhtmltopdf_converter*>(this), message.toUtf8().constData());
}

void MyPdfConverter::error(const QString & message) {
if (error_cb) (error_cb)(reinterpret_cast<wkhtmltopdf_converter*>(this), message.toUtf8().constData());
}

void MyPdfConverter::phaseChanged() {
if (phase_changed) (phase_changed)(reinterpret_cast<wkhtmltopdf_converter*>(this));
}

void MyPdfConverter::progressChanged(int progress) {
if (progress_changed) (progress_changed)(reinterpret_cast<wkhtmltopdf_converter*>(this), progress);
}

void MyPdfConverter::finished(bool ok) {
if (finished_cb) (finished_cb)(reinterpret_cast<wkhtmltopdf_converter*>(this), ok);
}

MyPdfConverter::MyPdfConverter(settings::PdfGlobal * gs):
warning_cb(0), error_cb(0), phase_changed(0), progress_changed(0), finished_cb(0),
converter(*gs), globalSettings(gs) {

connect(&converter, SIGNAL(warning(const QString &)), this, SLOT(warning(const QString &)));
connect(&converter, SIGNAL(error(const QString &)), this, SLOT(error(const QString &)));
connect(&converter, SIGNAL(phaseChanged()), this, SLOT(phaseChanged()));
connect(&converter, SIGNAL(progressChanged(int)), this, SLOT(progressChanged(int)));
connect(&converter, SIGNAL(finished(bool)), this, SLOT(finished(bool)));
}

MyPdfConverter::~MyPdfConverter() {
delete globalSettings;
for (size_t i=0; i < objectSettings.size(); ++i)
delete objectSettings[i];
objectSettings.clear();
}

/**
* \page pagesettings Setting
* Settings can be supplied to PDF and image c-bindings using utf-8 encoded strings.
* This is done by relatively simple reflection on the CropSettins, HeaderFooter, Margin,
* ImageGlobal, PdfGlobal, PdfObject, Size, and TabelOfContent classes .
* ImageGlobal, PdfGlobal, PdfObject, Size, and TabelOfContent classes.
*
* - The \ref wkhtmltopdf_global_settings corresponds to the PdfGlobal class and is documented in \ref pagePdfGlobal.
* - The \ref wkhtmltopdf_object_settings corresponds to the PdfGlobal class and is documented in \ref pagePdfObject.
* - The \ref wkhtmltopdf_image_settings corresponds to the ImageGlobal class and is documented in \ref pageImageGlobal.
*
* \section pageGlobalLoad Page loading settings
* \section pageWeb Web page specific settings
* The following web page specific settings apply
* - \b web.background Should we print the background? Must be either "true" or "false".
* - \b web.loadImages Should we load images? Must be either "true" or "false".
* - \b web.enableJavascript Should we enable javascript? Must be either "true" or "false".
* - \b web.enableIntelligentShrinking Should we enable intelligent shrinkng to fit more content
* on one page? Must be either "true" or "false". Has no effect for wkhtmltoimage.
* - \b web.minimumFontSize The minimum font size allowed. E.g. "9"
* - \b web.printMediaType Should the content be printed using the print media type instead
* of the screen media type. Must be either "true" or "false". Has no effect for wkhtmltoimage.
* - \b web.defaultEncoding What encoding should we guess content is using if they do not
* specify it propperly? E.g. "utf-8"
* - \b web.userStyleSheet Url er path to a user specified style sheet.
* - \b web.enablePlugins Should we enable NS plugins, must be either "true" or "false".
* Enabling this will have limited success.
*
* \section pageLoad Object Specific loading settings
* The following settings apply for object loading.
* - \b load.username The user name to use when loging into a website, E.g. "bart"
* - \b load.password The password to used when logging into a website, E.g. "elbarto"
* - \b load.jsdelay The mount of time in milliseconds to wait after a page has done loading until
* it is actualy printed. E.g. "1200". We will wait this amount of time or until, javascript
* calles window.print().
* - \b load.zoomFactor How much should we zoom in on the content? E.g. "2.2".
* - \b load.customHeaders TODO
* - \b load.repertCustomHeaders Should the custom headers be sendt all elements loaded instead of
* only the main page? Must be either "true" or "false".
* - \b load.cookies TODO
* - \b load.post TODO
* - \b load.blockLocalFileAccess Dissalow local and piped files to acces other local files. Must
* be either "true" or "false".
* - \b load.stopSlowScript Stop slow running javascript. Must be either "true" or "false".
* - \b load.debugJavascript Forward javascript warnings and errors to the warning callback.
* Must be either "true" or "false".
* - \b load.loadErrorHandling How should we handel obejcts that fail to load. Must be one of:
* - "abort" Abort the convertion process
* - "skip" Do not add the object to the final output
* - "ignore" Try to add the object to the final output.
* - \b load.proxy String describing whact proxy to use when loading the object.
* \section pageHeaderFooter Header and footer settings
* The same settings can be applied for headers and footers, here there are explained in
* terms of the header.
* - \b header.fontSize The font size to use for the header, e.g. "13"
* - \b header.fontName The name of the font to use for the header. e.g. "times"
* - \b header.left The string to print in the left part of the header, note that some sequences
* are replaced in this string, see the wkhtmltopdf manual.
* - \b header.center The text to print in the center part of the header.
* - \b header.right The text to print in the right part of the header.
* - \b header.line Should a line be printed under the header? Must be either "true" or "false.
* - \b header.space The amount of space to put between the header and the content, e.g. "1.8". Be
* aware that if this is to large the header will be printed outside the pdf document. This
* can be correct with the margin.top setting.
* - \b header.htmlUrl Url for a HTML document to use for the header.
*
* \section pagePdfGlobal Pdf global settings
* The \ref wkhtmltopdf_global_settings structure contains the following settings:
Expand All @@ -114,38 +124,47 @@ MyPdfConverter::~MyPdfConverter() {
* - \b outputFormat The format of the output document, must be ether "", "pdf" or "ps".
* - \b imageDPI The maximal DPI to use for images in the pdf document.
* - \b imageQuality The jpeg compression factor to use when producing the pdf document, e.g. "92".
* - \b load.* Global Setting related to loading content, see \ref pageGlobalLoad.
* - \b load.cookieJar Path of file used to load and store cookies.
*
* \section pagePdfObjectl Pdf object settings
* \section pagePdfObject Pdf object settings
* The \ref wkhtmltopdf_object_settings structure contains the following settings:
* - \b toc.*
* - \b toc.useDottedLines Should we use a dotted line when creating a table of content?
* Must be either "true" or "false".
* - \b toc.captionText The caption to use when creating a table of content.
* - \b toc.forwardLinks Should we create links from the table of content into the actual content?
* Must be either "true or "false.
* - \b toc.backLinks Should we link back from the content to this table of content.
* - \b toc.indentation The indentation used for every table of content level, e.g. "2em".
* - \b toc.fontScale How much should we scale down the font for every toc level? E.g. "0.8"
* - \b page The URL or path of the web page to convert, if "-" input is read from stdin.
* - \b header.*
* - \b footer.*
* - \b useExternalLinks Should external links in the HTML document be converted into external pdf links? Must be either "true" or "false.
* - \b useLocalLinks Should internal links in the HTML document be converted into pdf references? Must be either "true" or "false"
* - \b header.* Header specific settings see \ref pageHeaderFooter.
* - \b footer.* Footer specific settings see \ref pageHeaderFooter.
* - \b useExternalLinks Should external links in the HTML document be converted into
* external pdf links? Must be either "true" or "false.
* - \b useLocalLinks Should internal links in the HTML document be converted into pdf
* references? Must be either "true" or "false"
* - \b replacements TODO
* - \b produceForms Should we turn HTML forms into PDF forms? Must be either "true" or file".
* - \b load.* Page specific settings related to loading content, see \ref pageLoad.
* - \b web.* See \ref pageWeb.
* - \b includeInOutline Should the sections from this document be included in the outline and table of content?
* - \b pagesCount Should we count the pages of this document, in the counter used for TOC, headers and footers?
* - \b tocXsl If not empty this object is a table of content object, "page" is ignored and this xsl style sheet is
* used to convert the outline XML into a table of content.
* - \b tocXsl If not empty this object is a table of content object, "page" is ignored and this xsl style
* sheet is used to convert the outline XML into a table of content.
*/

/**
* \struct wkhtmltopdf_global_settings
* \brief A struct holding global settings
*
* See also \ref pagesettings
* See also \ref pagePdfGlobal
*/

/**
* \struct wkhtmltopdf_object_settings
* \brief A struct holding object settings
*
* See also \ref pagesettings
* See also \ref pagePdfObject
*/

/**
Expand Down Expand Up @@ -186,6 +205,50 @@ MyPdfConverter::~MyPdfConverter() {
* \sa wkhtmltopdf_set_phase_changed_callback
*/


using namespace wkhtmltopdf;
QApplication * a = 0;
int usage = 0;

void MyPdfConverter::warning(const QString & message) {
if (warning_cb) (warning_cb)(reinterpret_cast<wkhtmltopdf_converter*>(this), message.toUtf8().constData());
}

void MyPdfConverter::error(const QString & message) {
if (error_cb) (error_cb)(reinterpret_cast<wkhtmltopdf_converter*>(this), message.toUtf8().constData());
}

void MyPdfConverter::phaseChanged() {
if (phase_changed) (phase_changed)(reinterpret_cast<wkhtmltopdf_converter*>(this));
}

void MyPdfConverter::progressChanged(int progress) {
if (progress_changed) (progress_changed)(reinterpret_cast<wkhtmltopdf_converter*>(this), progress);
}

void MyPdfConverter::finished(bool ok) {
if (finished_cb) (finished_cb)(reinterpret_cast<wkhtmltopdf_converter*>(this), ok);
}

MyPdfConverter::MyPdfConverter(settings::PdfGlobal * gs):
warning_cb(0), error_cb(0), phase_changed(0), progress_changed(0), finished_cb(0),
converter(*gs), globalSettings(gs) {

connect(&converter, SIGNAL(warning(const QString &)), this, SLOT(warning(const QString &)));
connect(&converter, SIGNAL(error(const QString &)), this, SLOT(error(const QString &)));
connect(&converter, SIGNAL(phaseChanged()), this, SLOT(phaseChanged()));
connect(&converter, SIGNAL(progressChanged(int)), this, SLOT(progressChanged(int)));
connect(&converter, SIGNAL(finished(bool)), this, SLOT(finished(bool)));
}

MyPdfConverter::~MyPdfConverter() {
delete globalSettings;
for (size_t i=0; i < objectSettings.size(); ++i)
delete objectSettings[i];
objectSettings.clear();
}


/**
* \brief Check if the library is build against the wkhtmltopdf version of QT
*
Expand Down Expand Up @@ -282,7 +345,7 @@ CAPI wkhtmltopdf_global_settings * wkhtmltopdf_create_global_settings() {
/**
* \brief Alter a setting in a global settings object
*
* \sa \ref pagesettings, wkhtmltopdf_create_global_settings, wkhtmltopdf_get_global_setting
* \sa \ref pagePdfGlobal, wkhtmltopdf_create_global_settings, wkhtmltopdf_get_global_setting
*
* \param settings The settings object to change
* \param name The name of the setting
Expand Down

0 comments on commit 2b1fe11

Please sign in to comment.