소스 검색

Fix issue 165: Add a title to the pdf document

Antialize 15 년 전
부모
커밋
3b62760762
3개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      src/arguments.cc
  2. 6 1
      src/pageconverter.cc
  3. 1 0
      src/settings.hh

+ 1 - 1
src/arguments.cc

@@ -480,9 +480,9 @@ CommandLineParserPrivate::CommandLineParserPrivate(Settings & s):
 	addarg("read-args-from-stdin",0,"Read command line arguments from stdin", new ConstSetter<bool>(s.readArgsFromStdin,true,false));
 	addarg("cookie-jar", 0, "Read and write cookies from and to the supplied cookie jar file", new QStrSetter(s.cookieJar, "path", "") );
 	addarg("cookie",0,"Set an additional cookie (repeatable)", new MapSetter<>(s.cookies, "name", "value"));
-
 	addarg("post", 0, "Add an additional post field (repeatable)", new MapSetter<PostItemCreator<false> >(s.post, "name", "value"));
 	addarg("post-file", 0, "Post an aditional file (repeatable)", new MapSetter<PostItemCreator<true> >(s.post, "name", "path"));
+	addarg("title", 0, "The title of the generated pdf file (The title of the first document is used if not specified)", new QStrSetter(s.documentTitle,"text",""));
 	qthack(true);
 	addarg("disable-internal-links",0,"Do no make local links", new ConstSetter<bool>(s.useLocalLinks,false,true));
 	addarg("disable-external-links",0,"Do no make links to remote web pages", new ConstSetter<bool>(s.useExternalLinks,false,true));

+ 6 - 1
src/pageconverter.cc

@@ -229,6 +229,11 @@ void PageConverterPrivate::preparePrint(bool ok) {
 	printPage(true);
 #else
 	painter = new QPainter();
+	
+	QString title = settings.documentTitle;
+	if (title == "") 
+		title = pages[0]->mainFrame()->title();
+	printer->setDocName(title);
 	if (!painter->begin(printer)) {
 		emit outer.error("Unable to write to destination");
 		fail();
@@ -450,7 +455,7 @@ void PageConverterPrivate::printPage(bool ok) {
 
 	progressString = "Preparing";
 	emit outer.progressChanged(0);
-	
+			
 	for(int cc_=0; cc_ < cc; ++cc_) {
 		logicalPage=1;
 		for(int d=0; d < pages.size(); ++d) {

+ 1 - 0
src/settings.hh

@@ -191,6 +191,7 @@ struct Settings {
 	QString cookieJar;
 	
 	QList< PostItem > post;
+	QString documentTitle;
 
 	static QPrinter::PageSize strToPageSize(const char * s, bool * ok=0);
 	static QPair<qreal, QPrinter::Unit> strToUnitReal(const char * s, bool * ok=0);