--- a/qt4/src/poppler-ps-converter.cc +++ b/qt4/src/poppler-ps-converter.cc @@ -214,12 +214,31 @@ char* pstitlechar; if (!d->title.isEmpty()) pstitlechar = pstitle8Bit.data(); else pstitlechar = 0; + + /* Calculate min and max page for creating the ps-file. + * This was introduced because before all pages where + * put in the ps file, which was very inefficent + * when printing a single page in a huge pdf file. + * TODO: + * Do you need to calculate min/max? Or can you rely + * on the first and last element of pageList? + */ + int minPage=0; + int maxPage=0; + if(d->pageList.size()>0) { + minPage = maxPage = d->pageList[0]; + } + for(int i=1; ipageList.size(); i++) { + int currentPage = d->pageList[i]; + if(currentPage < minPage) minPage = currentPage; + if(currentPage > maxPage) maxPage = currentPage; + } PSOutputDev *psOut = new PSOutputDev(outputToQIODevice, dev, pstitlechar, d->document->doc, - 1, - d->document->doc->getNumPages(), + minPage, + maxPage, (d->opts & PrintToEPS) ? psModeEPS : psModePS, d->paperWidth, d->paperHeight,