[poppler] poppler/glib: poppler-document.cc, 1.24, 1.25 poppler-document.h, 1.14, 1.15 poppler-page.cc, 1.27, 1.28 poppler-private.h, 1.10, 1.11

Martin Kretzschmar m_kretzschmar at freedesktop.org
Thu Jul 28 05:21:10 EST 2005


Update of /cvs/poppler/poppler/glib
In directory gabe:/tmp/cvs-serv6864/glib

Modified Files:
	poppler-document.cc poppler-document.h poppler-page.cc 
	poppler-private.h 
Log Message:
* poppler/PSOutputDev.cc (PSOutputDev): change the constructor to
take paper size and duplex setting parameters.
(init): add paper size and duplex parameters.
(writeDocSetup): add duplex parameter.

* poppler/PSOutputDev.h: update declarations.

* glib/poppler-private.h (struct _PopplerPSFile): store necessary
information to eventually construct a PSOutputDev.

* glib/poppler-page.cc (poppler_page_render_to_ps): initialize the
output dev if it doesn't exist yet.

* glib/poppler-document.cc (poppler_ps_file_new): don't create the
PSOutputDev here, just store filename and page range.
(poppler_ps_file_set_paper_size, poppler_ps_file_set_duplex): new
functions.
(poppler_ps_file_free): free the filename which we strdup now.

* glib/poppler-document.h: add prototypes.


Index: poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-document.cc,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- poppler-document.cc	22 Jul 2005 10:35:56 -0000	1.24
+++ poppler-document.cc	27 Jul 2005 19:21:08 -0000	1.25
@@ -982,17 +982,51 @@
 
 	ps_file = g_new0 (PopplerPSFile, 1);
 	ps_file->document = (PopplerDocument *) g_object_ref (document);
-	ps_file->out = new PSOutputDev ((char *)filename,
-					document->doc->getXRef(),
-					document->doc->getCatalog(),
-					first_page + 1,
-					first_page + 1 + n_pages - 1,
-					psModePS);
-
+        ps_file->filename = g_strdup (filename);
+        ps_file->first_page = first_page + 1;
+        ps_file->last_page = first_page + 1 + n_pages - 1;
+        
 	return ps_file;
 }
 
 /**
+ * poppler_ps_file_set_paper_size:
+ * @ps_file: a PopplerPSFile which was not yet printed to.
+ * @width: the paper width in 1/72 inch
+ * @height: the paper height in 1/72 inch
+ *
+ * Set the output paper size. These values will end up in the
+ * DocumentMedia, the BoundingBox DSC comments and other places in the
+ * generated PostScript.
+ *
+ **/
+void
+poppler_ps_file_set_paper_size (PopplerPSFile *ps_file,
+                                double width, double height)
+{
+        g_return_if_fail (ps_file->out == NULL);
+        
+        ps_file->paper_width = width;
+        ps_file->paper_height = height;
+}
+
+/**
+ * poppler_ps_file_set_duplex:
+ * @ps_file a PopplerPSFile which was not yet printed to
+ * @duplex: whether to force duplex printing (on printers which support this)
+ *
+ * Enable or disable Duplex printing. 
+ *
+ **/
+void
+poppler_ps_file_set_duplex (PopplerPSFile *ps_file, gboolean duplex)
+{
+        g_return_if_fail (ps_file->out == NULL);
+
+        ps_file->duplex = duplex;
+}
+
+/**
  * poppler_ps_file_free:
  * @ps_file: a PopplerPSFile
  * 
@@ -1006,6 +1040,7 @@
 
 	delete ps_file->out;
 	g_object_unref (ps_file->document);
+        g_free (ps_file->filename);
 	g_free (ps_file);
 }
 

Index: poppler-document.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-document.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- poppler-document.h	22 Jul 2005 10:35:56 -0000	1.14
+++ poppler-document.h	27 Jul 2005 19:21:08 -0000	1.15
@@ -134,11 +134,16 @@
 gboolean          poppler_fonts_iter_next          (PopplerFontsIter  *iter);
 
 /* Export to ps */
-PopplerPSFile *poppler_ps_file_new   (PopplerDocument *document,
-				      const char      *filename,
-				      int              first_pages,
-				      int              n_pages);
-void           poppler_ps_file_free  (PopplerPSFile   *ps_file);
+PopplerPSFile *poppler_ps_file_new            (PopplerDocument *document,
+                                               const char      *filename,
+                                               int              first_pages,
+                                               int              n_pages);
+void           poppler_ps_file_set_paper_size (PopplerPSFile   *ps_file,
+                                               double           width,
+                                               double           height);
+void           poppler_ps_file_set_duplex     (PopplerPSFile   *ps_file,
+                                               gboolean         duplex);
+void           poppler_ps_file_free           (PopplerPSFile   *ps_file);
 
 G_END_DECLS
 

Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.cc,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- poppler-page.cc	8 Jul 2005 04:59:41 -0000	1.27
+++ poppler-page.cc	27 Jul 2005 19:21:08 -0000	1.28
@@ -692,6 +692,16 @@
   g_return_if_fail (POPPLER_IS_PAGE (page));
   g_return_if_fail (ps_file != NULL);
 
+  if (!ps_file->out)
+    ps_file->out = new PSOutputDev (ps_file->filename,
+                                    ps_file->document->doc->getXRef(),
+                                    ps_file->document->doc->getCatalog(),
+                                    ps_file->first_page + 1, ps_file->last_page,
+                                    psModePS, (int)ps_file->paper_width,
+                                    (int)ps_file->paper_height, ps_file->duplex,
+                                    0, 0, 0, 0, gFalse);
+
+
   ps_file->document->doc->displayPage (ps_file->out, page->index + 1, 72.0, 72.0,
 				       poppler_page_get_rotate (page), gTrue, gFalse);
 }

Index: poppler-private.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-private.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- poppler-private.h	30 Jun 2005 00:36:01 -0000	1.10
+++ poppler-private.h	27 Jul 2005 19:21:08 -0000	1.11
@@ -31,6 +31,12 @@
 {
   PopplerDocument *document;
   PSOutputDev *out;
+  char *filename;
+  int first_page;
+  int last_page;
+  double paper_width;
+  double paper_height;
+  gboolean duplex;
 };
 
 struct _PopplerFontInfo



More information about the poppler mailing list