ImageGear for C and C++ on Linux - Updated
Printing Images
User Guide > How to Work with... > Common Operations > Printing Images

ImageGear provides the following print capabilities:

Basic printing can done using a single all-purpose printing function (IG_dspl_image_print) that will print any image to a graphics-capable printer:

 
Copy Code
IG_dspl_image_print ( HIGEAR hIGear, DWORD dwGrpID, HDC hDC, BOOL bDirectToDriver );

This function prints a HIGEAR image to the current default printer according to the display parameter specified by dwGrpID group. There is a special group IG_GRP_DEFAULT_PRINT that can be used to print an image with the default print options. See the section Viewing for an introduction to display option groups.

In general, bDirectToDriver = FALSE gives you greater control of the printing process, while bDirectToDriver = TRUE gives you faster printing.

Apart from IG_dspl_image_print, you can use the following functions if you need to print multiple images on a single page, or need more control over the positioning or scale of the image(s):

For printing ArtX annotations, use the following functions:

For printing PDF documents, use the following function:

The following snippet shows how to print a single image on a single page using default settings, printing to file using the Microsoft XPS Document Writer printer driver:

C and C++
Copy Code
    HMIGEAR image;
    DOCINFO docInfo;
    HDC deviceContext;

    // Load the image we want to print.
    IG_load_file("sample.bmp", &image);

    // Set the Windows related document printing parameters.
    docInfo.cbSize = sizeof(DOCINFO);
    docInfo.lpszDocName = "Sample Document";
    docInfo.lpszOutput = "sample.xps";
    docInfo.lpszDatatype = NULL;
    docInfo.fwType = 0;

    // Set up the DC used for printing, indicating the printer driver.
    deviceContext = CreateDC("WINSPOOL", "Microsoft XPS Document Writer", NULL, NULL);

    // Start the print job and a new page.
    StartDoc(deviceContext, &docInfo);
    StartPage(deviceContext);

    // Print the image directly to the device using the default print options group.
    IG_dspl_image_print(image, (DWORD)IG_GRP_DEFAULT_PRINT, deviceContext, TRUE);

    // Signal the end of the page and the print job.
    EndPage(deviceContext);
    EndDoc(deviceContext);

    // Clean up.
    DeleteDC(deviceContext);

Samples

The following samples demonstrate the use of the print functions, how to initialize printing options, and how to show an initial Print Dialog: