[arch-commits] Commit in wkhtmltopdf/repos (8 files)

Evangelos Foutras foutrelis at nymeria.archlinux.org
Thu Jun 12 12:41:47 UTC 2014


    Date: Thursday, June 12, 2014 @ 14:41:47
  Author: foutrelis
Revision: 113062

archrelease: copy trunk to community-i686, community-x86_64

Added:
  wkhtmltopdf/repos/community-i686/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch
    (from rev 113061, wkhtmltopdf/trunk/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch)
  wkhtmltopdf/repos/community-i686/0002-fix-compilation-failures-when-not-building-with-patc.patch
    (from rev 113061, wkhtmltopdf/trunk/0002-fix-compilation-failures-when-not-building-with-patc.patch)
  wkhtmltopdf/repos/community-i686/PKGBUILD
    (from rev 113061, wkhtmltopdf/trunk/PKGBUILD)
  wkhtmltopdf/repos/community-x86_64/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch
    (from rev 113061, wkhtmltopdf/trunk/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch)
  wkhtmltopdf/repos/community-x86_64/0002-fix-compilation-failures-when-not-building-with-patc.patch
    (from rev 113061, wkhtmltopdf/trunk/0002-fix-compilation-failures-when-not-building-with-patc.patch)
  wkhtmltopdf/repos/community-x86_64/PKGBUILD
    (from rev 113061, wkhtmltopdf/trunk/PKGBUILD)
Deleted:
  wkhtmltopdf/repos/community-i686/PKGBUILD
  wkhtmltopdf/repos/community-x86_64/PKGBUILD

----------------------------------------------------------------------------------+
 /PKGBUILD                                                                        |   98 ++++
 community-i686/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch   |   74 +++
 community-i686/0002-fix-compilation-failures-when-not-building-with-patc.patch   |  233 ++++++++++
 community-i686/PKGBUILD                                                          |   30 -
 community-x86_64/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch |   74 +++
 community-x86_64/0002-fix-compilation-failures-when-not-building-with-patc.patch |  233 ++++++++++
 community-x86_64/PKGBUILD                                                        |   30 -
 7 files changed, 712 insertions(+), 60 deletions(-)

Copied: wkhtmltopdf/repos/community-i686/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch (from rev 113061, wkhtmltopdf/trunk/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch)
===================================================================
--- community-i686/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch	                        (rev 0)
+++ community-i686/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch	2014-06-12 12:41:47 UTC (rev 113062)
@@ -0,0 +1,74 @@
+From d6b406d9ec207036af807af2bee2aeb5e33827f0 Mon Sep 17 00:00:00 2001
+From: Ashish Kulkarni <kulkarni.ashish at gmail.com>
+Date: Mon, 10 Feb 2014 19:33:21 +0530
+Subject: [PATCH 1/2] fix spurious "exit with code 1 due to http error: 1xxx"
+ errors
+
+This fixes #1502 and was introduced in ce6d6cd0f0f86a5b1ff3765aaae357dfdf3be803,
+which returned errors above 1000 as a proxy for network errors. However, the
+error 5 (i.e. OperationCanceledError) was not handled, which apparently happens
+a lot due to parallel loading of resources. We thus ignore this error in the
+loader.
+
+In addition, in case the error is greater than 1000, we find out the correct
+network error and display that error instead of HTTP error 1xxx which doesn't
+exist. The trick to find out the text values for the enum was taken from:
+
+https://blog.qt.digia.com/blog/2008/10/09/coding-tip-pretty-printing-enum-values/
+---
+ src/lib/multipageloader.cc |  2 +-
+ src/lib/utilities.cc       | 18 +++++++++++++++++-
+ 2 files changed, 18 insertions(+), 2 deletions(-)
+
+diff --git a/src/lib/multipageloader.cc b/src/lib/multipageloader.cc
+index 0f4e7f7..d74fa0d 100644
+--- a/src/lib/multipageloader.cc
++++ b/src/lib/multipageloader.cc
+@@ -335,7 +335,7 @@ void ResourceObject::error(const QString & str) {
+ void ResourceObject::amfinished(QNetworkReply * reply) {
+ 	int networkStatus = reply->error();
+ 	int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+-	if (networkStatus > 0 || (httpStatus > 399 && httpErrorCode == 0))
++	if ((networkStatus != 0 && networkStatus != 5) || (httpStatus > 399 && httpErrorCode == 0))
+ 	{
+ 		QFileInfo fi(reply->url().toString());
+ 		bool mediaFile = settings::LoadPage::mediaFilesExtensions.contains(fi.completeSuffix().toLower());
+diff --git a/src/lib/utilities.cc b/src/lib/utilities.cc
+index 639aa32..4238c47 100644
+--- a/src/lib/utilities.cc
++++ b/src/lib/utilities.cc
+@@ -27,6 +27,8 @@
+ #include "utilities.hh"
+ #include <QDebug>
+ #include <QTextStream>
++#include <QMetaEnum>
++#include <QNetworkReply>
+ 
+ void loadSvg(QSvgRenderer * & ptr, const QString & path, const char * def, int w, int h) {
+ 	 delete ptr;
+@@ -160,7 +162,21 @@ int handleError(bool success, int errorCode) {
+ 		if (ce.contains(errorCode)) c = ce[errorCode];
+ 		const char * m = "";
+ 		if (cm.contains(errorCode)) m = cm[errorCode];
+-		fprintf(stderr, "Exit with code %d due to http error: %d %s\n", c, errorCode, m);
++		if (errorCode < 1000) {
++			fprintf(stderr, "Exit with code %d due to http error: %d %s\n", c, errorCode, m);
++		} else {
++			QNetworkReply::NetworkError error = (QNetworkReply::NetworkError)(errorCode - 1000);
++			QString errorValue;
++			QMetaObject meta = QNetworkReply::staticMetaObject;
++			for (int i=0; i < meta.enumeratorCount(); ++i) {
++				QMetaEnum m = meta.enumerator(i);
++				if (m.name() == QLatin1String("NetworkError")) {
++					errorValue = QLatin1String(m.valueToKey(error));
++					break;
++				}
++			}
++			fprintf(stderr, "Exit with code %d due to network error: %s\n", c, errorValue.toLocal8Bit().data());
++		}
+ 		return c;
+ 	} else if (!success) {
+ 		fprintf(stderr, "Exit with code %d, due to unknown error.\n", EXIT_FAILURE);
+-- 
+2.0.0
+

Copied: wkhtmltopdf/repos/community-i686/0002-fix-compilation-failures-when-not-building-with-patc.patch (from rev 113061, wkhtmltopdf/trunk/0002-fix-compilation-failures-when-not-building-with-patc.patch)
===================================================================
--- community-i686/0002-fix-compilation-failures-when-not-building-with-patc.patch	                        (rev 0)
+++ community-i686/0002-fix-compilation-failures-when-not-building-with-patc.patch	2014-06-12 12:41:47 UTC (rev 113062)
@@ -0,0 +1,233 @@
+From ef708c2adb31062d73506917f03fd5e942594d33 Mon Sep 17 00:00:00 2001
+From: Ashish Kulkarni <kulkarni.ashish at gmail.com>
+Date: Sat, 15 Mar 2014 11:42:11 +0530
+Subject: [PATCH 2/2] fix compilation failures when not building with patched
+ QT/WebKit
+
+Apparently, no one uses the plain vanilla build as no one reported
+any issue for a long time. This will get it to compile and work at
+least for a sample page.
+
+Conflicts:
+	src/lib/pdfconverter.cc
+---
+ src/lib/pdfconverter.cc   | 33 +++++++++++++++++++++++++++------
+ src/lib/pdfconverter_p.hh | 14 +++++++++-----
+ 2 files changed, 36 insertions(+), 11 deletions(-)
+
+diff --git a/src/lib/pdfconverter.cc b/src/lib/pdfconverter.cc
+index b227c87..f883a00 100644
+--- a/src/lib/pdfconverter.cc
++++ b/src/lib/pdfconverter.cc
+@@ -78,9 +78,9 @@ bool DLL_LOCAL looksLikeHtmlAndNotAUrl(QString str) {
+ 
+ PdfConverterPrivate::PdfConverterPrivate(PdfGlobal & s, PdfConverter & o) :
+ 	settings(s), pageLoader(s.load),
+-	out(o), printer(0), painter(0), webPrinter(0)
++	out(o), printer(0), painter(0)
+ #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+-    , measuringHFLoader(s.load), hfLoader(s.load), tocLoader1(s.load), tocLoader2(s.load)
++    , webPrinter(0), measuringHFLoader(s.load), hfLoader(s.load), tocLoader1(s.load), tocLoader2(s.load)
+ 	, tocLoader(&tocLoader1), tocLoaderOld(&tocLoader2)
+     , outline(0), currentHeader(0), currentFooter(0)
+ #endif
+@@ -151,13 +151,15 @@ void PdfConverterPrivate::beginConvert() {
+ 		fail();
+ 		return;
+ 	}
+-#endif
++#else
+     bool headerHeightsCalcNeeded = false;
++#endif
+ 
+ 	for (QList<PageObject>::iterator i=objects.begin(); i != objects.end(); ++i) {
+ 		PageObject & o=*i;
+ 		settings::PdfObject & s = o.settings;
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+         if (!s.header.htmlUrl.isEmpty() ) {
+             if (looksLikeHtmlAndNotAUrl(s.header.htmlUrl)) {
+                 emit out.error("--header-html should be a URL and not a string containing HTML code.");
+@@ -195,6 +197,7 @@ void PdfConverterPrivate::beginConvert() {
+                 o.footerReserveHeight = settings.margin.bottom.first + s.footer.spacing;
+             }
+         }
++#endif
+ 
+ 		if (!s.isTableOfContent) {
+ 			o.loaderObject = pageLoader.addResource(s.page, s.load, &o.data);
+@@ -207,6 +210,7 @@ void PdfConverterPrivate::beginConvert() {
+ 	emit out.phaseChanged();
+ 	loadProgress(0);
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+     if (headerHeightsCalcNeeded) {
+         // preload header/footer to check their heights
+         measuringHFLoader.load();
+@@ -225,8 +229,12 @@ void PdfConverterPrivate::beginConvert() {
+ 
+         pageLoader.load();
+     }
++#else
++    pageLoader.load();
++#endif
+ }
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+ // calculates header/footer height
+ // returns millimeters
+ qreal PdfConverterPrivate::calculateHeaderHeight(PageObject & object, QWebPage & header) {
+@@ -252,6 +260,8 @@ qreal PdfConverterPrivate::calculateHeaderHeight(PageObject & object, QWebPage &
+     return (height / PdfConverter::millimeterToPointMultiplier);
+ }
+ 
++#endif
++
+ QPrinter * PdfConverterPrivate::createPrinter(const QString & tempFile) {
+     QPrinter * printer = new QPrinter(settings.resolution);
+     if (settings.dpi != -1) printer->setResolution(settings.dpi);
+@@ -275,6 +285,7 @@ QPrinter * PdfConverterPrivate::createPrinter(const QString & tempFile) {
+     return printer;
+ }
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+ void PdfConverterPrivate::preprocessPage(PageObject & obj) {
+ 	currentObject++;
+ 	if (obj.settings.isTableOfContent) {
+@@ -309,7 +320,7 @@ void PdfConverterPrivate::preprocessPage(PageObject & obj) {
+ 		outline->addEmptyWebPage();
+ 	painter->restore();
+ }
+-
++#endif
+ 
+ /*!
+  * Prepares printing out the document to the pdf file
+@@ -353,9 +364,15 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
+ 	}
+ 
+     //Setup margins and papersize
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+     printer->setPageMargins(settings.margin.left.first, objects[0].headerReserveHeight,
+                                 settings.margin.right.first, objects[0].footerReserveHeight,
+                                 settings.margin.left.second);
++#else
++    printer->setPageMargins(settings.margin.left.first, settings.margin.top.first,
++                                settings.margin.right.first, settings.margin.bottom.first,
++                                settings.margin.left.second);
++#endif
+ 
+ 	if ((settings.size.height.first != -1) && (settings.size.width.first != -1)) {
+ 		printer->setPaperSize(QSizeF(settings.size.width.first,settings.size.height.first), settings.size.height.second);
+@@ -656,7 +673,6 @@ void PdfConverterPrivate::endPage(PageObject & object, bool hasHeaderFooter, int
+ 	}
+ 
+ }
+-#endif
+ 
+ void PdfConverterPrivate::handleTocPage(PageObject & obj) {
+ 	painter->save();
+@@ -670,6 +686,7 @@ void PdfConverterPrivate::handleTocPage(PageObject & obj) {
+ 	tocChanged = outline->replaceWebPage(obj.number, obj.settings.toc.captionText, wp, obj.page->mainFrame(), obj.settings, obj.localLinks, obj.anchors) || tocChanged;
+ 	painter->restore();
+ }
++#endif
+ 
+ 
+ void PdfConverterPrivate::tocLoaded(bool ok) {
+@@ -731,6 +748,7 @@ void PdfConverterPrivate::measuringHeadersLoaded(bool ok) {
+         return;
+     }
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+     for (int d=0; d < objects.size(); ++d) {
+         PageObject & obj = objects[d];
+         if (obj.measuringHeader) {
+@@ -743,6 +761,7 @@ void PdfConverterPrivate::measuringHeadersLoaded(bool ok) {
+             obj.footerReserveHeight = calculateHeaderHeight(obj, *obj.measuringFooter) + obj.settings.header.spacing;
+         }
+     }
++#endif
+ 
+     pageLoader.load();
+ }
+@@ -758,6 +777,7 @@ void PdfConverterPrivate::headersLoaded(bool ok) {
+ 	printDocument();
+ }
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+ 
+ void PdfConverterPrivate::spoolPage(int page) {
+ 	progressString = QString("Page ") + QString::number(actualPage) + QString(" of ") + QString::number(actualPages);
+@@ -904,7 +924,8 @@ void PdfConverterPrivate::endPrintObject(PageObject & obj) {
+ 	}
+ 
+ }
+-			
++
++#endif
+ 
+ void PdfConverterPrivate::printDocument() {
+ #ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+diff --git a/src/lib/pdfconverter_p.hh b/src/lib/pdfconverter_p.hh
+index 2cfa441..3679673 100644
+--- a/src/lib/pdfconverter_p.hh
++++ b/src/lib/pdfconverter_p.hh
+@@ -94,8 +94,11 @@ public:
+ 	}
+ 
+ 	PageObject(const settings::PdfObject & set, const QString * d=NULL):
+-        settings(set), loaderObject(0), page(0), headerReserveHeight(0), footerReserveHeight(0),
+-        measuringHeader(0), measuringFooter(0) {
++		settings(set), loaderObject(0), page(0)
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
++		, headerReserveHeight(0), footerReserveHeight(0), measuringHeader(0), measuringFooter(0)
++#endif
++	{
+ 		if (d) data=*d;
+ 	};
+ 
+@@ -134,6 +137,7 @@ private:
+ 	bool tocChanged;
+ 	int actualPage;
+ 	int pageNumber;
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+ 	QWebPrinter * webPrinter;
+ 	int objectPage;
+ 
+@@ -144,7 +148,6 @@ private:
+ 	QHash<int, QVector<QWebElement> > pageFormElements;
+ 	bool pageHasHeaderFooter;
+ 	
+-#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+     // loader for measuringHeader and measuringFooter
+     MultiPageLoader measuringHFLoader;
+ 
+@@ -163,14 +166,14 @@ private:
+ 	void fillParms(QHash<QString, QString> & parms, int page, const PageObject & object);
+ 	QString hfreplace(const QString & q, const QHash<QString, QString> & parms);
+ 	QWebPage * loadHeaderFooter(QString url, const QHash<QString, QString> & parms, const settings::PdfObject & ps);
+-
++    qreal calculateHeaderHeight(PageObject & object, QWebPage & header);
+ 
+ #endif
+ 	QWebPage * currentHeader;
+ 	QWebPage * currentFooter;
+-    qreal calculateHeaderHeight(PageObject & object, QWebPage & header);
+     QPrinter * createPrinter(const QString & tempFile);
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+ 	void handleTocPage(PageObject & obj);
+ 	void preprocessPage(PageObject & obj);
+ 	void spoolPage(int page);
+@@ -179,6 +182,7 @@ private:
+ 	void handleFooter(QWebPage * frame, int page);
+ 	void beginPrintObject(PageObject & obj);
+ 	void endPrintObject(PageObject & obj);
++#endif
+ 
+ 	void loadTocs();
+ 	void loadHeaders();
+-- 
+2.0.0
+

Deleted: community-i686/PKGBUILD
===================================================================
--- community-i686/PKGBUILD	2014-06-12 12:38:30 UTC (rev 113061)
+++ community-i686/PKGBUILD	2014-06-12 12:41:47 UTC (rev 113062)
@@ -1,30 +0,0 @@
-# $Id$
-# Maintainer: Evangelos Foutras <evangelos at foutrelis.com>
-
-pkgname=wkhtmltopdf
-pkgver=0.9.9
-pkgrel=2
-pkgdesc="Simple shell utility to convert html to pdf using the webkit rendering engine, and qt"
-arch=('i686' 'x86_64')
-url="http://code.google.com/p/wkhtmltopdf/"
-license=('GPL3')
-depends=('qtwebkit')
-optdepends=('xorg-server: wkhtmltopdf needs X or Xvfb to operate')
-source=(http://wkhtmltopdf.googlecode.com/files/$pkgname-$pkgver.tar.bz2)
-sha1sums=('41f598c0103326e7c13101391447b0284b4ba3cb')
-
-build() {
-  cd "$srcdir/$pkgname-$pkgver"
-
-  qmake wkhtmltopdf.pro
-  make
-}
-
-package() {
-  cd "$srcdir/$pkgname-$pkgver"
-  make INSTALL_ROOT="$pkgdir/usr" install
-
-  # Generate and install man page
-  install -d "$pkgdir/usr/share/man/man1"
-  ./wkhtmltopdf --manpage >"$pkgdir/usr/share/man/man1/wkhtmltopdf.1"
-}

Copied: wkhtmltopdf/repos/community-i686/PKGBUILD (from rev 113061, wkhtmltopdf/trunk/PKGBUILD)
===================================================================
--- community-i686/PKGBUILD	                        (rev 0)
+++ community-i686/PKGBUILD	2014-06-12 12:41:47 UTC (rev 113062)
@@ -0,0 +1,49 @@
+# $Id$
+# Maintainer: Evangelos Foutras <evangelos at foutrelis.com>
+
+pkgname=wkhtmltopdf
+pkgver=0.12.0
+pkgrel=1
+pkgdesc="Command line tools to render HTML into PDF and various image formats"
+arch=('i686' 'x86_64')
+url="http://wkhtmltopdf.org/"
+license=('GPL3')
+depends=('qtwebkit')
+optdepends=('xorg-server: wkhtmltopdf needs X or Xvfb to operate')
+source=($pkgname-$pkgver.tar.gz::https://github.com/wkhtmltopdf/wkhtmltopdf/archive/$pkgver.tar.gz
+        0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch
+        0002-fix-compilation-failures-when-not-building-with-patc.patch)
+sha256sums=('ad3449acc772bd687b3853e087033b7223e6298f4a59d21d09c08c9d006f693f'
+            'bc9ffc8a99a32f66882e406f25962a0753129c161530879ad23ee5bd189a2a66'
+            'ece5abbee4c9f37ab4b5df856dd708562dbf4e14374b9c60b41109f00c82c44b')
+
+prepare() {
+  cd "$srcdir/$pkgname-$pkgver"
+
+  # https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1502
+  patch -Np1 -i "$srcdir/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch"
+
+  # Fix build with system Qt
+  patch -Np1 -i "$srcdir/0002-fix-compilation-failures-when-not-building-with-patc.patch"
+}
+
+build() {
+  cd "$srcdir/$pkgname-$pkgver"
+
+  qmake-qt4 wkhtmltopdf.pro
+  make
+}
+
+package() {
+  cd "$srcdir/$pkgname-$pkgver"
+  make INSTALL_ROOT="$pkgdir/usr" install
+
+  # Generate and install man page
+  install -d "$pkgdir/usr/share/man/man1"
+  LD_LIBRARY_PATH=bin ./bin/wkhtmltopdf --manpage \
+    >"$pkgdir/usr/share/man/man1/wkhtmltopdf.1"
+  LD_LIBRARY_PATH=bin ./bin/wkhtmltoimage --manpage \
+    >"$pkgdir/usr/share/man/man1/wkhtmltoimage.1"
+}
+
+# vim:set ts=2 sw=2 et:

Copied: wkhtmltopdf/repos/community-x86_64/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch (from rev 113061, wkhtmltopdf/trunk/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch)
===================================================================
--- community-x86_64/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch	                        (rev 0)
+++ community-x86_64/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch	2014-06-12 12:41:47 UTC (rev 113062)
@@ -0,0 +1,74 @@
+From d6b406d9ec207036af807af2bee2aeb5e33827f0 Mon Sep 17 00:00:00 2001
+From: Ashish Kulkarni <kulkarni.ashish at gmail.com>
+Date: Mon, 10 Feb 2014 19:33:21 +0530
+Subject: [PATCH 1/2] fix spurious "exit with code 1 due to http error: 1xxx"
+ errors
+
+This fixes #1502 and was introduced in ce6d6cd0f0f86a5b1ff3765aaae357dfdf3be803,
+which returned errors above 1000 as a proxy for network errors. However, the
+error 5 (i.e. OperationCanceledError) was not handled, which apparently happens
+a lot due to parallel loading of resources. We thus ignore this error in the
+loader.
+
+In addition, in case the error is greater than 1000, we find out the correct
+network error and display that error instead of HTTP error 1xxx which doesn't
+exist. The trick to find out the text values for the enum was taken from:
+
+https://blog.qt.digia.com/blog/2008/10/09/coding-tip-pretty-printing-enum-values/
+---
+ src/lib/multipageloader.cc |  2 +-
+ src/lib/utilities.cc       | 18 +++++++++++++++++-
+ 2 files changed, 18 insertions(+), 2 deletions(-)
+
+diff --git a/src/lib/multipageloader.cc b/src/lib/multipageloader.cc
+index 0f4e7f7..d74fa0d 100644
+--- a/src/lib/multipageloader.cc
++++ b/src/lib/multipageloader.cc
+@@ -335,7 +335,7 @@ void ResourceObject::error(const QString & str) {
+ void ResourceObject::amfinished(QNetworkReply * reply) {
+ 	int networkStatus = reply->error();
+ 	int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+-	if (networkStatus > 0 || (httpStatus > 399 && httpErrorCode == 0))
++	if ((networkStatus != 0 && networkStatus != 5) || (httpStatus > 399 && httpErrorCode == 0))
+ 	{
+ 		QFileInfo fi(reply->url().toString());
+ 		bool mediaFile = settings::LoadPage::mediaFilesExtensions.contains(fi.completeSuffix().toLower());
+diff --git a/src/lib/utilities.cc b/src/lib/utilities.cc
+index 639aa32..4238c47 100644
+--- a/src/lib/utilities.cc
++++ b/src/lib/utilities.cc
+@@ -27,6 +27,8 @@
+ #include "utilities.hh"
+ #include <QDebug>
+ #include <QTextStream>
++#include <QMetaEnum>
++#include <QNetworkReply>
+ 
+ void loadSvg(QSvgRenderer * & ptr, const QString & path, const char * def, int w, int h) {
+ 	 delete ptr;
+@@ -160,7 +162,21 @@ int handleError(bool success, int errorCode) {
+ 		if (ce.contains(errorCode)) c = ce[errorCode];
+ 		const char * m = "";
+ 		if (cm.contains(errorCode)) m = cm[errorCode];
+-		fprintf(stderr, "Exit with code %d due to http error: %d %s\n", c, errorCode, m);
++		if (errorCode < 1000) {
++			fprintf(stderr, "Exit with code %d due to http error: %d %s\n", c, errorCode, m);
++		} else {
++			QNetworkReply::NetworkError error = (QNetworkReply::NetworkError)(errorCode - 1000);
++			QString errorValue;
++			QMetaObject meta = QNetworkReply::staticMetaObject;
++			for (int i=0; i < meta.enumeratorCount(); ++i) {
++				QMetaEnum m = meta.enumerator(i);
++				if (m.name() == QLatin1String("NetworkError")) {
++					errorValue = QLatin1String(m.valueToKey(error));
++					break;
++				}
++			}
++			fprintf(stderr, "Exit with code %d due to network error: %s\n", c, errorValue.toLocal8Bit().data());
++		}
+ 		return c;
+ 	} else if (!success) {
+ 		fprintf(stderr, "Exit with code %d, due to unknown error.\n", EXIT_FAILURE);
+-- 
+2.0.0
+

Copied: wkhtmltopdf/repos/community-x86_64/0002-fix-compilation-failures-when-not-building-with-patc.patch (from rev 113061, wkhtmltopdf/trunk/0002-fix-compilation-failures-when-not-building-with-patc.patch)
===================================================================
--- community-x86_64/0002-fix-compilation-failures-when-not-building-with-patc.patch	                        (rev 0)
+++ community-x86_64/0002-fix-compilation-failures-when-not-building-with-patc.patch	2014-06-12 12:41:47 UTC (rev 113062)
@@ -0,0 +1,233 @@
+From ef708c2adb31062d73506917f03fd5e942594d33 Mon Sep 17 00:00:00 2001
+From: Ashish Kulkarni <kulkarni.ashish at gmail.com>
+Date: Sat, 15 Mar 2014 11:42:11 +0530
+Subject: [PATCH 2/2] fix compilation failures when not building with patched
+ QT/WebKit
+
+Apparently, no one uses the plain vanilla build as no one reported
+any issue for a long time. This will get it to compile and work at
+least for a sample page.
+
+Conflicts:
+	src/lib/pdfconverter.cc
+---
+ src/lib/pdfconverter.cc   | 33 +++++++++++++++++++++++++++------
+ src/lib/pdfconverter_p.hh | 14 +++++++++-----
+ 2 files changed, 36 insertions(+), 11 deletions(-)
+
+diff --git a/src/lib/pdfconverter.cc b/src/lib/pdfconverter.cc
+index b227c87..f883a00 100644
+--- a/src/lib/pdfconverter.cc
++++ b/src/lib/pdfconverter.cc
+@@ -78,9 +78,9 @@ bool DLL_LOCAL looksLikeHtmlAndNotAUrl(QString str) {
+ 
+ PdfConverterPrivate::PdfConverterPrivate(PdfGlobal & s, PdfConverter & o) :
+ 	settings(s), pageLoader(s.load),
+-	out(o), printer(0), painter(0), webPrinter(0)
++	out(o), printer(0), painter(0)
+ #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+-    , measuringHFLoader(s.load), hfLoader(s.load), tocLoader1(s.load), tocLoader2(s.load)
++    , webPrinter(0), measuringHFLoader(s.load), hfLoader(s.load), tocLoader1(s.load), tocLoader2(s.load)
+ 	, tocLoader(&tocLoader1), tocLoaderOld(&tocLoader2)
+     , outline(0), currentHeader(0), currentFooter(0)
+ #endif
+@@ -151,13 +151,15 @@ void PdfConverterPrivate::beginConvert() {
+ 		fail();
+ 		return;
+ 	}
+-#endif
++#else
+     bool headerHeightsCalcNeeded = false;
++#endif
+ 
+ 	for (QList<PageObject>::iterator i=objects.begin(); i != objects.end(); ++i) {
+ 		PageObject & o=*i;
+ 		settings::PdfObject & s = o.settings;
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+         if (!s.header.htmlUrl.isEmpty() ) {
+             if (looksLikeHtmlAndNotAUrl(s.header.htmlUrl)) {
+                 emit out.error("--header-html should be a URL and not a string containing HTML code.");
+@@ -195,6 +197,7 @@ void PdfConverterPrivate::beginConvert() {
+                 o.footerReserveHeight = settings.margin.bottom.first + s.footer.spacing;
+             }
+         }
++#endif
+ 
+ 		if (!s.isTableOfContent) {
+ 			o.loaderObject = pageLoader.addResource(s.page, s.load, &o.data);
+@@ -207,6 +210,7 @@ void PdfConverterPrivate::beginConvert() {
+ 	emit out.phaseChanged();
+ 	loadProgress(0);
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+     if (headerHeightsCalcNeeded) {
+         // preload header/footer to check their heights
+         measuringHFLoader.load();
+@@ -225,8 +229,12 @@ void PdfConverterPrivate::beginConvert() {
+ 
+         pageLoader.load();
+     }
++#else
++    pageLoader.load();
++#endif
+ }
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+ // calculates header/footer height
+ // returns millimeters
+ qreal PdfConverterPrivate::calculateHeaderHeight(PageObject & object, QWebPage & header) {
+@@ -252,6 +260,8 @@ qreal PdfConverterPrivate::calculateHeaderHeight(PageObject & object, QWebPage &
+     return (height / PdfConverter::millimeterToPointMultiplier);
+ }
+ 
++#endif
++
+ QPrinter * PdfConverterPrivate::createPrinter(const QString & tempFile) {
+     QPrinter * printer = new QPrinter(settings.resolution);
+     if (settings.dpi != -1) printer->setResolution(settings.dpi);
+@@ -275,6 +285,7 @@ QPrinter * PdfConverterPrivate::createPrinter(const QString & tempFile) {
+     return printer;
+ }
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+ void PdfConverterPrivate::preprocessPage(PageObject & obj) {
+ 	currentObject++;
+ 	if (obj.settings.isTableOfContent) {
+@@ -309,7 +320,7 @@ void PdfConverterPrivate::preprocessPage(PageObject & obj) {
+ 		outline->addEmptyWebPage();
+ 	painter->restore();
+ }
+-
++#endif
+ 
+ /*!
+  * Prepares printing out the document to the pdf file
+@@ -353,9 +364,15 @@ void PdfConverterPrivate::pagesLoaded(bool ok) {
+ 	}
+ 
+     //Setup margins and papersize
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+     printer->setPageMargins(settings.margin.left.first, objects[0].headerReserveHeight,
+                                 settings.margin.right.first, objects[0].footerReserveHeight,
+                                 settings.margin.left.second);
++#else
++    printer->setPageMargins(settings.margin.left.first, settings.margin.top.first,
++                                settings.margin.right.first, settings.margin.bottom.first,
++                                settings.margin.left.second);
++#endif
+ 
+ 	if ((settings.size.height.first != -1) && (settings.size.width.first != -1)) {
+ 		printer->setPaperSize(QSizeF(settings.size.width.first,settings.size.height.first), settings.size.height.second);
+@@ -656,7 +673,6 @@ void PdfConverterPrivate::endPage(PageObject & object, bool hasHeaderFooter, int
+ 	}
+ 
+ }
+-#endif
+ 
+ void PdfConverterPrivate::handleTocPage(PageObject & obj) {
+ 	painter->save();
+@@ -670,6 +686,7 @@ void PdfConverterPrivate::handleTocPage(PageObject & obj) {
+ 	tocChanged = outline->replaceWebPage(obj.number, obj.settings.toc.captionText, wp, obj.page->mainFrame(), obj.settings, obj.localLinks, obj.anchors) || tocChanged;
+ 	painter->restore();
+ }
++#endif
+ 
+ 
+ void PdfConverterPrivate::tocLoaded(bool ok) {
+@@ -731,6 +748,7 @@ void PdfConverterPrivate::measuringHeadersLoaded(bool ok) {
+         return;
+     }
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+     for (int d=0; d < objects.size(); ++d) {
+         PageObject & obj = objects[d];
+         if (obj.measuringHeader) {
+@@ -743,6 +761,7 @@ void PdfConverterPrivate::measuringHeadersLoaded(bool ok) {
+             obj.footerReserveHeight = calculateHeaderHeight(obj, *obj.measuringFooter) + obj.settings.header.spacing;
+         }
+     }
++#endif
+ 
+     pageLoader.load();
+ }
+@@ -758,6 +777,7 @@ void PdfConverterPrivate::headersLoaded(bool ok) {
+ 	printDocument();
+ }
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+ 
+ void PdfConverterPrivate::spoolPage(int page) {
+ 	progressString = QString("Page ") + QString::number(actualPage) + QString(" of ") + QString::number(actualPages);
+@@ -904,7 +924,8 @@ void PdfConverterPrivate::endPrintObject(PageObject & obj) {
+ 	}
+ 
+ }
+-			
++
++#endif
+ 
+ void PdfConverterPrivate::printDocument() {
+ #ifndef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+diff --git a/src/lib/pdfconverter_p.hh b/src/lib/pdfconverter_p.hh
+index 2cfa441..3679673 100644
+--- a/src/lib/pdfconverter_p.hh
++++ b/src/lib/pdfconverter_p.hh
+@@ -94,8 +94,11 @@ public:
+ 	}
+ 
+ 	PageObject(const settings::PdfObject & set, const QString * d=NULL):
+-        settings(set), loaderObject(0), page(0), headerReserveHeight(0), footerReserveHeight(0),
+-        measuringHeader(0), measuringFooter(0) {
++		settings(set), loaderObject(0), page(0)
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
++		, headerReserveHeight(0), footerReserveHeight(0), measuringHeader(0), measuringFooter(0)
++#endif
++	{
+ 		if (d) data=*d;
+ 	};
+ 
+@@ -134,6 +137,7 @@ private:
+ 	bool tocChanged;
+ 	int actualPage;
+ 	int pageNumber;
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+ 	QWebPrinter * webPrinter;
+ 	int objectPage;
+ 
+@@ -144,7 +148,6 @@ private:
+ 	QHash<int, QVector<QWebElement> > pageFormElements;
+ 	bool pageHasHeaderFooter;
+ 	
+-#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+     // loader for measuringHeader and measuringFooter
+     MultiPageLoader measuringHFLoader;
+ 
+@@ -163,14 +166,14 @@ private:
+ 	void fillParms(QHash<QString, QString> & parms, int page, const PageObject & object);
+ 	QString hfreplace(const QString & q, const QHash<QString, QString> & parms);
+ 	QWebPage * loadHeaderFooter(QString url, const QHash<QString, QString> & parms, const settings::PdfObject & ps);
+-
++    qreal calculateHeaderHeight(PageObject & object, QWebPage & header);
+ 
+ #endif
+ 	QWebPage * currentHeader;
+ 	QWebPage * currentFooter;
+-    qreal calculateHeaderHeight(PageObject & object, QWebPage & header);
+     QPrinter * createPrinter(const QString & tempFile);
+ 
++#ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
+ 	void handleTocPage(PageObject & obj);
+ 	void preprocessPage(PageObject & obj);
+ 	void spoolPage(int page);
+@@ -179,6 +182,7 @@ private:
+ 	void handleFooter(QWebPage * frame, int page);
+ 	void beginPrintObject(PageObject & obj);
+ 	void endPrintObject(PageObject & obj);
++#endif
+ 
+ 	void loadTocs();
+ 	void loadHeaders();
+-- 
+2.0.0
+

Deleted: community-x86_64/PKGBUILD
===================================================================
--- community-x86_64/PKGBUILD	2014-06-12 12:38:30 UTC (rev 113061)
+++ community-x86_64/PKGBUILD	2014-06-12 12:41:47 UTC (rev 113062)
@@ -1,30 +0,0 @@
-# $Id$
-# Maintainer: Evangelos Foutras <evangelos at foutrelis.com>
-
-pkgname=wkhtmltopdf
-pkgver=0.9.9
-pkgrel=2
-pkgdesc="Simple shell utility to convert html to pdf using the webkit rendering engine, and qt"
-arch=('i686' 'x86_64')
-url="http://code.google.com/p/wkhtmltopdf/"
-license=('GPL3')
-depends=('qtwebkit')
-optdepends=('xorg-server: wkhtmltopdf needs X or Xvfb to operate')
-source=(http://wkhtmltopdf.googlecode.com/files/$pkgname-$pkgver.tar.bz2)
-sha1sums=('41f598c0103326e7c13101391447b0284b4ba3cb')
-
-build() {
-  cd "$srcdir/$pkgname-$pkgver"
-
-  qmake wkhtmltopdf.pro
-  make
-}
-
-package() {
-  cd "$srcdir/$pkgname-$pkgver"
-  make INSTALL_ROOT="$pkgdir/usr" install
-
-  # Generate and install man page
-  install -d "$pkgdir/usr/share/man/man1"
-  ./wkhtmltopdf --manpage >"$pkgdir/usr/share/man/man1/wkhtmltopdf.1"
-}

Copied: wkhtmltopdf/repos/community-x86_64/PKGBUILD (from rev 113061, wkhtmltopdf/trunk/PKGBUILD)
===================================================================
--- community-x86_64/PKGBUILD	                        (rev 0)
+++ community-x86_64/PKGBUILD	2014-06-12 12:41:47 UTC (rev 113062)
@@ -0,0 +1,49 @@
+# $Id$
+# Maintainer: Evangelos Foutras <evangelos at foutrelis.com>
+
+pkgname=wkhtmltopdf
+pkgver=0.12.0
+pkgrel=1
+pkgdesc="Command line tools to render HTML into PDF and various image formats"
+arch=('i686' 'x86_64')
+url="http://wkhtmltopdf.org/"
+license=('GPL3')
+depends=('qtwebkit')
+optdepends=('xorg-server: wkhtmltopdf needs X or Xvfb to operate')
+source=($pkgname-$pkgver.tar.gz::https://github.com/wkhtmltopdf/wkhtmltopdf/archive/$pkgver.tar.gz
+        0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch
+        0002-fix-compilation-failures-when-not-building-with-patc.patch)
+sha256sums=('ad3449acc772bd687b3853e087033b7223e6298f4a59d21d09c08c9d006f693f'
+            'bc9ffc8a99a32f66882e406f25962a0753129c161530879ad23ee5bd189a2a66'
+            'ece5abbee4c9f37ab4b5df856dd708562dbf4e14374b9c60b41109f00c82c44b')
+
+prepare() {
+  cd "$srcdir/$pkgname-$pkgver"
+
+  # https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1502
+  patch -Np1 -i "$srcdir/0001-fix-spurious-exit-with-code-1-due-to-http-error-1xxx.patch"
+
+  # Fix build with system Qt
+  patch -Np1 -i "$srcdir/0002-fix-compilation-failures-when-not-building-with-patc.patch"
+}
+
+build() {
+  cd "$srcdir/$pkgname-$pkgver"
+
+  qmake-qt4 wkhtmltopdf.pro
+  make
+}
+
+package() {
+  cd "$srcdir/$pkgname-$pkgver"
+  make INSTALL_ROOT="$pkgdir/usr" install
+
+  # Generate and install man page
+  install -d "$pkgdir/usr/share/man/man1"
+  LD_LIBRARY_PATH=bin ./bin/wkhtmltopdf --manpage \
+    >"$pkgdir/usr/share/man/man1/wkhtmltopdf.1"
+  LD_LIBRARY_PATH=bin ./bin/wkhtmltoimage --manpage \
+    >"$pkgdir/usr/share/man/man1/wkhtmltoimage.1"
+}
+
+# vim:set ts=2 sw=2 et:




More information about the arch-commits mailing list