rrthomas / psutils

Utilities for manipulating PostScript documents
GNU General Public License v3.0
39 stars 11 forks source link

Unneeded warning message about paper size when used with a2ps (fixps) and troff files #65

Closed dsan4208 closed 9 months ago

dsan4208 commented 9 months ago

groff produces postscript files that work fine with psnup. The PS groff produces includes a DocumentMedia statement at the begining. However a2ps runs the PS through fixps. The most recent version of fixps always rewrites the file with ghostscript which strips the DocumentMedia statment from the file. So when psnup reads the file you get the warning message "psnup: required input paper size was guessed as 612x792 pt". When you have a bunch of troff files that a2ps is processing you get the warning for each file. This is unneeded. As a temporary workaround, the call the fixps can be removed. The previous version of fixps didn't modify groff outputed postscript so this just re-establishes the status quo.

The postscript from fixps does however include PageBoundingBox, BoundingBox, and HiResBoundingBox statements. This should be suffice to inform psnup as to the input page size and the warning about "guessing" the input page size is undesired behavior. Please consider removing the warning when there is a PageBoundingBox statement in the PS file.

Thanks, David

rrthomas commented 9 months ago

I'm entirely responsible for this unfortunate state of affairs (sorry!), but I don't think it's an issue with psutils, or indeed of a2ps or fixps.

I maintain a2ps since 4.15. I made fixps always run the input through Ghostscript, as there's no reliable way to tell when it's needed.

PSUtils is doing the right thing: bounding boxes are often paper sizes, but not reliably so.

I can't see a fix here that won't make one of these bits of software less robust or more complex; I'm open to suggestions!

Here, where you're batch processing, I'd simply filter out expected warnings, or customize your a2ps.cfg not to use fixps.

dsan4208 commented 9 months ago

Fixps could capture the DocumentMedia (and perhaps other “%%” lines) from the original file and insert it into the beginning of the output of Ghostscript.

As you say, that's probably true for the a2ps use, but not the general case. The most obvious thing to follow up on would be: why does GhostScript remove the DocumentMedia setting?

From an a2ps point of view, it seems to me that the most obvious fix would be to add a user option that omits the a2ps step in delegations (or probably more easily, runs it with --no-fix. I'd happily accept a patch to a2ps to add that feature to the default a2ps.cfg.

dsan4208 commented 9 months ago

Thanks.

Perhaps you're right that asking why GhostScript removes DocumentMedia is the next step. In the mean time I have removed the call to fixps in my a2ps.cfg. I'm not sure which program accepts a "--no-fix" option so can't put that in anywhere.

From a psutils standpoint, the only other thing I would point out is that psnup doesn't respect the "-q" option and issues the warning anyway. That is unexpected. Perhaps you could allow specifying it twice "-q -q" to also silence warnings. When used by a2ps the warnings aren't desired in my humble opinion (at least not when used with groff).

Thanks, David

rrthomas commented 9 months ago

Perhaps you're right that asking why GhostScript removes DocumentMedia is the next step. In the mean time I have removed the call to fixps in my a2ps.cfg. I'm not sure which program accepts a "--no-fix" option so can't put that in anywhere.

Sorry, it was an older version of psfix that accepted --no-fix. But one could still implement a user option in a2ps.cfg that optionally doesn't run psfix.

From a psutils standpoint, the only other thing I would point out is that psnup doesn't respect the "-q" option and issues the warning anyway. That is unexpected. Perhaps you could allow specifying it twice "-q -q" to also silence warnings. When used by a2ps the warnings aren't desired in my humble opinion (at least not when used with groff).

The -q option for psnup just means "don't show progress", unfortunately (it's backwards-compatible, not what I'd choose). This is clearly documented, but I agree it's not what that flag usually does.

Having a stronger "really quiet" option is not a bad idea, but I think it's overkill in this case, where 2> /dev/null is also an option.

If that's it for this particular issue, please close it.

rrthomas commented 8 months ago

For future reference: the actual locus of the problem is unclear (why does GhostScript strip that header? there's probably a good reason, but I don't know what it is).

My own prejudice is that this is the sort of problem one will run into with PostScript: one is trying to automatically rewrite programs in a Turing-complete language, after all!

There are various workarounds, and if anywhere is the right place to add a flag for something that's a little hacky, it's in the (default) a2ps config.