changeset 1234:bee6fc8119ec

Paper size reported on Mac height is for all pages... so divide height by the number of pages to get the single page size.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 17 Oct 2011 07:41:14 +0000
parents 365f92e85771
children 9327f684c9b8
files mac/dw.m
diffstat 1 files changed, 19 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Sun Oct 16 20:03:36 2011 +0000
+++ b/mac/dw.m	Mon Oct 17 07:41:14 2011 +0000
@@ -9634,12 +9634,31 @@
     /* Figure out the printer/paper size */
     pi = p->pi;
     size = [pi paperSize];
+
     /* Okay the size reported is really small... and everything
      * in Cocoa is scaled so ... multiply by 2 to get a better
      * resolution but maintain the right aspect ratio.
      */
     size.width *= 2;
     size.height *= 2;
+    
+    /* Get the page range */
+    settings = [pi PMPrintSettings];
+    PMGetFirstPage(settings, &start);
+    if(start > 0)
+        start--;
+    PMGetLastPage(settings, &end);
+    PMSetPageRange(settings, 1, 1);
+    PMSetFirstPage(settings, 1, true);
+    PMSetLastPage(settings, 1, true);
+    [pi updateFromPMPrintSettings];
+    
+    /* Adjust the image size according to
+     * the number of pages to be printed.
+     */
+    if((end - start) > 1)
+        size.height /= (end - start);
+    
     /* Create an image view to print and a pixmap to draw into */
     iv = [[NSImageView alloc] init];
     pixmap = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8);
@@ -9665,17 +9684,6 @@
     po = [NSPrintOperation printOperationWithView:iv printInfo:pi];
     [po setShowsPrintPanel:NO];
     
-    /* Get the page range */
-    settings = [pi PMPrintSettings];
-    PMGetFirstPage(settings, &start);
-    if(start > 0)
-        start--;
-    PMGetLastPage(settings, &end);
-    PMSetPageRange(settings, 1, 1);
-    PMSetFirstPage(settings, 1, true);
-    PMSetLastPage(settings, 1, true);
-    [pi updateFromPMPrintSettings];
-    
     /* Cycle through each page */
     for(x=start; x<end && p->drawfunc; x++)
     {