Closed Bug 263177 Opened 20 years ago Closed 17 years ago

[ps] mozilla generates level 2 postscript that will not print on a level 1 printer

Categories

(Core :: Printing: Output, defect)

x86
Linux
defect
Not set
major

Tracking

()

RESOLVED FIXED

People

(Reporter: CarlPonder, Unassigned)

References

Details

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; rv:1.7.3) Gecko/20040914 Firefox/0.10
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.3) Gecko/20040914 Firefox/0.10

When I print from Mozilla FireFox, it generates PostScript that appears to be
PostScript Level 2 compliant but not Level 1. I can't print documents on my IBM
4029 LaserPrinter 10.

I wrote a filter that removes the "undef" statements from the PostScript and am
able to print some pages but not others. I'll keep working this.

Reproducible: Always
Steps to Reproduce:
1. Plug system into 4029 printer.
2. Configure the printer.
3. Print to it using Mozilla FireFox.

Actual Results:  
Printer starts up and then flushes the input. No pages are printed.

Expected Results:  
Pages should have printed.

The irony is that when Mozilla was printing Level 3 PostScript, as described in
defect #182324, I could write a simple filter that rearranged the "unidict"
entry, and I never had a problem printing anything after that.

Now that the output is Level 2 compliant, I haven't found a foolproof filter
that makes it Level 1 compliant. I'll keep working on this -- in bug #182324,
Kenneth Heron pointed out that the "undef" statement was Level 2, not Level 1,
and I'll see if this is the only problem.

Further, the "undef" may actually be a good thing, if printers with limited
memory can process longer documents. If I had a filter that would make my
Level 1 printer work for the smaller cases, this would be enough for my
purposes.
This bug relates to #107756 and #182324, regarding the fact that Mozilla
generated some Level-3-only constructs.

Bug #176938 raises the same issue, but it's not clear that strict Level 1
or 2 is what is required, or it these printers could only process subsets of
the language.

That's actually why I prefer using a filter to changing Mozilla.
Here's the filter I'm using that removes the use of "undef":

    while ( <> ) {
 
        if ( m#^/rowdata where { /rowdata undef } if\n$# ) {
            print "%$_";
            next;
        }
        print;
 
    }

From Kenneth Herron:

>
> Carl, could you open a new bug about your issue? "undef" is a PS level 2
> operator. The intent of that line is to remove a temporary string buffer used
> while printing images, in order to save printer memory. The line could be
> modified to avoid breakage on level 1 printers, and if it's the only thing
> keeping a latin1 page from printing on a level 1 printer then we should probably
> fix it.
>

The "undef" appears to be used in a pretty specific way, that's easy to filter
out. Also I see uses of the "bind" operator, which (if I read the manual
correctly) is also a Level-3 operator; maybe I can just delete the usages.
Another thing to note: the only web-pages I *haven't* been able to print
are e-mail messages in the Netscape Mail website (the website, not the
Netscape-mail tool). There's something in these pages that prevents printing
in most but not all cases. I assumed it was the "bind" operators, but some
pages will still print in spite of containing "bind".
Here's a public web-page I can't print to my PS1 printer:

      http://www.austinchronicle.com/

Also, I'm not conviced that "bind" statements are a problem after all, since I
found a file that doesn't contain any and still won't print.
The Level 2 PostScript operator "glyphshow" is being used in the output of
FireFox. This looks like something that wouldn't be easy to filter out.

There are also the operators

          selectfont    setpagedevice     setstrokeadjust

that are used in single cases:

    /Msf /selectfont where
    { pop { exch selectfont } }
    { { findfont exch scalefont setfont } }
    ifelse
    bind def

    /setpagedevice where
    { pop 1 dict
      dup /PageSize [ 612 792 ] put
      setpagedevice
    } if

   /Msetstrokeadjust /setstrokeadjust where
     { pop /setstrokeadjust } { /pop } ifelse
     load def

I don't know what these do.

Anyway, is there some form that a filter can replace these with? Or is it
possible to define them as macros and have the filter insert the macro
definitions into the appropriate places?
I'm having some success by by-passing the use of "glyphshow". The use is wrapped
within the form

/real_glyph_unicodeshow
{
  /ccode exch def
      /UniDict where {
        pop
        UniDict ccode known {
          UniDict ccode get glyphshow
          true
        } {
          false
        } ifelse
      } {
          false
      } ifelse
} bind def

which is only invoked by the form

/default_ls {
  /Unicode2NativeDict Unicode2NativeDictdef def
  /UCS2Font   /Courier def
  /NativeFont /Courier def
  /unicodeshow1 { real_glyph_unicodeshow } bind def
  /unicodeshow2 { real_unicodeshow_native } bind def
} bind def

About 30 lines below this second form is a similar one

/Unicode2NativeDictja 0 dict def
/ja_ls {
  /NativeFont /Ryumin-Light-EUC-H def
  /UCS2Font /Courier def
  /Unicode2NativeDict Unicode2NativeDictja def
  /unicodeshow1 { real_unicodeshow } bind def
  /unicodeshow2 { real_unicodeshow_native } bind def
} bind def

The kludge I'm applying is to convert the instance

  /unicodeshow1 { real_glyph_unicodeshow } bind def

which occurs in the second form, to 

  /unicodeshow1 { real_unicodeshow } bind def

which occurs in the third form, so "glyphshow" never gets invoked. Since
the two were used in different contexts, there's a possibility that pages
may get garbled. I just noticed that a page from Charles Schwab is showing
a box instead of a ' character, which may be an indication of worse to come.

At least I can print pages that weren't working before.
For future reference: the PostScript 3 Definition document

     http://www-cdf.fnal.gov/offline/PostScript/PLRM3.pdf

has, on page 732 (by the document) and page 746 (by the viewer)
the list of operators that are new to Level 2 PostScript and
not supported by Level 1 PostScript.

I copied this list into a file and wrote an easy script that
fgrep'd for each entry in my firefox output files, and identified
selectfont, setpagedevice, setstrokeadjust, and glyphshow in the
files.
(In reply to comment #8)

> I copied this list into a file and wrote an easy script that
> fgrep'd for each entry in my firefox output files, and identified
> selectfont, setpagedevice, setstrokeadjust, and glyphshow in the
> files.

Font related problem may be fixed by bug 234182.
"setstrokeadjust" only used in plugin printing. It is just a name in normal page.
So "undef" and "setpagedevice" should be fixed next.
Depends on: 283432
Attachment #176717 - Flags: superreview?(roc)
Attachment #176717 - Flags: review?(kherron+mozilla)
Comment on attachment 176717 [details] [diff] [review]
Give postscript level1 printer a changce to print multi-copies

The postscript looks fine. You could convert the three fprintf() calls into a
single call, though.

When you check this in, please leave the bug open. We still need to do
something about calling the "glyphshow" operator.
Attachment #176717 - Flags: review?(kherron+mozilla) → review+
Attachment #176855 - Flags: superreview?(roc)
Attachment #176855 - Flags: superreview?(roc) → superreview+
Checking in nsPostScriptObj.cpp;
/cvsroot/mozilla/gfx/src/ps/nsPostScriptObj.cpp,v  <--  nsPostScriptObj.cpp
new revision: 1.122; previous revision: 1.121
done
Status: UNCONFIRMED → NEW
Ever confirmed: true
Can this bug be marked as fixed ?
(In reply to comment #14)
> Can this bug be marked as fixed ?

(From comment #11)
> When you check this in, please leave the bug open. We still need to do
> something about calling the "glyphshow" operator.
> 

My filter no longer works with FireFox 1.5. I don't see any level 3 PostScript keywords being used, but grepping for level 2 keywords give me

    { currentfile rowdata readhexstring pop } false 3 colorimage
    /Msetstrokeadjust /setstrokeadjust where
    /Msf /selectfont where
    { pop { exch selectfont } }
    { pop /setstrokeadjust } { /pop } ifelse
     setpagedevice
    /setpagedevice where
    true Msetstrokeadjust
    /undef where { pop /rowdata where { /rowdata undef } if } if

I don't know whether I can replace these or not. Abode acrobat is using
PostScript 2 forms that can't be replaced because of the structure of the
print file; this may be the case with FireFox as well.
(In reply to comment #16)
>     { currentfile rowdata readhexstring pop } false 3 colorimage

If you have a Black & white printer which doesn't support the colorimage operator, then you should print in grayscale. Open File->Print and click on "printer properties". In the printer properties dialog, select "grayscale".

>     /Msetstrokeadjust /setstrokeadjust where
>     /Msf /selectfont where
>     { pop { exch selectfont } }
>     { pop /setstrokeadjust } { /pop } ifelse
>      setpagedevice
>     /setpagedevice where
>     true Msetstrokeadjust
>     /undef where { pop /rowdata where { /rowdata undef } if } if

In these cases the level 2 operator only executes if the postscript interpreter supports it. That's what the "where" operator is doing in these lines, testing for the existance of another operator.
At this point, I *have* a Level 2 printer.
I'd prefer that the format *NOT* be downgraded to Level 1 if it would potentially limit the formatting capability of the print function.
I'm marking it as "FIXED" since I don't see a button to withdraw it.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: