Discussion:
ghostscript - any way to fit to printable area?
(too old to reply)
jhgrredbjhj
2011-12-15 17:08:40 UTC
Permalink
Is there any way (short of using Adobe Reader) to fit a page into the
"printable area" (inside of printers hard margins) using ghostscript
when printing?
Rod Dorman
2011-12-15 19:04:09 UTC
Permalink
Post by jhgrredbjhj
Is there any way (short of using Adobe Reader) to fit a page into the
"printable area" (inside of printers hard margins) using ghostscript
when printing?
Sure, use the scale command if you need to change the size, and the
translate command if you need to move the origin.
--
-- Rod --
rodd(at)polylogics(dot)com
jhgrredbjhj
2011-12-16 12:56:32 UTC
Permalink
Post by Rod Dorman
Post by jhgrredbjhj
Is there any way (short of using Adobe Reader) to fit a page into the
"printable area" (inside of printers hard margins) using ghostscript
when printing?
Sure, use the scale command if you need to change the size, and the
translate command if you need to move the origin.
We have around 500 blueprints we print each week using ghostscript or
gsprint. Most are us letter but some a4 and a few 11x17. The current
printer has 4mm hard margins on each side. Sometimes the printed
output gets clipped at these hard margins when printing with
ghostscript depending on how close the engineer drew to the edge of
the page. Adobe reader has an option "fit to printable area" that
takes the pdf and scales it up or down to fit within the hard
margins. This is what I am trying to do. How would I know which way
to scale the output and manipulate the origin? Can ghostscript figure
this out somehow?
John Reiser
2011-12-16 16:44:59 UTC
Permalink
Post by jhgrredbjhj
We have around 500 blueprints
Sometimes it is important for a blueprint to be actual size: the user
intends to obtain valid data by measuring marks on the physical print.
The external scale of the physical print must match the internal scale
that was chosen by the author (human or program.)

If so, then the only option for printing is positioning the output
on the page, such as rotation or centering. The printer's 4mm hard
margin may clip some marks, but with a requirement for "actual size"
printing then you have no choice. Choosing "fit to printable area"
and scaling by a factor of 0.97 might just be the *worst possible* output.
Some engineering departments require that drawings have a drawn border
(effectively, a *drawn* bounding box) whose dimensions are known,
so that clipping and scaling can be detected.
Post by jhgrredbjhj
we print each week using ghostscript or
gsprint. Most are us letter but some a4 and a few 11x17. The current
printer has 4mm hard margins on each side. Sometimes the printed
output gets clipped at these hard margins when printing with
ghostscript depending on how close the engineer drew to the edge of
the page. Adobe reader has an option "fit to printable area" that
takes the pdf and scales it up or down to fit within the hard
margins. This is what I am trying to do. How would I know which way
to scale the output and manipulate the origin? Can ghostscript figure
this out somehow?
If the printer has a 4mm hard margin on the two sides that correspond
to the PostScript origin, then move the origin out of the margin using
something such as:
-----
/inch { 72 mul } bind def
/mm { 25.4 div inch } bind def

4 mm 4 mm move
-----

Next comes the scaling. The bounding box of the marks on a PostScript
page can be unknown, so assume that there is a DSC (Document Structuring
Convention) comment "%%BoundingBox" which gives correct information.
You need to know the current paper size, which might be in a device
dictionary. Assume that the orientation ("portrait" or "landscape"
rotation) has been chosen, and requires no further rotation.

If you don't require equal scaling along both axes, then divide
each paper extent (remember to subtract the hard margins) by the
corresponding drawing extent (from the bounding box), and 'scale'
by that much. To fit with equal scaling along both axes then take
the minimum ratio and use that for both axes. For centering, move
the origin parallel to the axis that did not get a tight fit. If
the bounding box does not have the proper corner at the origin,
then another 'move' will be required.

--
Helge Blischke
2011-12-16 17:12:51 UTC
Permalink
Post by John Reiser
Post by jhgrredbjhj
We have around 500 blueprints
Sometimes it is important for a blueprint to be actual size: the user
intends to obtain valid data by measuring marks on the physical print.
The external scale of the physical print must match the internal scale
that was chosen by the author (human or program.)
If so, then the only option for printing is positioning the output
on the page, such as rotation or centering. The printer's 4mm hard
margin may clip some marks, but with a requirement for "actual size"
printing then you have no choice. Choosing "fit to printable area"
and scaling by a factor of 0.97 might just be the *worst possible* output.
Some engineering departments require that drawings have a drawn border
(effectively, a *drawn* bounding box) whose dimensions are known,
so that clipping and scaling can be detected.
Post by jhgrredbjhj
we print each week using ghostscript or
gsprint. Most are us letter but some a4 and a few 11x17. The current
printer has 4mm hard margins on each side. Sometimes the printed
output gets clipped at these hard margins when printing with
ghostscript depending on how close the engineer drew to the edge of
the page. Adobe reader has an option "fit to printable area" that
takes the pdf and scales it up or down to fit within the hard
margins. This is what I am trying to do. How would I know which way
to scale the output and manipulate the origin? Can ghostscript figure
this out somehow?
If the printer has a 4mm hard margin on the two sides that correspond
to the PostScript origin, then move the origin out of the margin using
-----
/inch { 72 mul } bind def
/mm { 25.4 div inch } bind def
4 mm 4 mm move
-----
Next comes the scaling. The bounding box of the marks on a PostScript
page can be unknown, so assume that there is a DSC (Document Structuring
Convention) comment "%%BoundingBox" which gives correct information.
You need to know the current paper size, which might be in a device
dictionary. Assume that the orientation ("portrait" or "landscape"
rotation) has been chosen, and requires no further rotation.
If you don't require equal scaling along both axes, then divide
each paper extent (remember to subtract the hard margins) by the
corresponding drawing extent (from the bounding box), and 'scale'
by that much. To fit with equal scaling along both axes then take
the minimum ratio and use that for both axes. For centering, move
the origin parallel to the axis that did not get a tight fit. If
the bounding box does not have the proper corner at the origin,
then another 'move' will be required.
--
Using PostScript code, you can determine the real bounding box by
clippath pathbbox
which gives the four coordinates determining the lower left and the upper
right corner of the printab le area.

Helge
jhgrredbjhj
2011-12-16 21:10:33 UTC
Permalink
Post by John Reiser
Post by jhgrredbjhj
We have around 500 blueprints
Sometimes it is important for a blueprint to be actual size: the user
intends to obtain valid data by measuring marks on the physical print.
The external scale of the physical print must match the internal scale
that was chosen by the author (human or program.)
Yes but not in our case. This is for work that is much more precise
(0.0005")
than measuring the paper could provide. All dimensions/tolerances are
noted
and the scale of the print is not important. Thanks for your comments
below,
I have yet to digest them.
Post by John Reiser
If the printer has a 4mm hard margin on the two sides that correspond
to the PostScript origin, then move the origin out of the margin using
-----
   /inch { 72 mul } bind def
   /mm { 25.4 div inch } bind def
   4 mm 4 mm move
-----
Next comes the scaling.  The bounding box of the marks on a PostScript
page can be unknown, so assume that there is a DSC (Document Structuring
Convention) comment "%%BoundingBox" which gives correct information.
You need to know the current paper size, which might be in a device
dictionary.  Assume that the orientation ("portrait" or "landscape"
rotation) has been chosen, and requires no further rotation.
If you don't require equal scaling along both axes, then divide
each paper extent (remember to subtract the hard margins) by the
corresponding drawing extent (from the bounding box), and 'scale'
by that much.  To fit with equal scaling along both axes then take
the minimum ratio and use that for both axes.  For centering, move
the origin parallel to the axis that did not get a tight fit.  If
the bounding box does not have the proper corner at the origin,
then another 'move' will be required.
--
ken
2011-12-16 17:31:14 UTC
Permalink
In article <58aab8e2-b98f-41c3-8e8b-
Post by jhgrredbjhj
We have around 500 blueprints we print each week using ghostscript or
gsprint. Most are us letter but some a4 and a few 11x17. The current
printer has 4mm hard margins on each side. Sometimes the printed
output gets clipped at these hard margins when printing with
ghostscript depending on how close the engineer drew to the edge of
the page. Adobe reader has an option "fit to printable area" that
takes the pdf and scales it up or down to fit within the hard
margins. This is what I am trying to do. How would I know which way
to scale the output and manipulate the origin? Can ghostscript figure
this out somehow?
If you set the width and height of the output to be the exact dimensions
of the printable area, and probably set -dFIXEDMEDIA, then set the
PageSizePolicy to '3' which is 'select nearest and scale to fit' then it
should work I would think.

"<</PageSizePolicy 3>> setpagedevice"

Of course, I have no idea how you are sending the output to the printer.


Ken
jhgrredbjhj
2011-12-16 21:11:45 UTC
Permalink
Post by ken
In article <58aab8e2-b98f-41c3-8e8b-
Post by jhgrredbjhj
We have around 500 blueprints we print each week using ghostscript or
gsprint.  Most are us letter but some a4 and a few 11x17.  The current
printer has 4mm hard margins on each side.  Sometimes the printed
output gets clipped at these hard margins when printing with
ghostscript depending on how close the engineer drew to the edge of
the page.  Adobe reader has an option "fit to printable area" that
takes the pdf and scales it up or down to fit within the hard
margins.  This is what I am trying to do.  How would I know which way
to scale the output and manipulate the origin?  Can ghostscript figure
this out somehow?
If you set the width and height of the output to be the exact dimensions
of the printable area, and probably set -dFIXEDMEDIA, then set the
PageSizePolicy to '3' which is 'select nearest and scale to fit' then it
should work I would think.
"<</PageSizePolicy 3>> setpagedevice"
Of course, I have no idea how you are sending the output to the printer.
                        Ken
Thank you! Will be testing!
Loading...