浏览代码

Add --height option to set viewport height

Adam Thorsen 15 年之前
父节点
当前提交
0f7a2668e1

+ 3 - 0
include/wkhtmltox/imagesettings.hh

@@ -79,6 +79,9 @@ struct DLL_PUBLIC ImageGlobal {
 	//! Set the screen width
 	int screenWidth;
 
+	//! Set the screen height
+	int screenHeight;
+
 	//! Image Quality
 	int quality;
 

+ 1 - 0
src/image/imagearguments.cc

@@ -32,6 +32,7 @@ ImageCommandLineParser::ImageCommandLineParser(wkhtmltopdf::settings::ImageGloba
 	extended(false);
 	qthack(false);
 	addarg("width",0,"Set screen width (default is 1024)", new IntSetter(s.screenWidth,"int"));
+  addarg("height",0,"Set screen height (default is calculated from page content)", new IntSetter(s.screenHeight, "int"));
 	// addarg("scale-w",0,"Set width for resizing", new IntSetter(s.scale.width,"int"));
 	// addarg("scale-h",0,"Set height for resizing", new IntSetter(s.scale.height,"int"));
 

+ 4 - 1
src/lib/imageconverter.cc

@@ -133,7 +133,10 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 	}
 	loaderObject->page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
 	//Set the right height
-	loaderObject->page.setViewportSize(QSize(highWidth, frame->contentsSize().height()));
+  if(settings.screenHeight > 0)
+    loaderObject->page.setViewportSize(QSize(highWidth, settings.screenHeight));
+  else
+    loaderObject->page.setViewportSize(QSize(highWidth, frame->contentsSize().height()));
 
 	QPainter painter;
 	QSvgGenerator generator;

+ 2 - 0
src/lib/imagesettings.cc

@@ -45,6 +45,7 @@ template<>
 struct DLL_LOCAL ReflectImpl<ImageGlobal>: public ReflectClass {
 	ReflectImpl(ImageGlobal & c) {
 		WKHTMLTOPDF_REFLECT(screenWidth);
+		WKHTMLTOPDF_REFLECT(screenHeight);
 		WKHTMLTOPDF_REFLECT(quiet);
 		WKHTMLTOPDF_REFLECT(transparent);
 		WKHTMLTOPDF_REFLECT(useGraphics);
@@ -64,6 +65,7 @@ CropSettings::CropSettings():
 
 ImageGlobal::ImageGlobal():
 	screenWidth(1024),
+	screenHeight(0),
 	quiet(false),
 	transparent(false),
 	useGraphics(false),

+ 3 - 0
src/lib/imagesettings.hh

@@ -82,6 +82,9 @@ struct DLL_PUBLIC ImageGlobal {
 	//! Set the screen width
 	int screenWidth;
 
+	//! Set the screen height
+	int screenHeight;
+
 	//! Image Quality
 	int quality;