[cairo] Re: Some thoughts on metadata

Michael Sweet mike at easysw.com
Mon May 1 12:58:36 PDT 2006

Carl Worth wrote:
> On Mon, 01 May 2006 13:56:08 -0400, Michael Sweet wrote:
>> WRT orientation, I would say that it is sufficient to allow the
>> developer to change the page size to be a landscape aspect ratio
>> to indicate the orientation, and/or do rotation.  That is
>> sufficient to achieve 0, 90, 180, and 270 degree rotations.
> The orientation control is something that left me quite confused as I
> tried studying it this weekend.
> There's obviously a difference between page-feed direction, (that is a
> printer tray could provide short-edge or long-edge first), and logical
> content orientation, (the direction to present the page to a human
> viewer so it looks correct).

Correct, however the printer and/or driver can handle this for you.

> I notice that PostScript/DSC provide per-page PageOrientation control
> but with values of only "Portrait" or "Landscape". Meanwhile PDF does
> provide a Rotate option that can accept any multiple of 90 degrees.
> Additionally, it's quite obvious that there are PPD options that
> control orientation as well.

In some cases, yes.  ALL Level 2 and higher printers, however, MUST
support setpagedevice with landscape PageSize values, and
automatically rotate as needed.  The PPD LandscapeOrientation
attribute provides the hint to the application about which
direction a landscape print job will be rotated (+ or - 90 degrees)

> So what I'm left wondering is what is the right way to generate a
> PostScript file that has multiple orientations in it. For example,
> given a page size of SHORTxLONG should cairo generate all pages with
> the same bounding box of [0 0 SHORT LONG], say, and then include hints
> to allow viewers to properly rotate things for humans?

That is one way, but...

> Or should cairo generate pages with both [0 0 SHORT LONG] and [0 0
> LONG SHORT] for the bounding boxes? That would let viewer applications
> do the obvious thing and users would see the correct result. And then
> would CUPS step in and rotate the content as necessary so that the
> printer receives the content it needs?

Yes, and this is the way I would recommend you do it since there
are printers that print on landscape media (that is, the long edge
is the leading edge...) and you need to support both types of
devices.  Using SHORT LONG for portrait and LONG SHORT for
landscape is guaranteed to work in all circumstances.

If you want to get fancy, you can add a rotation angle parameter
to the size API, e.g.:

     cairo_set_page_size(float width, float height, int rotation);

where "rotation" can be 0, 90, 180, or 270.  All you'd need to do
is initialize the CTM to the proper matrix (identity for 0 degrees).

Michael Sweet, Easy Software Products           mike at easysw dot com
Internet Printing and Document Software          http://www.easysw.com

More information about the cairo mailing list