[Kde-print-devel] PageSize versus kde-pagesize

Albert Astals Cid aacid at kde.org
Mon May 7 20:56:46 CEST 2007


Hi, in kpdf we need to know the paper size because we create our own PS and 
need to know the size so we can write it to the file.

Currently i'm using this code

QString ps = printer.option("PageSize");

if (ps.find(QRegExp("w\\d+h\\d+")) == 0)
{
    // size not supported by Qt, KPrinter gives us the size as wWIDTHhHEIGHT
    // remove the w
    ps = ps.mid(1);
    int hPos = ps.find("h");
    paperWidth = ps.left(hPos).toInt();
    paperHeight = ps.mid(hPos+1).toInt();
}
else
{
    // size is supported by Qt, we get either the pageSize name or nothing 
because the default pageSize is used
    QPrinter dummy(QPrinter::PrinterResolution);
    dummy.setFullPage(true);
    dummy.setPageSize((QPrinter::PageSize)(ps.isEmpty() ? 
KGlobal::locale()->pageSize() : pageNameToPageSize(ps)));

    QPaintDeviceMetrics metrics(&dummy);
    paperWidth = metrics.width();
    paperHeight = metrics.height();
}

This has been always working for me when printing to a printer, but when, for 
example printing to a PS file i never get the "PageSize" but 
a "kde-pagesize".

Now a user is also getting "kde-pagesize" when printing to a printer resulting 
in wrong printouts.

So can someone give some light on how PageSize and kde-pagesize work and if i 
should be using any other way to get the paper size?

Thanks,
  Albert


More information about the Kde-print-devel mailing list