Bug 690595 - increase spool file size drastically while printing.
Summary: increase spool file size drastically while printing.
Status: RESOLVED WONTFIX
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Printer Driver (show other bugs)
Version: 8.63
Hardware: PC All
: P4 normal
Assignee: Ken Sharp
URL:
Keywords: bountiable
Depends on:
Blocks:
 
Reported: 2009-07-03 00:47 UTC by Shobhit Jain
Modified: 2021-01-30 15:49 UTC (History)
3 users (show)

See Also:
Customer:
Word Size: ---


Attachments
patch (12.16 KB, patch)
2017-08-07 16:42 UTC, Peter Cherepanov
Details | Diff
Test case (3.70 KB, application/postscript)
2017-08-07 16:44 UTC, Peter Cherepanov
Details
Updated patch for v. 9.52 (8.80 KB, patch)
2020-03-08 01:58 UTC, Peter Cherepanov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Shobhit Jain 2009-07-03 00:47:47 UTC
Dear concern,

I am using gs 8.63 for printing my PDF files using 'mswinpr2' device using 
following line
gswin32c -dPDFFitPage -dNoCancel -dNOPAUSE -dBATCH -dSAFER -dNORANGEPAGESIZE -
sDEVICE=mswinpr2 -sOutputFile="%printer%myprinter" myfile.pdf

But the problem is it when this file is spooled at printer driver then ghost 
makes the size of spool file too big(makes in GBs for the files in few MBs).

Is there some way so that I can keep the spool file size small ?

Regards
Shobhit Jain
Comment 1 Michael B. 2009-07-14 17:01:37 UTC
I think this might be caused by MuPDF because I have this problem using
SumatraPDF. According to it's developers it is because it uses MuPDF which lacks
a GDI backend to tell the printer that "text goes here." Instead, it must tell
the printer that "dots go here."

Could this be the same cause of your problem?
Comment 2 Shobhit Jain 2009-07-14 21:12:14 UTC
then how could I solve my problem??
Comment 3 Ray Johnston 2009-07-15 09:51:56 UTC
This has nothing to do with mupdf or summatrapdf.

Ghostscript generates raster images for the pages, by default at the full color
depth and resolution that the printer supports. GDI (which is what is spooled)
does not provide for compression of images, so the full page raster image gets
spooled. Setting a lower resolution using the -r### option will trade-off the
image quality for the spool file size.

While reducing the bits per pixel to less than 8 (per component) might help
reduce the file size, it is not recommended since this will degrade the image
quality a lot.

An idea that occurs to me is that if some pages are only black and white (or
shades of gray), then the size of the data for the page can be cut to 1/3 by
only sending a black and white image. Currently it always sends full color
even if the page only needs 1 channel.

Adding 'bountiable' to this since we will be glad to pay for someone to
improve the output spool file size of the mswinpr2 device. The above
optimization for B&W pages and/or other ideas a contributor has will be
welcome.

Assigning to Russell since he (I think) is the original author of this
device. Russell, if you don't want it assigned to you, feel free to change
it back to support@artifex.com
Comment 4 Henry Stiles 2009-07-29 22:00:31 UTC
fix severity.
Comment 5 Peter Cherepanov 2017-08-07 16:42:09 UTC
Created attachment 14053 [details]
patch

To reduce spool file size, convert true color RGB bitmaps generated by Ghostscript to indexed bitmaps. This would result in a 24x reduction in spool size for the most common case: black-and-white text.

Also fixed a bug that would cause an infinite loop on wide format printers. The old code assumed that a 64K buffer is sufficient for at least 1 scan line.
Comment 6 Peter Cherepanov 2017-08-07 16:44:47 UTC
Created attachment 14054 [details]
Test case

A test case for output devices, using discrete bands to test different output modes.
Comment 7 Henry Stiles 2017-08-10 19:52:49 UTC
(In reply to Peter Cherepanov from comment #6)
> Created attachment 14054 [details]
> Test case
> 
> A test case for output devices, using discrete bands to test different
> output modes.

How did you test this code?  Do you have a GDI printer?
Comment 8 Peter Cherepanov 2017-08-10 22:59:23 UTC
Yes, I have a cheap ink-jet printer supported by MS Windows. It prints my sample file correctly. I've also checked using MSVC debugger that all normal branches of the code and all types of bitmaps had been exercised.
Comment 9 Henry Stiles 2017-08-11 08:59:00 UTC
We'll likely take this next release Peter, but you can claim the bounty now.  I assume you have filled out a licence agreement, http://bugs.ghostscript.com/attachment.cgi?id=9346

I'll contact you by email separately about the bounty.
Comment 10 Ken Sharp 2017-10-14 03:33:08 UTC
Peter, can you tell me which printer you are using that exhibits a difference please ? I've implemented the code and no matter what printer I try the output file is the same size with the old code and the new.
Comment 11 Peter Cherepanov 2020-03-08 01:58:46 UTC
Created attachment 18956 [details]
Updated patch for v. 9.52

This is an updated patch for the current master version.

The patch reduces color depth of output raster images produced by Ghostscript when it can do it losslessly. The resulting indexed images are presented to GDI for spooling. This reduces the size of the spool file but does't affect the final output (*.prn) for simple raster printers. Usually, GDI will just expand and dither the images before sending them to the printer. Normally, final raster is not stored on disk and its size is not important.

High level printers that directly support indexed images can also see reduction in the *.prn file size. In particular, *.prn size is greatly reduced when ordinary text document is printed on a color PostScript printer.
Comment 12 Ken Sharp 2021-01-13 14:57:54 UTC
(In reply to Peter Cherepanov from comment #11)

> This is an updated patch for the current master version.

No matter what I do I am unable to reproduce any difference in behaviour with any of these patches.

Can you please describe to me, as simply as possible please, words of one syllable, how I can reproduce some difference in behaviour before and after applying any of these patches.

Until I can reproduce a difference I'm not likely to accept a patch.
Comment 13 Ken Sharp 2021-01-30 15:49:42 UTC
In the absence of any information on how to reproduce the supplied patch reducing the spool size I'm closing this bug report.

We've not had any further reports of this as a problem, if it is I'm sure someone will report it again.