ImageGear for C and C++ on Linux v20.0 - Updated
Printing Images
[No Target Defined] > [No Target Defined] > Common Operations > Viewing > 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 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);

    // 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.

    // Clean up.


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

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