fordwardport SVN commit 663027 by aacid:

Improve handling of page sizes when printing. 

svn path=/trunk/KDE/kdegraphics/okular/; revision=663034
remotes/origin/KDE/4.0
Albert Astals Cid 19 years ago
parent 1d727e66f6
commit 61b3f856d0
  1. 12
      generators/poppler/generator_pdf.cpp

@ -760,6 +760,7 @@ Okular::TextPage* PDFGenerator::textPage( Okular::Page *page )
bool PDFGenerator::print( KPrinter& printer ) bool PDFGenerator::print( KPrinter& printer )
{ {
int width, height; int width, height;
// PageSize is a CUPS artificially created setting
QString ps = printer.option( "PageSize" ); QString ps = printer.option( "PageSize" );
QRegExp sizere( "w(\\d+)h(\\d+)" ); QRegExp sizere( "w(\\d+)h(\\d+)" );
int marginTop, marginLeft, marginRight, marginBottom; int marginTop, marginLeft, marginRight, marginBottom;
@ -769,17 +770,22 @@ bool PDFGenerator::print( KPrinter& printer )
marginBottom = (int)printer.option("kde-margin-bottom").toDouble(); marginBottom = (int)printer.option("kde-margin-bottom").toDouble();
if ( sizere.exactMatch( ps ) ) if ( sizere.exactMatch( ps ) )
{ {
// size not supported by Qt, KPrinter gives us the size as wWIDTHhHEIGHT // size not supported by Qt, CUPS gives us the size as wWIDTHhHEIGHT, at least on the printers i tested
width = sizere.cap( 1 ).toInt(); width = sizere.cap( 1 ).toInt();
height = sizere.cap( 2 ).toInt(); height = sizere.cap( 2 ).toInt();
} }
else else
{ {
// size is supported by Qt, we get either the pageSize name or nothing because the default pageSize is used // size is supported by Qt, we get either the pageSize name or nothing because the CUPS driver
// does not do any translation, then use KPrinter::pageSize to get the page size
KPrinter::PageSize qtPageSize;
if (!ps.isEmpty()) qtPageSize = pageNameToPageSize(ps);
else qtPageSize = printer.pageSize();
QPrinter dummy(QPrinter::PrinterResolution); QPrinter dummy(QPrinter::PrinterResolution);
dummy.setOrientation((QPrinter::Orientation)printer.orientation()); dummy.setOrientation((QPrinter::Orientation)printer.orientation());
dummy.setFullPage(true); dummy.setFullPage(true);
dummy.setPageSize((QPrinter::PageSize)(ps.isEmpty() ? KGlobal::locale()->pageSize() : pageNameToPageSize(ps))); dummy.setPageSize((QPrinter::PageSize)qtPageSize);
width = dummy.width(); width = dummy.width();
height = dummy.height(); height = dummy.height();

Loading…
Cancel
Save