2

I have a PostScript file with a shfill in it that views fine in tools such as gv and converts fine to png using ghostscript however the shfill disappears when using ps2pdf on Linux (which uses gs device PDFWriter i believe). Anyone have a hunch why ?

%%BoundingBox: 40 13 555 829                                               
%%HiResBoundingBox: 40.2072703937 13.1732283465 554.7927296063 828.8267716535                                
%%PageOrientation: Portrait          
%%Pages: 1
%%EndComments
%%Page: page 1
grestore
gsave %pre-tile 0
14.1732283465 14.1732283465 translate
%portrait
27.0340420472 0.0000000000 translate
%539.619501 813.653543 scale

0.0040682677 0.0040682677 scale
newpath
grestore
gsave %pre-tile 0
14.1732283465 14.1732283465 translate
%portrait
27.0340420472 0.0000000000 translate
%539.619501 813.653543 scale

0.0040682677 0.0040682677 scale
<< /ShadingType 5
   /ColorSpace /DeviceRGB
   /VerticesPerRow 2
   /DataSource [
119726 154712 1.00 0.56 0.38 123209 154712 1.00 0.56 0.38 
119726 158195 1.00 0.65 0.50 123209 158195 1.00 0.65 0.50 
119726 161679 1.00 0.74 0.62 123209 161679 1.00 0.74 0.62 
119726 165163 1.00 0.82 0.75 123209 165163 1.00 0.82 0.75 
119726 168647 1.00 0.91 0.87 123209 168647 1.00 0.91 0.87 
119726 172131 1.00 1.00 1.00 123209 172131 1.00 1.00 1.00 
119726 175614 0.91 1.00 1.00 123209 175614 0.91 1.00 1.00 
119726 179098 0.82 0.99 1.00 123209 179098 0.82 0.99 1.00 
119726 182582 0.73 0.99 1.00 123209 182582 0.73 0.99 1.00 
119726 186066 0.64 0.99 1.00 123209 186066 0.64 0.99 1.00 
119726 189550 0.55 0.99 1.00 123209 189550 0.55 0.99 1.00 
   ]
>> shfill

The software is running on an up-to-date Ubuntu 20. The gs version ps2pdf uses is

GPL Ghostscript 9.50 (2019-10-15) Copyright (C) 2019 Artifex Software, Inc. All rights reserved.

Update: I've gotten one step closer to the problem by at least having a workaround:

When i remove the scale operator and perform the scaling manually by mul in the shfill then the PDF conversion works fine

%!PS-Adobe-3.0 EPSF-3.0
14.1732283465 14.1732283465 translate
27.0340420472 0.0000000000 translate
%0.0040682677 0.0040682677 scale
<< /ShadingType 5
   /ColorSpace /DeviceRGB
   /VerticesPerRow 2
   /DataSource [
119726 0.0040682677 mul 154712 0.0040682677 mul 1.00 0.56 0.38
123209 0.0040682677 mul 154712 0.0040682677 mul 1.00 0.56 0.38
119726 0.0040682677 mul 158195 0.0040682677 mul 1.00 0.65 0.50
123209 0.0040682677 mul 158195 0.0040682677 mul 1.00 0.65 0.50
119726 0.0040682677 mul 161679 0.0040682677 mul 1.00 0.74 0.62
123209 0.0040682677 mul 161679 0.0040682677 mul 1.00 0.74 0.62
119726 0.0040682677 mul 165163 0.0040682677 mul 1.00 0.82 0.75
123209 0.0040682677 mul 165163 0.0040682677 mul 1.00 0.82 0.75
119726 0.0040682677 mul 168647 0.0040682677 mul 1.00 0.91 0.87
123209 0.0040682677 mul 168647 0.0040682677 mul 1.00 0.91 0.87
119726 0.0040682677 mul 172131 0.0040682677 mul 1.00 1.00 1.00
123209 0.0040682677 mul 172131 0.0040682677 mul 1.00 1.00 1.00
119726 0.0040682677 mul 175614 0.0040682677 mul 0.91 1.00 1.00
123209 0.0040682677 mul 175614 0.0040682677 mul 0.91 1.00 1.00
119726 0.0040682677 mul 179098 0.0040682677 mul 0.82 0.99 1.00
123209 0.0040682677 mul 179098 0.0040682677 mul 0.82 0.99 1.00
119726 0.0040682677 mul 182582 0.0040682677 mul 0.73 0.99 1.00
123209 0.0040682677 mul 182582 0.0040682677 mul 0.73 0.99 1.00
119726 0.0040682677 mul 186066 0.0040682677 mul 0.64 0.99 1.00
123209 0.0040682677 mul 186066 0.0040682677 mul 0.64 0.99 1.00
119726 0.0040682677 mul 189550 0.0040682677 mul 0.55 0.99 1.00
123209 0.0040682677 mul 189550 0.0040682677 mul 0.55 0.99 1.00
   ]
>> shfill 
Waslap
  • 572
  • 3
  • 23
  • If you think you've found a bug, then you should report a bug. You've only posted a small fragment of PostScript and not stated what device you are using, nor what version of Ghostscript. Open a bug report at bugs.ghostcript.com and someone can look at it. – KenS Jul 07 '23 at 07:19
  • The example is a self-contained postscript file that can be used to illustrate my problem. I don't think i've found a bug until i've had some exposure on the problem here and someone perhaps says this is not possible in PDF. I've stated clearly i use ps2pdf – Waslap Jul 07 '23 at 07:47
  • 1
    It is not a problem with `shfill` as such, see for example https://stackoverflow.com/questions/65907826/a-pdf-with-different-outputs-in-different-pdf-viewers-with-shades which works fine with `ps2pdf`. I am not proficient enough in Postscript to see what the problem is but it might have to do with the bounding box/coordinates, which may cause the pdf to fail to know that it needs to draw something or where to draw it, whereas `gv` is more permissive. That's just a wild guess however, maybe there is some bug with the fill (for example ShadingType 5 vs. 2). – Marijn Jul 07 '23 at 08:57
  • 1
    A little bit further testing shows that ShadingType 5 is also not the problem, the example from http://www.setec.org/~izaac/postscriptbooks/partners.adobe.com/asn/developer/pdfs/tn/TN5600.SmoothShading.pdf page 46 works fine with `ps2pdf`. – Marijn Jul 07 '23 at 09:17
  • Well the shading is present in the PDF file, the content stream calls for it and renders it, apparently to cover the entire page, which is slightly surprising, but that's what the EPS file does too. The Decode array values look suspicious, as does the fact that there are 5 entries. Beyond that it'll take some debugging to figure out, type 5 shadings are not the simplest. ps2pdf is not a Ghostscript device (it uses the pdfwrite device), and isn't even unique to Ghostscript, I've wasted time in the past with people using 'ps2pdf' and saying it's Ghostscript, only to discover it isn't. – KenS Jul 07 '23 at 11:03
  • @Marijn Thanks, your helpful comments assisted me to focus not on shfill but the coordinates. I have narrowed it down now to the coordinate system. When i get rid of the translate/scale it shows up in pdf. I will post the eventual answer if i find it – Waslap Jul 07 '23 at 11:34
  • 1
    It still ought to work, and clearly doesn't, so I'll need to look into it anyway. Unfortunately this is a particularly busy time and I'm not sure how long it will take me to get to it. – KenS Jul 07 '23 at 12:10
  • 1
    I have logged a ghostscript bug and updated it with a workaround – Waslap Jul 10 '23 at 10:03

0 Answers0