ImageGear for C and C++ on Linux v20.0 - Updated
IG_ascii_page_width_get
API Reference Guide > Core Component API Reference > Core Component Functions Reference > ASCII Functions > IG_ascii_page_width_get

This function returns the width of an ASCII file that has not been loaded yet.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_ascii_page_width_get (
        const LPSTR lpszFileName, 
        LPUINT lpPageWidth
);

Arguments:

Name Type Description
lpszFileName const LPSTR Set to the name of the ASCII file from which to get the width.
lpPageWidth LPUINT A far pointer that returns a value of type UINT indicating the width of the file in thousands of an inch.

Return Value:

Returns the number of ImageGear errors that occurred during this function call. If there are no errors, the return value is IGE_SUCCESS.

Supported Raster Image Formats:

This function does not process image pixels.

Example:

 
Copy Code
HIGEAR hIGear;        /* HIGEAR handle of image   */
AT_ERRCOUNT nErrcount;     /* total # of ImageGear errors on the stack*/
UINT pageWidth;     /* returns the width of the ASCII file */
UINTpointSize; /* to get and possibly set the point size of the font */
AT_REAL reduction;    /* percentage of reduction possibly needed on the point size before
the image is loaded with a width of 8.5 inches   */
nErrcount = IG_ascii_page_width_get("Hamlet.txt", &pageWidth);
if (pageWidth > 8500)
/* if the width of the unloaded page is greater than 8.5 inches, we will resize it to 8.5
inches before loading it. However, to avoid cropping any words, we will first reduce the
point size by the percentage needed to make each line fit on an 8.5 inch page */
{
        reduction = 8500/pageWidth;
        pointSize = (UINT)(pointSize * reduction + 0.5);
        nErrcount = 
                IG_fltr_ctrl_set(IG_FORMAT_TXT, "POINT_SIZE", 
                (LPVOID)pointSize, sizeof(pointSize));
        nErrcount = 
                IG_fltr_ctrl_set(IG_FORMAT_TXT, "PAGE_WIDTH", 
                (LPVOID)8500, sizeof(nPageWidth));
}
nErrcount = IG_ascii_import("Hamlet.txt", 1, &hIGear);

Remarks:

Specify the path/filename of an ASCII file, and this function will return the width in thousands of an inch. For example, if the file has a width of 8.5 inches, this function returns the value 8500.

The width of the page (as well as many other attributes) can be set before the page is loaded. See the description for IG_ascii_import()for the full list of attributes that can be determined prior to loading.

As an alternative to this function, you can use IG_fltr_ctrl_get() with the control parameter argument "PAGE_WIDTH".

Is this page helpful?
Yes No
Thanks for your feedback.