Twips

Twips are the measurement units for PageMaker commands and queries. Internally, PageMaker represents and stores measurement information in twips. Likewise, plug-ins that use commands and queries in the PageMaker Class Library must use twips to represent units of measure.

A twip is defined as a twentieth of a pica point. To convert from points, picas, inches, millimeters, or other units to/from twips, use the PGetConvertStr and PGetConvertTwips query classes.

Throughout this documentation, you will see a function named twips( ) that converts common units of measurement into twips. This simple function is based on the PGetConvertStr query, and is shown below. This twips( ) function is included in the SDK in the file "Twips.cpp".

long twips(const char * ch)
{
    try {
        PGetConvertStr result(ch, kParmDontCare);
        return result;
    }
    catch (PMErr) {
       return 0;
    };
}

An example of this function:

long len = twips("3i"); // convert 3 inches to twips
PNudge(len, 0); // nudge the selected object three inches to the right.

To learn more about the strings representing units of measure that you can pass to the twips( ) function, refer to the documentation for PGetConvertStr.

Alternatively, you can use the following constants to convert to/from twips without using twips( ) or PGetConvertStr. This may improve performance in situations where your plug-in is doing a large number of measurement conversions.

Units Ratio
Twips per Inch 1440
Twips per Centimeter 72000 / 127
Twips per Millimeter 7200 / 127
Twips per PicaPoint 20
Twips per Pica 240
Twips per Cicero 6394 / 25
Twips per Didot 12000 / 563


Copyright © 1996, Adobe Systems Incorporated. All rights reserved.

Comments or suggestions? Contact Adobe Developer Support