[poppler] poppler/poppler: PSOutputDev.cc, 1.15, 1.16 PSOutputDev.h, 1.8, 1.9

Albert Astals Cid aacid at kemper.freedesktop.org
Fri Apr 27 14:25:32 PDT 2007


Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv368/poppler

Modified Files:
	PSOutputDev.cc PSOutputDev.h 
Log Message:
        * glib/poppler-page.cc:
        * poppler/PSOutputDev.cc:
        * poppler/PSOutputDev.h:
        * qt/poppler-document.cc:
        * qt4/src/poppler-document.cc:
        * qt4/src/poppler-qt4.h:
        * utils/pdftohtml.cc:
        * utils/pdftops.cc:
        Add option to force rasterizing the pages when printing them
        Add functionality to output the title field on the PS file
        Only Qt4 frontend exposes the functionality

Bringing this features from KPDF 3.5.7 to poppler
Testers welcome
Patches for other frontends more than welcome
Comments and suggestions even more than welcome :-)


Index: PSOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/PSOutputDev.cc,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- PSOutputDev.cc	25 Apr 2007 19:59:10 -0000	1.15
+++ PSOutputDev.cc	27 Apr 2007 21:25:30 -0000	1.16
@@ -943,9 +943,11 @@
 }
 
 PSOutputDev::PSOutputDev(const char *fileName, XRef *xrefA, Catalog *catalog,
+			 char *psTitle,
 			 int firstPage, int lastPage, PSOutMode modeA,
-                         int paperWidthA, int paperHeightA, GBool duplexA,
+			 int paperWidthA, int paperHeightA, GBool duplexA,
 			 int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
+			 GBool forceRasterizeA,
 			 GBool manualCtrlA) {
   FILE *f;
   PSFileType fileTypeA;
@@ -968,6 +970,8 @@
   haveTextClip = gFalse;
   t3String = NULL;
 
+  forceRasterize = forceRasterizeA;
+
   // open file or pipe
   if (!strcmp(fileName, "-")) {
     fileTypeA = psStdout;
@@ -997,17 +1001,19 @@
     }
   }
 
-  init(outputToFile, f, fileTypeA,
+  init(outputToFile, f, fileTypeA, psTitle,
        xrefA, catalog, firstPage, lastPage, modeA,
        imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA,
        paperWidthA, paperHeightA, duplexA);
 }
 
 PSOutputDev::PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA,
+			 char *psTitle,
 			 XRef *xrefA, Catalog *catalog,
 			 int firstPage, int lastPage, PSOutMode modeA,
-                         int paperWidthA, int paperHeightA, GBool duplexA,
+			 int paperWidthA, int paperHeightA, GBool duplexA,
 			 int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
+			 GBool forceRasterizeA,
 			 GBool manualCtrlA) {
   underlayCbk = NULL;
   underlayCbkData = NULL;
@@ -1027,18 +1033,20 @@
   haveTextClip = gFalse;
   t3String = NULL;
 
-  init(outputFuncA, outputStreamA, psGeneric,
+  forceRasterize = forceRasterizeA;
+
+  init(outputFuncA, outputStreamA, psGeneric, psTitle,
        xrefA, catalog, firstPage, lastPage, modeA,
        imgLLXA, imgLLYA, imgURXA, imgURYA, manualCtrlA,
        paperWidthA, paperHeightA, duplexA);
 }
 
 void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
-		       PSFileType fileTypeA, XRef *xrefA, Catalog *catalog,
+		       PSFileType fileTypeA, char *pstitle, XRef *xrefA, Catalog *catalog,
 		       int firstPage, int lastPage, PSOutMode modeA,
 		       int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
 		       GBool manualCtrlA, int paperWidthA, int paperHeightA,
-                       GBool duplexA) {
+		       GBool duplexA) {
   Page *page;
   PDFRectangle *box;
 
@@ -1132,10 +1140,11 @@
       writeHeader(firstPage, lastPage,
 		  catalog->getPage(firstPage)->getMediaBox(),
 		  catalog->getPage(firstPage)->getCropBox(),
-		  catalog->getPage(firstPage)->getRotate());
+		  catalog->getPage(firstPage)->getRotate(),
+		  pstitle);
     } else {
       box = new PDFRectangle(0, 0, 1, 1);
-      writeHeader(firstPage, lastPage, box, box, 0);
+      writeHeader(firstPage, lastPage, box, box, 0, pstitle);
       delete box;
     }
     if (mode != psModeForm) {
@@ -1231,7 +1240,7 @@
 
 void PSOutputDev::writeHeader(int firstPage, int lastPage,
 			      PDFRectangle *mediaBox, PDFRectangle *cropBox,
-			      int pageRotate) {
+			      int pageRotate, char *psTitle) {
   double x1, y1, x2, y2;
   Object info, obj1;
 
@@ -1253,6 +1262,9 @@
   }
   obj1.free();
   info.free();
+  if(psTitle) {
+    writePSFmt("%%Title: {0:s}\n", psTitle);
+  }
   writePSFmt("%%LanguageLevel: {0:d}\n",
 	     (level == psLevel1 || level == psLevel1Sep) ? 1 :
 	     (level == psLevel2 || level == psLevel2Sep) ? 2 : 3);
@@ -1545,6 +1557,8 @@
   GfxFont *font;
   int i;
 
+  if (forceRasterize) return;
+
   gfxFontDict = NULL;
   resDict->lookupNF("Font", &obj1);
   if (obj1.isRef()) {
@@ -2849,12 +2863,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,
-		     sliceX, sliceY, sliceW, sliceH,
-		     printing, catalog, abortCheckCbk, abortCheckCbkData);
-  rasterize = scan->usesTransparency();
-  delete scan;
+  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;
+  } else {
+    rasterize = gTrue;
+  }
   if (!rasterize) {
     return gTrue;
   }

Index: PSOutputDev.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/PSOutputDev.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- PSOutputDev.h	25 Apr 2007 19:59:10 -0000	1.8
+++ PSOutputDev.h	27 Apr 2007 21:25:30 -0000	1.9
@@ -53,21 +53,25 @@
 
   // Open a PostScript output file, and write the prolog.
   PSOutputDev(const char *fileName, XRef *xrefA, Catalog *catalog,
+	      char *psTitle,
 	      int firstPage, int lastPage, PSOutMode modeA,
-              int paperWidthA = -1, int paperHeightA = -1,
-              GBool duplexA = gTrue,
+	      int paperWidthA = -1, int paperHeightA = -1,
+	      GBool duplexA = gTrue,
 	      int imgLLXA = 0, int imgLLYA = 0,
 	      int imgURXA = 0, int imgURYA = 0,
+	      GBool forceRasterizeA = 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 paperWidthA = -1, int paperHeightA = -1,
-              GBool duplexA = gTrue,
+	      int paperWidthA = -1, int paperHeightA = -1,
+	      GBool duplexA = gTrue,
 	      int imgLLXA = 0, int imgLLYA = 0,
 	      int imgURXA = 0, int imgURYA = 0,
+	      GBool forceRasterizeA = gFalse,
 	      GBool manualCtrlA = gFalse);
 
   // Destructor -- writes the trailer and closes the file.
@@ -109,7 +113,7 @@
   // Write the document-level header.
   void writeHeader(int firstPage, int lastPage,
 		   PDFRectangle *mediaBox, PDFRectangle *cropBox,
-		   int pageRotate);
+		   int pageRotate, char *pstitle);
 
   // Write the Xpdf procset.
   void writeXpdfProcset();
@@ -246,7 +250,7 @@
 private:
 
   void init(PSOutputFunc outputFuncA, void *outputStreamA,
-	    PSFileType fileTypeA, XRef *xrefA, Catalog *catalog,
+	    PSFileType fileTypeA, char *pstitle, XRef *xrefA, Catalog *catalog,
 	    int firstPage, int lastPage, PSOutMode modeA,
 	    int imgLLXA, int imgLLYA, int imgURXA, int imgURYA,
 	    GBool manualCtrlA, int paperWidthA, int paperHeightA,
@@ -385,6 +389,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 into a image before printing
 
 #if OPI_SUPPORT
   int opi13Nest;		// nesting level of OPI 1.3 objects



More information about the poppler mailing list