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

List:       kde-commits
Subject:    branches/KDE/3.5/kdegraphics/kpdf
From:       Albert Astals Cid <tsdgeos () terra ! es>
Date:       2007-04-09 16:25:24
Message-ID: 1176135924.485339.7731.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 651906 by aacid:

Add an option to force the printing of the page rasterized as image instead of \
converting PDF commands to PS commands. This "decreases" printing quality as the \
thing you print is no longer vectorial, but it is useful for printing files that \
would fail otherwise because our PDF->PS converter is not as perfect as it should be.


 M  +2 -1      core/generator_pdf/generator_pdf.cpp  
 M  +34 -0     part.cpp  
 M  +13 -32    xpdf/xpdf/PSOutputDev.cc  
 M  +2 -8      xpdf/xpdf/PSOutputDev.h  


--- branches/KDE/3.5/kdegraphics/kpdf/core/generator_pdf/generator_pdf.cpp \
#651905:651906 @@ -417,6 +417,7 @@
     marginLeft = (int)printer.option("kde-margin-left").toDouble();
     marginRight = (int)printer.option("kde-margin-right").toDouble();
     marginBottom = (int)printer.option("kde-margin-bottom").toDouble();
+    bool forceRasterize = printer.option("kde-kpdf-forceRaster").toInt();
 
     if (ps.find(QRegExp("w\\d+h\\d+")) == 0)
     {
@@ -458,7 +459,7 @@
     {
       pstitlechar = 0;
     }
-    PSOutputDev *psOut = new PSOutputDev(const_cast<char*>(tf.name().latin1()), \
const_cast<char*>(pstitlechar), pdfdoc->getXRef(), pdfdoc->getCatalog(), 1, \
pdfdoc->getNumPages(), psModePS, marginRight, marginBottom, paperWidth - marginLeft, \
paperHeight - marginTop); +    PSOutputDev *psOut = new \
PSOutputDev(const_cast<char*>(tf.name().latin1()), const_cast<char*>(pstitlechar), \
pdfdoc->getXRef(), pdfdoc->getCatalog(), 1, pdfdoc->getNumPages(), psModePS, \
marginRight, marginBottom, paperWidth - marginLeft, paperHeight - marginTop, \
forceRasterize);  
     if (psOut->isOk())
     {
--- branches/KDE/3.5/kdegraphics/kpdf/part.cpp #651905:651906
@@ -22,13 +22,16 @@
  ***************************************************************************/
 
 // qt/kde includes
+#include <qcheckbox.h>
 #include <qsplitter.h>
 #include <qpainter.h>
 #include <qlayout.h>
 #include <qlabel.h>
 #include <qvbox.h>
 #include <qtoolbox.h>
+#include <qtooltip.h>
 #include <qpushbutton.h>
+#include <qwhatsthis.h>
 #include <dcopobject.h>
 #include <dcopclient.h>
 #include <kapplication.h>
@@ -36,6 +39,7 @@
 #include <kdirwatch.h>
 #include <kinstance.h>
 #include <kprinter.h>
+#include <kdeprint/kprintdialogpage.h>
 #include <kstdaction.h>
 #include <kdeversion.h>
 #include <kparts/genericfactory.h>
@@ -70,6 +74,35 @@
 #include "core/document.h"
 #include "core/page.h"
 
+class PDFOptionsPage : public KPrintDialogPage
+{
+   public:
+       PDFOptionsPage()
+       {
+           setTitle( i18n( "PDF Options" ) );
+           QVBoxLayout *layout = new QVBoxLayout(this);
+           m_forceRaster = new QCheckBox(i18n("Force rasterization"), this);
+           QToolTip::add(m_forceRaster, i18n("Rasterize into an image before \
printing")); +           QWhatsThis::add(m_forceRaster, i18n("Forces the \
rasterization of each page into an image before printing it. This usually gives \
somewhat worse results, but is useful when printing documents that appear to print \
incorrectly.")); +           layout->addWidget(m_forceRaster);
+           layout->addStretch(1);
+       }
+
+       void getOptions( QMap<QString,QString>& opts, bool incldef = false )
+       {
+           Q_UNUSED(incldef);
+           opts[ "kde-kpdf-forceRaster" ] = QString::number( \
m_forceRaster->isChecked() ); +       }
+
+       void setOptions( const QMap<QString,QString>& opts )
+       {
+           m_forceRaster->setChecked( opts[ "kde-kpdf-forceRaster" ].toInt() );
+       }
+
+    private:
+        QCheckBox *m_forceRaster;
+};
+
 // definition of searchID for this class
 #define PART_SEARCH_ID 1
 
@@ -977,6 +1010,7 @@
     }
     if (landscape > portrait) printer.setOrientation(KPrinter::Landscape);
 
+    KPrinter::addDialogPage(new PDFOptionsPage());
     if (printer.setup(widget())) doPrint( printer );
 }
 
--- branches/KDE/3.5/kdegraphics/kpdf/xpdf/xpdf/PSOutputDev.cc #651905:651906
@@ -946,6 +946,7 @@
 PSOutputDev::PSOutputDev(char *fileName, char *pstitle, XRef *xrefA, Catalog \
*catalog,  int firstPage, int lastPage, PSOutMode modeA,
 			 int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
+			 GBool forceRasterizeA,
 			 GBool manualCtrlA) {
   FILE *f;
   PSFileType fileTypeA;
@@ -967,6 +968,8 @@
   customColors = NULL;
   haveTextClip = gFalse;
   t3String = NULL;
+  
+  forceRasterize = forceRasterizeA;
 
   // open file or pipe
   if (!strcmp(fileName, "-")) {
@@ -1002,34 +1005,6 @@
        imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA);
 }
 
-PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA,
-			 char *pstitle, XRef *xrefA, Catalog *catalog,
-			 int firstPage, int lastPage, PSOutMode modeA,
-			 int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
-			 GBool manualCtrlA) {
-  underlayCbk = NULL;
-  underlayCbkData = NULL;
-  overlayCbk = NULL;
-  overlayCbkData = NULL;
-
-  fontIDs = NULL;
-  fontFileIDs = NULL;
-  fontFileNames = NULL;
-  font8Info = NULL;
-  font16Enc = NULL;
-  imgIDs = NULL;
-  formIDs = NULL;
-  xobjStack = NULL;
-  embFontList = NULL;
-  customColors = NULL;
-  haveTextClip = gFalse;
-  t3String = NULL;
-
-  init(outputFuncA, outputStreamA, psGeneric,
-       pstitle, xrefA, catalog, firstPage, lastPage, modeA,
-       imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA);
-}
-
 void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
 		       PSFileType fileTypeA, char *pstitle, XRef *xrefA, Catalog *catalog,
 		       int firstPage, int lastPage, PSOutMode modeA,
@@ -1541,6 +1516,8 @@
   GfxFont *font;
   int i;
 
+  if (forceRasterize) return;
+
   gfxFontDict = NULL;
   resDict->lookupNF("Font", &obj1);
   if (obj1.isRef()) {
@@ -2844,12 +2821,16 @@
   double m0, m1, m2, m3, m4, m5;
   int c, w, h, x, y, comp, i;
 
-  scan = new PreScanOutputDev();
-  page->displaySlice(scan, 72, 72, rotateA, useMediaBox, crop,
+  if (!forceRasterize) {
+    scan = new PreScanOutputDev();
+    page->displaySlice(scan, 72, 72, rotateA, useMediaBox, crop,
 		     sliceX, sliceY, sliceW, sliceH,
 		     printing, catalog, abortCheckCbk, abortCheckCbkData);
-  rasterize = scan->usesTransparency();
-  delete scan;
+    rasterize = scan->usesTransparency();
+    delete scan;
+  } else {
+    rasterize = true;
+  }
   if (!rasterize) {
     return gTrue;
   }
--- branches/KDE/3.5/kdegraphics/kpdf/xpdf/xpdf/PSOutputDev.h #651905:651906
@@ -58,16 +58,9 @@
 	      int firstPage, int lastPage, PSOutMode modeA,
 	      int imgLLXA = 0, int imgLLYA = 0,
 	      int imgURXA = 0, int imgURYA = 0,
+	      GBool forceRasterize = gFalse,
 	      GBool manualCtrlA = gFalse);
 
-  // Open a PSOutputDev that will write to a generic stream.
-  PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA,
-	      char *pstitle, XRef *xrefA, Catalog *catalog,
-	      int firstPage, int lastPage, PSOutMode modeA,
-	      int imgLLXA = 0, int imgLLYA = 0,
-	      int imgURXA = 0, int imgURYA = 0,
-	      GBool manualCtrlA = gFalse);
-
   // Destructor -- writes the trailer and closes the file.
   virtual ~PSOutputDev();
 
@@ -382,6 +375,7 @@
          t3LLX, t3LLY, t3URX, t3URY;
   GBool t3Cacheable;		// cleared if char is not cacheable
   GBool t3NeedsRestore;		// set if a 'q' operator was issued
+  GBool forceRasterize;		// forces the page to be rasterized
 
 #if OPI_SUPPORT
   int opi13Nest;		// nesting level of OPI 1.3 objects


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

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