Browse Source

enable headless mode on Unix for non-patched Qt5 builds

This is available by default by using the "offscreen" QPA platform,
which has a default resolution of 800x600. If you want a different
resolution, you can set QT_QPA_PLATFORM to "xcb" in the environment
and run the program under X.
Ashish Kulkarni 7 years ago
parent
commit
a104752a0a
3 changed files with 10 additions and 0 deletions
  1. 3 0
      src/image/wkhtmltoimage.cc
  2. 4 0
      src/lib/pdf_c_bindings.cc
  3. 3 0
      src/pdf/wkhtmltopdf.cc

+ 3 - 0
src/image/wkhtmltoimage.cc

@@ -33,6 +33,9 @@
 int main(int argc, char** argv) {
 #if defined(Q_OS_UNIX)
 	setlocale(LC_ALL, "");
+#if QT_VERSION >= 0x050000 && !defined(__EXTENSIVE_WKHTMLTOPDF_QT_HACK__)
+	setenv("QT_QPA_PLATFORM", "offscreen", 0);
+#endif
 #endif
 	//This will store all our settings
 	wkhtmltopdf::settings::ImageGlobal settings;

+ 4 - 0
src/lib/pdf_c_bindings.cc

@@ -292,6 +292,10 @@ CAPI(int) wkhtmltopdf_init(int use_graphics) {
 		char * arg[] = {x, 0};
 		int aa = 1;
 
+#if QT_VERSION >= 0x050000 && defined(Q_OS_UNIX) && !defined(__EXTENSIVE_WKHTMLTOPDF_QT_HACK__)
+		setenv("QT_QPA_PLATFORM", "offscreen", 0);
+#endif
+
 		bool ug = true;
 #if defined(Q_OS_UNIX) || defined(Q_OS_MAC)
 #ifdef __EXTENSIVE_WKHTMLTOPDF_QT_HACK__

+ 3 - 0
src/pdf/wkhtmltopdf.cc

@@ -165,6 +165,9 @@ char * fgets_large(FILE * fp)
 int main(int argc, char * argv[]) {
 #if defined(Q_OS_UNIX)
 	setlocale(LC_ALL, "");
+#if QT_VERSION >= 0x050000 && !defined(__EXTENSIVE_WKHTMLTOPDF_QT_HACK__)
+	setenv("QT_QPA_PLATFORM", "offscreen", 0);
+#endif
 #endif
 	//This will store all our settings
 	PdfGlobal globalSettings;