Antialize 16 years ago
parent
commit
54a8be722a
3 changed files with 234 additions and 128 deletions
  1. 18 12
      src/toc.cc
  2. 184 116
      src/wkhtmltopdf.cc
  3. 32 0
      src/wkhtmltopdf.hh

+ 18 - 12
src/toc.cc

@@ -18,13 +18,17 @@
 #include <QtGui>
 #include <QtGui>
 #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 
 
-// /*!
-//  * Build a toc structure out of headings elements
-//  * \param root The root node of the Toc tree
-//  * \param headings The headings extracted from the html document
-//  * \paran firstPage Offset numbering of the pages
-//  */
-// void buildToc(TocItem * root, const QVector<QWebFrame::Heading> & headings, uint firstPage) {
+/*!
+ * Build a toc structure out of headings elements
+ * \param root The root node of the Toc tree
+ * \param headings The headings extracted from the html document
+ * \paran firstPage Offset numbering of the pages
+ */
+// void buildToc(TocItem * root, 
+// 			  const QList<QWebElement> & headings, 
+// 			  QHash<QString, QWebElement> & anchors,
+// 			  QVector< QPair<QWebElement, QString> >  & links,
+// 			  uint firstPage) {
 // 	//This huristic is a little strange, it tries to create a real tree,
 // 	//This huristic is a little strange, it tries to create a real tree,
 // 	//even though someone puts a h5 below a h1 or stuff like that
 // 	//even though someone puts a h5 below a h1 or stuff like that
 // 	//The way this is handled is having a level stack, indicating what h-tags
 // 	//The way this is handled is having a level stack, indicating what h-tags
@@ -32,12 +36,14 @@
 // 	QVector<uint> levelStack;
 // 	QVector<uint> levelStack;
 // 	levelStack.push_back(0);
 // 	levelStack.push_back(0);
 // 	TocItem * old = root;
 // 	TocItem * old = root;
-// 	for (int i=0; i < headings.size(); ++i) {
-// 		const QWebFrame::Heading & h = headings[i];
+// 	for (QList<QWebElement>::const_iterator i=headings.begin(); i != headings.end(); ++i) {
+// 		const QWebElement & h = *i;
+		
+// 		//Todo extract text;
 // 		TocItem * item = new TocItem();
 // 		TocItem * item = new TocItem();
-// 		item->page = firstPage + h.page;
-// 		item->value = h.text;
-// 		item->location = h.locationOnPage;
+// 		//item->page = firstPage + h.page;
+// 		//item->value = h.text;
+// 		//item->location = h.locationOnPage;
 // 		while (levelStack.back() >= h.level) {
 // 		while (levelStack.back() >= h.level) {
 // 			old = old->parent;
 // 			old = old->parent;
 // 			levelStack.pop_back();
 // 			levelStack.pop_back();

+ 184 - 116
src/wkhtmltopdf.cc

@@ -263,7 +263,7 @@ void WKHtmlToPdf::sslErrors(QNetworkReply *reply, const QList<QSslError> &error)
 /*!
 /*!
  * Print out the document to the pdf file
  * Print out the document to the pdf file
  */
  */
-void WKHtmlToPdf::printPage() {
+void WKHtmlToPdf::preparePrint() {
 	//If there are still pages loading wait til they are done
 	//If there are still pages loading wait til they are done
 	if (loading != 0) return;
 	if (loading != 0) return;
 	//Give some user feed back
 	//Give some user feed back
@@ -272,10 +272,10 @@ void WKHtmlToPdf::printPage() {
 		fflush(stdout);
 		fflush(stdout);
 	}
 	}
 
 
-	QPrinter printer(resolution);
+	printer = new QPrinter(resolution);
 	
 	
 	QString lout = out;
 	QString lout = out;
-	if (dpi != -1) printer.setResolution(dpi);
+	if (dpi != -1) printer->setResolution(dpi);
 	if (!strcmp(out,"-")) {
 	if (!strcmp(out,"-")) {
 		if (QFile::exists("/dev/stdout"))
 		if (QFile::exists("/dev/stdout"))
 			lout = "/dev/stdout";
 			lout = "/dev/stdout";
@@ -285,13 +285,11 @@ void WKHtmlToPdf::printPage() {
 		}
 		}
 	}
 	}
 	//Tell the printer object to print the file <out>
 	//Tell the printer object to print the file <out>
-	printer.setOutputFormat(
+	printer->setOutputFormat(
 	    strcmp(out + (strlen(out)-3),".ps")==0?
 	    strcmp(out + (strlen(out)-3),".ps")==0?
 	    QPrinter::PostScriptFormat : QPrinter::PdfFormat
 	    QPrinter::PostScriptFormat : QPrinter::PdfFormat
 	);
 	);
-	printer.setOutputFileName(lout);
-
-	this->printer = &printer;
+	printer->setOutputFileName(lout);
 
 
 	//We currently only support margins with the same unit
 	//We currently only support margins with the same unit
 	if (margin_left.second != margin_right.second ||
 	if (margin_left.second != margin_right.second ||
@@ -302,14 +300,14 @@ void WKHtmlToPdf::printPage() {
 	}
 	}
 
 
 	//Setup margins and papersize
 	//Setup margins and papersize
-	printer.setPageMargins(margin_left.first, margin_top.first,
+	printer->setPageMargins(margin_left.first, margin_top.first,
 	                       margin_right.first, margin_bottom.first,
 	                       margin_right.first, margin_bottom.first,
 	                       margin_left.second);
 	                       margin_left.second);
-	printer.setPageSize(pageSize);
-	printer.setOrientation(orientation);
-	printer.setColorMode(colorMode);
+	printer->setPageSize(pageSize);
+	printer->setOrientation(orientation);
+	printer->setColorMode(colorMode);
 
 
-	if (!printer.isValid()) {
+	if (!printer->isValid()) {
 		fprintf(stderr,"Unable to write to output file\n");
 		fprintf(stderr,"Unable to write to output file\n");
 		exit(1);
 		exit(1);
 	}
 	}
@@ -322,16 +320,17 @@ void WKHtmlToPdf::printPage() {
 	printer.setCollateCopies(collate);
 	printer.setCollateCopies(collate);
 	pages[0]->mainFrame()->print(&printer);
 	pages[0]->mainFrame()->print(&printer);
 #else
 #else
-	QPainter painter;
-	painter.begin(&printer);
-
-	int cc=collate?copies:1;
-	int pc=collate?1:copies;
-			
-	QHash<int, QHash<QString, QWebElement> > anchors;
-	QHash<int, QVector< QPair<QWebElement,QString> > > localLinks;
-	QHash<int, QVector< QPair<QWebElement,QString> > > externalLinks;
+	painter = new QPainter();
+	painter->begin(printer);
 	
 	
+	logicalPages = 0;
+	actualPages = 0;
+	pageCount.clear();
+	tocPages = 0;
+	anchors.clear();
+	localLinks.clear();
+	externalLinks.clear();
+
 	//Find and resolve all local links
 	//Find and resolve all local links
 	if(useLocalLinks || useExternalLinks) {
 	if(useLocalLinks || useExternalLinks) {
 		QHash<QString, int> urlToDoc;
 		QHash<QString, int> urlToDoc;
@@ -372,86 +371,129 @@ void WKHtmlToPdf::printPage() {
 			}
 			}
 		}
 		}
 	}
 	}
-			
-
-	//Find the header elements, we need them now to figure out the number of pages of
-	//TOC
-// 	if(print_toc || outline) {
-// 		for(int d=0; d < pages.size(); ++d) {
-// 			QList<QWebElement> l = pages[d]->mainFrame()->findAllElements("h1,h2,h3,h4,h5,h6,h7,h8,h9");
-//if (!quiet) {
-// 				fprintf(stderr, "Finding headings %d of %d      \r",i,in.size());
-// 				fflush(stdout);
-// 			}
-// 			for(QList<QWebElement>::iterator i=l.begin(); i != l.end(); ++l) {
-// 			}
-// 		}
-// 	}
-
-	int logicalPages = 0;
-	int actualPages = 0;;
-	//Count the number of pages
+	
+	//This is the first render face, it is done to calculate:
+	// * The number of pages of each document
+	// * A visual ordering of the header elemnt
+	// * The location and page number of each header
 	for(int d=0; d < pages.size(); ++d) {
 	for(int d=0; d < pages.size(); ++d) {
 		if (!quiet) {
 		if (!quiet) {
-			fprintf(stderr, "Counting pages %d of %d      \r",d+1,pages.size());
+			fprintf(stderr, "Counting pages %d of %d      \r",d+1,pages.size()+(print_toc?1:0));
 			fflush(stdout);
 			fflush(stdout);
 		}
 		}
 
 
-		painter.save();
-		QWebPrinter wp(pages[d]->mainFrame(), &printer, painter);
-		painter.restore();
-		actualPages += wp.pageCount();
-		if (cover[0] && d == 0) {
-			continue;
-		}
-		logicalPages += wp.pageCount();
+		painter->save();
+		QWebPrinter wp(pages[d]->mainFrame(), printer, *painter);
+		int count = wp.pageCount();
+		pageCount.push_back(count);
+		actualPages += count;
+		if (!cover[0] || d != 0) {
+			logicalPages += count;
+			QList<QWebElement> l = pages[d]->mainFrame()->findAllElements("h1,h2,h3,h4,h5,h6,h7,h8,h9");
+			for(QList<QWebElement>::const_iterator i = l.begin(); i != l.end(); ++i) {
+				QPair<int, QRectF> location = wp.elementLocation(*i);
+				headings[d][ qMakePair(location.first, qMakePair(location.second.y(), location.second.x()) ) ] = *i;
+			}
+		} 
+		painter->restore();
 	}
 	}
+
+	//Now that we know the ordering of the headers in each document we
+	//can calculate the number of pages in the table of content
+	if (print_toc) {
+		if (!quiet) {
+			fprintf(stderr, "Counting pages %d of %d      \r",pages.size()+1,pages.size()+1);
+ 			fflush(stdout);
+ 		}									   
+ 		TocItem * root = new TocItem();
+		for(int d=0; d < pages.size(); ++d) {
+			if (cover[0] && d == 0) continue;
+			// buildToc(root,pages[d]->mainFrame(),
+// 					 anchors[d], externalLinks[d]
+// 					 ,-1);
+		}
+// 		int p = tocPrinter.countPages(root, &printer, painter);;
+		actualPages += tocPages;
+		logicalPages += tocPages;
+ 		delete root;
+   	}
 	actualPages *= copies;
 	actualPages *= copies;
-	
-	// 	QVector< QVector<QWebFrame::Heading> > headings;
-//	
-// 		for (int i=0; i < in.size(); ++i) {
-// 			if (cover[0] && i == 0) {
-// 				headings.push_back( QVector<QWebFrame::Heading>() );
-// 				continue;
-// 			}
-// 			
-// 			headings.push_back(pages[i]->mainFrame()->headings(&printer, printMediaType));
-// 		}
+	int page=1;
+	headerFooterLoading = 0;
 
 
-//	}
+	html_header="header.html";
 
 
-// 	if (print_toc) {
-// 		TocItem * root = new TocItem();
-// 		for (int i=0; i < in.size(); ++i)buildToc(root,headings[i],0);
-// 		pageStart.back() += tocPrinter.countPages(root, &printer, &painter);
-// 		delete root;
-// 	}
-// 	for (int i=0; i < in.size(); ++i) {
-// 		if (cover[0] && i == 0) {
-// 			pageStart.push_front(0);
-// 			pageStart.back() +=  pages[i]->mainFrame()->countPages(&printer, printMediaType);
-// 			continue;
-// 		}
-// 		int count = pages[i]->mainFrame()->countPages(&printer, printMediaType);
-// 		pageStart.push_back( pageStart.back() + count );
-// 	}
+	if(!html_header.isEmpty() || !html_header.isEmpty()) {
+		for(int d=0; d < pages.size(); ++d) {
+			if (cover[0] && d == 0) continue;
+			for(int p=0; p < pageCount[d]; ++p) {
+				if(!html_header.isEmpty())
+					headers.push_back(loadHeaderFooter(html_header, d, page) );
+				if(!html_footer.isEmpty())
+					footers.push_back(loadHeaderFooter(html_footer, d, page) );
+				++page;
+			}
+		}
+	} else 
+		printPage();
+#endif
+}
 
 
+QHash<QString, QString> WKHtmlToPdf::calculateHeaderFooterParams(int d, int page) {
+	return QHash<QString, QString>();
+}
 
 
-// 	TocItem * root = NULL;
-// 	if (print_toc || outline) {
-// 		root = new TocItem();
-// 		//for (int i=0; i < in.size(); ++i) buildToc(root,headings[i],pageStart[i]+1);
-// 		//tocPrinter.populateSections(root);
-// 	}
-// 	TocItem toc;
-// 	if (print_toc) {
-// 		tocPrinter.page2sectionshigh[0][0] = &toc;
-// 		tocPrinter.page2sectionslow[0][0] = &toc;
-// 		toc.value = QString(tocPrinter.header_text);
+QWebPage * WKHtmlToPdf::loadHeaderFooter(QString url, int d, int page) {
+	QUrl u = guessUrlFromString(url);
 
 
-// 	}
+	QHash<QString, QString> values = calculateHeaderFooterParams(d, page);
+	for(QHash<QString, QString>::iterator i=values.begin(); i != values.end(); ++i)
+		u.addQueryItem(i.key(), i.value());
+	
+	QWebPage * p = new QWebPage();
+	p->setNetworkAccessManager(am);
+	connect(p, SIGNAL(loadFinished(bool)), this, SLOT(headerFooterLoadFinished(bool)));
+	connect(p, SIGNAL(loadStarted()), this, SLOT(headerFooterLoadStarted()));
+	p->mainFrame()->setZoomFactor(zoom_factor);
+
+	p->mainFrame()->load(u);
+	return p;
+}
+
+void WKHtmlToPdf::headerFooterLoadStarted() {
+	headerFooterLoading.ref();
+}
 
 
+void WKHtmlToPdf::headerFooterLoadFinished(bool) {
+	headerFooterLoading.deref();
+	//qDebug() << "hat";
+	if (headerFooterLoading == 0) {
+		//Wait a little while for js-redirects, and then print
+		QTimer::singleShot(100, this, SLOT(printPage()));
+	}
+}
+
+void WKHtmlToPdf::printPage() {
+	if (headerFooterLoading != 0 || loading != 0) return;
+
+	QPrinter p2(resolution);
+	if (dpi != -1) p2.setResolution(dpi);
+	p2.setOutputFormat(
+		strcmp(out + (strlen(out)-3),".ps")==0?
+		QPrinter::PostScriptFormat : QPrinter::PdfFormat
+		);
+	p2.setOutputFileName("foo.pdf");
+	
+	//Setup margins and papersize
+	p2.setPageMargins(margin_left.first, margin_top.first,
+					  margin_right.first, margin_bottom.first,
+					  margin_left.second);
+	p2.setPageSize(pageSize);
+	p2.setOrientation(orientation);
+	p2.setColorMode(colorMode);
+	QPainter pa2;
+	pa2.begin(&p2);
+	
 // 	for (int i=0; i < in.size(); ++i) {
 // 	for (int i=0; i < in.size(); ++i) {
 // 		currentPage = i;
 // 		currentPage = i;
 // 		if (i != 0) printer.newPage();
 // 		if (i != 0) printer.newPage();
@@ -463,17 +505,17 @@ void WKHtmlToPdf::printPage() {
 // 		}
 // 		}
 // 		pages[i]->mainFrame()->print(&printer,&painter, printMediaType);
 // 		pages[i]->mainFrame()->print(&printer,&painter, printMediaType);
 // 	}
 // 	}
-
-	bool first=true;
-	int actualPage=1;
-	int anchorID=0;
+ 	bool first=true;
+ 	int actualPage=1;
+ 	int cc=collate?copies:1;
+ 	int pc=collate?1:copies;
    
    
 	for(int cc_=0; cc_ < cc; ++cc_) {
 	for(int cc_=0; cc_ < cc; ++cc_) {
 		//TODO print front here
 		//TODO print front here
 		//TODO print TOC here
 		//TODO print TOC here
 		for(int d=0; d < pages.size(); ++d) {
 		for(int d=0; d < pages.size(); ++d) {
-			painter.save();
-			QWebPrinter wp(pages[d]->mainFrame(), &printer, painter);
+			painter->save();
+			QWebPrinter wp(pages[d]->mainFrame(), printer, *painter);
 			QString l1=pages[d]->mainFrame()->url().path().split("/").back()+"#";
 			QString l1=pages[d]->mainFrame()->url().path().split("/").back()+"#";
 			QString l2=pages[d]->mainFrame()->url().toString() + "#";
 			QString l2=pages[d]->mainFrame()->url().toString() + "#";
 
 
@@ -502,34 +544,54 @@ void WKHtmlToPdf::printPage() {
 					if(first)
 					if(first)
 						first=false;
 						first=false;
 					else
 					else
-						printer.newPage();
+						printer->newPage();
 
 
 					wp.spoolPage(p+1);
 					wp.spoolPage(p+1);
 					
 					
 					for(QHash<QString, QWebElement>::iterator i=myAnchors[p+1].begin();
 					for(QHash<QString, QWebElement>::iterator i=myAnchors[p+1].begin();
 						i != myAnchors[p+1].end(); ++i) {
 						i != myAnchors[p+1].end(); ++i) {
 						QRectF r = wp.elementLocation(i.value()).second;
 						QRectF r = wp.elementLocation(i.value()).second;
-						painter.addAnchor(r, i.key());
+						painter->addAnchor(r, i.key());
 					}
 					}
 					for(QVector< QPair<QWebElement,QString> >::iterator i=myLocalLinks[p+1].begin();
 					for(QVector< QPair<QWebElement,QString> >::iterator i=myLocalLinks[p+1].begin();
 						i != myLocalLinks[p+1].end(); ++i)  {
 						i != myLocalLinks[p+1].end(); ++i)  {
 						QRectF r = wp.elementLocation(i->first).second;
 						QRectF r = wp.elementLocation(i->first).second;
-						painter.addLink(r, i->second);
+						painter->addLink(r, i->second);
 					}
 					}
 					for(QVector< QPair<QWebElement,QString> >::iterator i=myExternalLinks[p+1].begin();
 					for(QVector< QPair<QWebElement,QString> >::iterator i=myExternalLinks[p+1].begin();
 						i != myExternalLinks[p+1].end(); ++i)  {
 						i != myExternalLinks[p+1].end(); ++i)  {
 						QRectF r = wp.elementLocation(i->first).second;
 						QRectF r = wp.elementLocation(i->first).second;
-						painter.addHyperlink(r, QUrl(i->second));
+						painter->addHyperlink(r, QUrl(i->second));
 					}
 					}
-		
-
 					++actualPage;
 					++actualPage;
+
+
+// 					QTransform t;
+// 					{
+// 						pa2.save();
+// 						QWebPrinter whp2(headers[0]->mainFrame(), &p2, pa2);
+// 						whp2.spoolPage(1);
+// 						t = pa2.transform();
+// 						pa2.restore();
+// 					}
+					{
+						painter->save();
+						painter->resetTransform();
+						QWebPrinter whp(headers[0]->mainFrame(), printer, *painter);		
+						qreal off=t.mapRect(
+							whp.elementLocation(headers[0]->mainFrame()->findFirstElement("body")).second).height();
+						qDebug() << off;
+						painter->translate(0,-off);
+						whp.spoolPage(1);
+						painter->restore();
+					}
  				}
  				}
+
 			}
 			}
-			painter.restore();
+			painter->restore();
 		}
 		}
-	}
-
+ 	}
+	
 // #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 // #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 // 	if (currentPage == 0 && cover[0]) return;
 // 	if (currentPage == 0 && cover[0]) return;
 // #endif
 // #endif
@@ -574,23 +636,29 @@ void WKHtmlToPdf::printPage() {
 // 	if (outline) tocPrinter.outline(root, &printer);
 // 	if (outline) tocPrinter.outline(root, &printer);
 // 	if (root) delete root;
 // 	if (root) delete root;
 
 
-	painter.end();
-#endif
-	if (loading != 0) return;
+ 	painter->end();
+
+	if (headerFooterLoading != 0 || loading != 0) return;
 
 
 	if (!quiet) {
 	if (!quiet) {
 		fprintf(stderr,"Done                 \n");
 		fprintf(stderr,"Done                 \n");
 		fflush(stderr);
 		fflush(stderr);
 	}
 	}
-	for (int i=0; i < pages.size(); ++i) delete pages[i];
-	if (!strcmp(out,"-") && lout != "/dev/stdout") {
-		QFile i(lout);
-		QFile o;
-		i.open(QIODevice::ReadOnly);
-		o.open(stdout,QIODevice::WriteOnly);
-		copyFile(i,o);
-	}
-	for (int i=0; i < temp.size(); ++i) QFile::remove(temp[i]);
+ 	for (int i=0; i < pages.size(); ++i) delete pages[i];
+	pages.clear();
+// 	for (int i=0; i < headers.size(); ++i) delete headers[i];
+// 	headers.clear();
+// 	for (int i=0; i < footers.size(); ++i) delete footers[i];
+// 	footers.clear();		
+
+// 	if (!strcmp(out,"-") && lout != "/dev/stdout") {
+// 		QFile i(lout);
+// 		QFile o;
+// 		i.open(QIODevice::ReadOnly);
+// 		o.open(stdout,QIODevice::WriteOnly);
+// 		copyFile(i,o);
+// 	}
+// 	for (int i=0; i < temp.size(); ++i) QFile::remove(temp[i]);
    
    
 	switch(networkError) {
 	switch(networkError) {
 	case 401: 
 	case 401: 
@@ -627,7 +695,7 @@ void WKHtmlToPdf::loadFinished(bool ok) {
 
 
 	if (loading == 0) {
 	if (loading == 0) {
 		//Wait a little while for js-redirects, and then print
 		//Wait a little while for js-redirects, and then print
-		QTimer::singleShot(jsredirectwait, this, SLOT(printPage()));
+		QTimer::singleShot(jsredirectwait, this, SLOT(preparePrint()));
 	}
 	}
 }
 }
 
 

+ 32 - 0
src/wkhtmltopdf.hh

@@ -56,6 +56,10 @@ public:
 	QVector<QWebPage *> pages;
 	QVector<QWebPage *> pages;
 	QVector<uint> pageStart;
 	QVector<uint> pageStart;
 
 
+	QVector<QWebPage *> headers;
+	QVector<QWebPage *> footers;
+
+
 	//Configuration variabels
 	//Configuration variabels
 	QVector<const char *> in; //Names of the input files
 	QVector<const char *> in; //Names of the input files
 	const char * out; //Name of the output file
 	const char * out; //Name of the output file
@@ -110,15 +114,37 @@ public:
 	QVector<QString> temp;
 	QVector<QString> temp;
 	QMap<QString, ArgHandler *> longToHandler; //Map from the long name of an argument, to its handler
 	QMap<QString, ArgHandler *> longToHandler; //Map from the long name of an argument, to its handler
 	QMap<char, ArgHandler *> shortToHandler; //Map form the short switch of an argument, to its handlr
 	QMap<char, ArgHandler *> shortToHandler; //Map form the short switch of an argument, to its handlr
+
+	QString html_header;
+	QString html_footer;
+
 	int currentPage;
 	int currentPage;
 	int pageNum;
 	int pageNum;
 	int loginTry;
 	int loginTry;
 
 
+	QAtomicInt headerFooterLoading;
+	QPainter * painter;
+
+	QHash<int, QHash<QString, QWebElement> > anchors;
+	QHash<int, QVector< QPair<QWebElement,QString> > > localLinks;
+	QHash<int, QVector< QPair<QWebElement,QString> > > externalLinks;
+	int logicalPages;
+	int actualPages;
+	QList<int> pageCount;
+	QHash<int, QMap< QPair<int, QPair<qreal,qreal> >, QWebElement> > headings;
+	int tocPages;
+
+	
 	int networkError;
 	int networkError;
 #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 #ifdef  __EXTENSIVE_WKHTMLTOPDF_QT_HACK__
 	TocPrinter tocPrinter;
 	TocPrinter tocPrinter;
 #endif
 #endif
 
 
+	
+	QHash<QString, QString> calculateHeaderFooterParams(int document, int page);
+	QWebPage * loadHeaderFooter(QString url, int document, int page);
+
+
 	//Add a new argument to the list of handled arguments
 	//Add a new argument to the list of handled arguments
 	void addarg(QString l, char s, QString desc, ArgHandler * h, bool display=true);
 	void addarg(QString l, char s, QString desc, ArgHandler * h, bool display=true);
 
 
@@ -144,6 +170,12 @@ public slots:
 	void sslErrors(QNetworkReply *reply, const QList<QSslError> &error);
 	void sslErrors(QNetworkReply *reply, const QList<QSslError> &error);
 	void authenticationRequired(QNetworkReply *     , QAuthenticator *);
 	void authenticationRequired(QNetworkReply *     , QAuthenticator *);
 	void printPage();
 	void printPage();
+	void preparePrint();
+
+
+	void headerFooterLoadStarted();
+	void headerFooterLoadFinished(bool ok);
+
 	void loadStarted();
 	void loadStarted();
 	void resetPages();
 	void resetPages();
 };
 };