Assuming y is not too small and extra padding '0' doesn't matter, does this
work?
dat=. 0j16 ": y
N. Drinkwater wrote:
There is a minor problem printing pdf files generated by plot in J 6.01
from Acrobat 7 or 8. The files may contain numbers in exponential
notation, e.g., 1.2345e-6, which is not allowed by the pdf file spec.
When trying to print a pdf containing such a number from Acrobat, a
blank page results (and the plot is wiped out in the print preview in
the acrobat print dialog). Foxit PDFReader ignores the problem and
prints fine.
A simple, if inelegant, workaround is to change the pfmt function in
jzplot to:
pfmt_jzplot_=: 3 : 0
dat=. ": (-.0=y)*0.0001 >. y
txt=. ,dat
($dat) $ '-' (I. txt='_') } txt
)
Non-zero numbers less than 0.0001 are changed to 0.0001 in the pdf
output. The only uses of pfmt (with one exception, below) are in
functions related to pdf or eps output. Since these values are all
rescaled, the very small numbers yield elements that don't show up on
the plot. The only other use of pfmt is in getlabels. Those uses are
changed to a new function lfmt (identical to the current pfmt code) so
that labels print correctly.
lfmt_jzplot_=: 3 : 0
dat=. ": y
txt=. ,dat
($dat) $ '-' (I. txt='_') } txt
)
getlabels_jzplot_=: 3 : 0
fm=. FRAME +. ORIGINXLABEL
if. (0=#XLabel) *. 0 { LABELS do.
b=. (XInt=XTicPos) *. (XInt=0) >: YDiv e. 0 1
ndx=. bx (DimType=2) *. fm<b
XLabel=: (<'') ndx } lfmt each pow10 ^: XLOG XTicPos
end.
if. (0=#YLabel) *. 1 { LABELS do.
b=. (YInt=YTicPos) *. (YInt=0) >: XDiv e. 0 1
ndx=. bx (DimType=2) *. fm<b
YLabel=: (<'') ndx } lfmt each pow10 ^: YLOG YTicPos
end.
if. DimType=2 do.
if. {:YAxes do.
if. (0=#Y2Label) *. 2 { LABELS do.
b=. (Y2Int=Y2TicPos) *. (Y2Int=0) >: XDiv e. 0 1
ndx=. bx (DimType=2) *. fm<b
Y2Label=: (<'') ndx } lfmt each pow10 ^: Y2LOG Y2TicPos
end.
end.
return.
end.
if. (0=#ZLabel) *. 2 { LABELS do.
b=. (ZInt=ZTicPos) *. (ZInt=0) >: XDiv e. 0 1
ndx=. bx (DimType=2) *. FRAME<b
ZLabel=: (<'') ndx } lfmt each pow10 ^: ZLOG ZTicPos
end.
)
With the above function changes, Acrobat prints all plot generated pdfs.
I don't think the modifications have any undesirable side-effects, but
I'd appreciate advice on a cleaner solution.
Norman Drinkwater
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm