@@ -124,7 +124,9 @@ void HTMLRenderer::process(PDFDoc *doc)
124124 break ;
125125 }
126126
127- cerr << " Working: " << (i-param.first_page ) << " /" << page_count << ' \r ' << flush;
127+ if (!param.quiet ) {
128+ cerr << " Working: " << (i-param.first_page ) << " /" << page_count << ' \r ' << flush;
129+ }
128130
129131 if (param.split_pages )
130132 {
@@ -153,9 +155,10 @@ void HTMLRenderer::process(PDFDoc *doc)
153155 f_curpage = nullptr ;
154156 }
155157 }
156- if ( page_count >= 0 )
158+ if (!param. quiet && page_count >= 0 )
157159 cerr << " Working: " << page_count << " /" << page_count;
158- cerr << endl;
160+ if (!param.quiet )
161+ cerr << endl;
159162
160163 // //////////////////////
161164 // Process Outline
@@ -167,7 +170,8 @@ void HTMLRenderer::process(PDFDoc *doc)
167170 bg_renderer = nullptr ;
168171 fallback_bg_renderer = nullptr ;
169172
170- cerr << endl;
173+ if (!param.quiet )
174+ cerr << endl;
171175}
172176
173177void HTMLRenderer::setDefaultCTM (double *ctm)
@@ -394,14 +398,21 @@ void HTMLRenderer::post_process(void)
394398 f_css.fs .close ();
395399
396400 // build the main HTML file
397- ofstream output;
398- {
401+ std::ofstream foutput;
402+ std::streambuf *output_buf;
403+ if (param.output_filename == " -" ) {
404+ output_buf = std::cout.rdbuf ();
405+ }
406+ else {
399407 auto fn = str_fmt (" %s/%s" , param.dest_dir .c_str (), param.output_filename .c_str ());
400- output .open ((char *)fn, ofstream::binary);
401- if (!output )
408+ foutput .open ((char *)fn, ofstream::binary);
409+ if (!foutput )
402410 throw string (" Cannot open " ) + (char *)fn + " for writing" ;
403- set_stream_flags (output);
411+ set_stream_flags (foutput);
412+
413+ output_buf = foutput.rdbuf ();
404414 }
415+ std::ostream output (output_buf);
405416
406417 // apply manifest
407418 ifstream manifest_fin ((char *)str_fmt (" %s/%s" , param.data_dir .c_str (), MANIFEST_FILENAME.c_str ()), ifstream::binary);
0 commit comments