<> <> <> <<>> 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 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.