Browse Source

Merged patch from rafael bedia: Allow starting page to have a different number

Jakob Truelsen 16 years ago
parent
commit
a09bc063c6
3 changed files with 5 additions and 3 deletions
  1. 1 0
      arguments.cc
  2. 3 3
      wkhtmltopdf.cc
  3. 1 0
      wkhtmltopdf.hh

+ 1 - 0
arguments.cc

@@ -373,6 +373,7 @@ void WKHtmlToPdf::initArgs() {
 	addarg("header-left",0,"Left aligned header text", new AHStrSetter(header_left,"text",""));
 	addarg("header-line",0,"Display line below the header", new AHConstSetter<bool>(header_line,true,false));
 	addarg("header-right",0,"Right aligned header text", new AHStrSetter(header_right,"text",""));
+	addarg("page-offset",0,"Set the starting page number", new AHIntSetter(page_offset,"offset",1));
 	addarg("toc",'t',"Insert a table of content in the beginning of the document", new AHConstSetter<bool>(print_toc,true,false));
 	addarg("toc-font-name",0,"Set the font used for the toc", new AHStrSetter(tocPrinter.font_name,"name","Arial"));
 	addarg("toc-no-dots",0,"Do not use dots, in the toc", new AHConstSetter<bool>(tocPrinter.useDots,false,true));

+ 3 - 3
wkhtmltopdf.cc

@@ -146,9 +146,9 @@ QString WKHtmlToPdf::hfreplace(const QString & q) {
 	}
 #endif
 	return _
-		.replace("[page]",QString::number(pageNum),Qt::CaseInsensitive)
-		.replace("[toPage]",QString::number(pageStart.back()),Qt::CaseInsensitive)
-		.replace("[fromPage]",QString::number(1),Qt::CaseInsensitive)
+		.replace("[page]",QString::number(pageNum+page_offset-1),Qt::CaseInsensitive)
+		.replace("[toPage]",QString::number(pageStart.back()+page_offset-1),Qt::CaseInsensitive)
+		.replace("[fromPage]",QString::number(page_offset),Qt::CaseInsensitive)
 #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 		.replace("[section]",sec[0],Qt::CaseInsensitive)
 		.replace("[subsection]",sec[1],Qt::CaseInsensitive)

+ 1 - 0
wkhtmltopdf.hh

@@ -76,6 +76,7 @@ public:
 	QPrinter::ColorMode colorMode; //Color or grayscale
 	QPrinter::PrinterMode resolution; //resolution
 	int dpi; //The printing dpi
+	int page_offset;
 	//Specify page margins
 	QPair<qreal, QPrinter::Unit> margin_top;
 	QPair<qreal, QPrinter::Unit> margin_right;