[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [PATCH] KPDF - Print with the correct page size
From:       Albert Astals Cid <astals11 () terra ! es>
Date:       2005-02-27 23:09:48
Message-ID: 200502280009.49076.astals11 () terra ! es
[Download RAW message or body]

Hi, i think that may be a candidate to commit to KDE_3_4_BRANCH.

The problem lies in that kpdf was not setting the pagesize of what it was 
printing according to what KPrinter said, instead it was printing the page 
size specified in /etc/xpdfrc or Letter as default, this is obviously wrong 
and that patch fixes it (at least the user that reported the problem says it 
seems to work, i don't have different paper sizes to try)

Related bug: http://bugs.kde.org/show_bug.cgi?id=100003

May i commit it to KDE_3_4_BRANCH?

Albert

["printing.2.patch" (text/x-diff)]

Index: core/generator_pdf/generator_pdf.cpp
===================================================================
RCS file: /home/kde/kdegraphics/kpdf/core/generator_pdf/generator_pdf.cpp,v
retrieving revision 1.22
diff -u -r1.22 generator_pdf.cpp
--- core/generator_pdf/generator_pdf.cpp	19 Feb 2005 13:04:41 -0000	1.22
+++ core/generator_pdf/generator_pdf.cpp	27 Feb 2005 22:44:42 -0000
@@ -13,6 +13,8 @@
 #include <qevent.h>
 #include <qimage.h>
 #include <qapplication.h>
+#include <qpaintdevicemetrics.h>
+#include <qregexp.h>
 #include <klocale.h>
 #include <kpassdlg.h>
 #include <kprinter.h>
@@ -296,6 +298,29 @@
 
 bool PDFGenerator::print( KPrinter& printer )
 {
+    QString ps = printer.option("PageSize");
+    QRegExp re = QRegExp("w\\d+h\\d+");
+    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");
+        globalParams->setPSPaperWidth(ps.left(hPos).toInt());
+        globalParams->setPSPaperHeight(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);
+        globalParams->setPSPaperWidth(metrics.width());
+        globalParams->setPSPaperHeight(metrics.height());
+    }
+
     KTempFile tf( QString::null, ".ps" );
     PSOutputDev *psOut = new PSOutputDev(tf.name().latin1(), pdfdoc->getXRef(), \
pdfdoc->getCatalog(), 1, pdfdoc->getNumPages(), psModePS);  



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic