InterpressSizeCommandImpl.mesa
Copyright Ó 1984, 1985, 1986, 1987 by Xerox Corporation. All rights reserved.
Bloomenthal, May 9, 1988 3:16:19 pm PDT
DIRECTORY
Commander, CommandTool, Convert, FS, Imager, ImagerBox, ImagerMaskCapture, ImagerTransformation, Interpress, IO, Rope, SF;
InterpressSizeCommandImpl: CEDAR PROGRAM
IMPORTS Commander, CommandTool, Convert, FS, Imager, ImagerBox, ImagerMaskCapture, ImagerTransformation, Interpress, IO
~ BEGIN
InterpressSizeCommand: Commander.CommandProc ~ {
ENABLE {
FS.Error => {
msg ← error.explanation;
GOTO Failure;
};
Convert.Error => {
msg ← "Conversion error";
GOTO Failure;
};
};
args: CommandTool.ArgumentVector ~ CommandTool.Parse[cmd];
IF args.argc # 2
THEN RETURN[$Failure, interpressSizeUsage]
ELSE {
m: Imager.Transformation ← ImagerTransformation.Scale[150.0/0.0254]; -- ~150 pixels/inch
n: Imager.Transformation ← ImagerTransformation.PostScale[m, 0.0254]; -- back to inches
master: Interpress.Master ← Interpress.Open[args[1], NIL];
FOR page: INT IN [1..master.pages] DO
Operator: PROC [context: Imager.Context] ~ {
Imager.SetColor[context, Imager.black];
Imager.SetStrokeEnd[context, square];
Imager.SetStrokeWidth[context, 0.0];
Imager.SetAmplifySpace[context, 1.0];
Interpress.DoPage[master, page, context, NIL];
};
b: SF.Box ← ImagerMaskCapture.CaptureBounds[Operator, m
! ImagerMaskCapture.Cant => RESUME];
r: ImagerBox.Rectangle ← ImagerTransformation.InverseTransformRectangle[
n, ImagerBox.RectangleFromBox[[b.min.s, b.min.f, b.max.s, b.max.f]]];
IF master.pages > 1 THEN IO.PutF[cmd.out, "P %g, ", IO.int[page]];
IO.PutF[cmd.out, "origin: [%5.3f, %5.3f], width: %5.3f, height: %5.3f (inches)\n", IO.real[r.x], IO.real[r.y], IO.real[r.w], IO.real[r.h]];
ENDLOOP;
};
EXITS Failure => result ← $Failure;
};
interpressSizeUsage: Rope.ROPE ~ "
InterpressSize | IPSize <interpress file>
Predict the (device independent) printed size of an interpress file.
Although not performing unnecessary operations, the entire
Interpress file is examined, which might take a long time.";
Commander.Register["InterpressSize", InterpressSizeCommand, interpressSizeUsage];
Commander.Register["IPSize", InterpressSizeCommand, interpressSizeUsage];
END.