Customizing Print Driver Plug-Ins

 

You can use print drivers other than those provided with Version 5. This task provides a step-by-step scenario describing how to plug-in your own print drivers in your Version 5 environment without CAA context using CATPrtDrvPlugins.

A CATPrtDrvPlugin is made of one group of 10 functions and one shared data structure:

  • Plug-in methods are functions you implement in the plug-in. These functions will then be called by Version 5. Their names all begin with "CATPDP_", for instance CATPDP_Begin
  • Data structures are plug-in-specific types defined for use in the plug-in API. Their names begin with "CATPDP", for instance CATPDPParameters. All plug-in API structures and definitions are found in CATPDPluginAPI.h located in $CATStartupPath\startup\PrintServices\PrintDriverPlugIn.

    Click the thumbnail below to find a description of the structure of CATPDPParameters:
 

  A plug-in is a native code library whose source conforms to standard C syntax.

The plug-in file type depends on the platform you are working on:

  • Windows: .DLL (Dynamic Link Library) files
  • UNIX: .SO or .DSO (Shared Objects) files.

You can use the template file (CATPluginTemplate.cpp) located in $CATStartupPath\startup\PrintServices\PrintDriverPlugIn and adapt it to your needs by implementing the plug-in methods provided by Version 5.

When the code has been written, you will have to compile and build the module then declare the resulting module to the Print Driver Manager File. The file CATPDPlugin.mak provided in $CATStartupPath\startup\PrintServices\PrintDriverPlugIn\BUILD\WINDOWS can help you build your library module.

 

  1. Access the file CATPluginTemplate.cpp located in:

    $CATStartupPath\startup\PrintServices\PrintDriverPlugIn

  2. Write the code corresponding to the interfaces to implement the plug-in methods that will be called by Version 5.

    For information about the syntax and use of C or C++ language, refer to your language documentation.

    The methods provided are listed in the table below. Click the desired method to access the corresponding description:

    Method Name Description
    CATPDPP_Begin Driver initialization with parameters provided by user interface
    CATPDP_End Indicates if the plug-in driver is about to be closed or removed
    CATPDP_DefineColor Defines a RGB color in the palette
    CATPDP_SelectDrawColor Selects the drawing color
    CATPDP_SetDrawWidth Selects the drawing path
    CATPDP_MoveTo Moves the pen without drawing
    CATPDP_LineTo Draws a line
    CATPDP_SelectFillColor Selects the filling color for polygon primitives
    CATPDP_FillArea Fills a polygon
    CATPDP_DrawBitmap Draws a bitmap
    --------------------------------------------------------------------------------------------------------------------

    CATPDP_Begin
    Provide global initialization for the plug-in driver.

    Syntax
    #include < CATPDPluginAPI.h >
    CATPDPError CATPDP_Begin(const CATPDPParameters& iParam);

    Parameters
    iParams     Global structure data parameters.
                   Various user printing options

    Returns

    • If successful, the function returns CATPDP_NO_ERROR
    • If unsuccessful, the plug-in the function returns an error code.

    Description
    This is the first call used from the V5 Printer Manager to inform the driver plug-in the the printing is started. The Printer Manager fills the CATPDPParameters according to the user choices. This structure is then passed to the plug-in by calling the CATPDP_Begin function.

    Back to Method summary

    --------------------------------------------------------------------------------------------------------------------

    CATPDP_End
    Provide global deinitialization for the plug-in driver.

    Syntax
    #include < CATPDPluginAPI.h >
    CATPDPError CATPDP_End(void);

    Parameters
    No parameters

    Returns

    • If successful, the function returns CATPDP_NO_ERROR
    • If unsuccessful, the plug-in the function returns an error code.

    Description
    The V5 Printer manager calls this function once the printing is done. Be sure to release allocations , instances or file I/O flushing in this function. After this call the plug-in driver is unloaded and the printing stopped.

    Back to Method summary

    --------------------------------------------------------------------------------------------------------------------

    CATPDP_DefineColor
    Defines a color in the palette.

    Syntax
    #include < CATPDPluginAPI.h >
    CATPDPError CATPDP_DefineColor(int iIndex , float iRed, float iGreen, float iBlue);

    Parameters
    iIndex      Index in the color table (between 0 and 255)
    iRed        Red color in RGB coordinates (between 0 and 1)
    iGreen     Green color in RGB coordinates (between 0 and 1)
    iRed        Blue color in RGB coordinates (between 0 and 1)

    Returns

    • If successful, the function returns CATPDP_NO_ERROR
    • If unsuccessful, the plug-in the function returns an error code.

    Description
    Defines a color in rgb coordinates. This index is used for function CATPDP_SelectDrawColor or CATPDP_SelectFillColor.

    Back to Method summary

    --------------------------------------------------------------------------------------------------------------------

    CATPDP_SelectDrawColor
    Selects the drawing color.

    Syntax
    #include < CATPDPluginAPI.h >
    CATPDPError CATPDP_SelectDrawColor(int index);

    Parameters
    iIndex    Index of the current drawing color (between 0 and 255)
                used for next drawing primitive

    Returns

    • If successful, the function returns CATPDP_NO_ERROR
    • If unsuccessful, the plug-in the function returns an error code.

    Description
    Selects the current drawing color related to the index defined by the CATPDP_DefineColor.

    Back to Method summary

    --------------------------------------------------------------------------------------------------------------------

    CATPDP_SetDrawWidth
    Selects the current draw width.

    Syntax
    #include < CATPDPluginAPI.h >
    CATPDPError CATPDP_ SetDrawWidth (float iWidth);

    Parameters
    IWith    Thickness in mm of the current drawing with
                used for next drawing primitives

    Returns

    • If successful, the function returns CATPDP_NO_ERROR
    • If unsuccessful, the plug-in the function returns an error code.

    Description
    Selects the current draw width. The width is in mm.

    Back to Method summary

    --------------------------------------------------------------------------------------------------------------------

    CATPDP_MoveTo
    Moves the pen without drawing.

    Syntax
    #include < CATPDPluginAPI.h >
    CATPDPError CATPDP_MoveTo(float iX, float iY);

    Parameters
    iX      X coordinate to move
    iY      Y coordinate to move

    Returns

    • If successful, the function returns CATPDP_NO_ERROR
    • If unsuccessful, the plug-in the function returns an error code.

    Description
    Moves the pen to (x, y) in device coordinates without drawing. Coordinates are in mm.

    Back to Method summary

    --------------------------------------------------------------------------------------------------------------------

    CATPDP_LineTo
    Draws a line.

    Syntax
    #include < CATPDPluginAPI.h >
    CATPDPError CATPDP_LineTo(float iX, float iY)

    Parameters
    iX      X coordinate to draw
    iY      Y coordinate to draw

    Returns

    • If successful, the function returns CATPDP_NO_ERROR
    • If unsuccessful, the plug-in the function returns an error code.

    Description
    Draws a line from the current pen position to (x, y) in device coordinates with current draw color, line type and draw width.

    Back to Method summary

    --------------------------------------------------------------------------------------------------------------------

    CATPDP_SelectFillColor
    Selects the fill color.

    Syntax
    #include < CATPDPluginAPI.h >
    CATPDPError CATPDP_SelectFillColor (int iIndex )

    Parameters
    iIndex     Index of the current Fill color (between 0 and 255)
                 used for next Fill primitive

    Returns

    • If successful, the function returns CATPDP_NO_ERROR
    • If unsuccessful, the plug-in the function returns an error code.

    Description
    Selects the current filling color related to the index defined by the CATPDP_DefineColor.

    Back to Method summary

    --------------------------------------------------------------------------------------------------------------------

    CATPDP_FillArea
    Fills a polypolygon.

    Syntax
    #include < CATPDPluginAPI.h >
    CATPDPError CATPDP_FillArea(int iOutlines, const int* iCorners, const float* iCoord)

    Parameters
    IOutlines     number of polygons in the polypolygon.
    iCorners      array of outlines integers giving the number of corners in each polygon.
    iCoord        array of floats giving the coordinates of alls corners of each polygon

    Returns

    • If successful, the function returns CATPDP_NO_ERROR
    • If unsuccessful, the plug-in the function returns an error code.

    Description
    Fills a polypolygon in device coordinates with current fill color.

    Back to Method summary

    --------------------------------------------------------------------------------------------------------------------

    CATPDP_DrawBitmap
    Draws a bitmap.

    Syntax
    #include < CATPDPluginAPI.h >
    CATPDPError CATPDP_DrawBitmap(float iX, float iY, const int iTypeOfBitmap, const unsigned char* iPixels, const int iSize);

    Parameters
    iX                         X coordinate of the bitmaps to draw
    iY                         Y coordinate of the bitmaps to draw
    iTypeOfBitmap         color mode of bitmap: 0 = RGB , 1 = Black and White bitmap
    iPixels                    array of pixels
    iSize                      size in bytes of the pixel array

    Returns

    • If successful, the function returns CATPDP_NO_ERROR
    • If unsuccessful, the plug-in the function returns an error code.

    Description
    Draws a bitmap in device coordinates at the given (x, y) position.

    Back to Method summary

    --------------------------------------------------------------------------------------------------------------------

  3. Compile and build the module.

    You can use the file CATPDPlugin.mak provided in $CATStartupPath\startup\PrintServices\PrintDriverPlugIn\BUILD\WINDOWS.
  4. In your Version 5 session, select File > Printer Setup to open the Printers dialog box:

  5. Double-click Add Printer.

    • If you are working on Windows, an additional dialog box named Add Printer Wizard opens:
    This dialog box enables you to choose between:
    • Windows Printer: in that case, selecting this option then OK opens the
      Connect to Printer dialog box in which you will select the Windows printer you
      wish to add
    • 3D PLM Printer: this option lets you add printers provided by Dassault Systèmes.
      When clicking OK, the Printer Properties dialog box is displayed to let you define
      the parameters for your new printer.

    Click OK to access the Printer Properties dialog box.

    • If you are working on UNIX, the Printer Properties dialog box opens directly:
  6. Select V5 Print Plugin Driver from the Driver list.

  7. Click Advanced Configuration... to access the following dialog box:

  8. In the Plugin Driver selection box, enter the path of the library module you built in step 3 or click Plugin... which enables you to browse your file tree.

  9. Select File > Print to open the Print dialog box:

  10. Indicate the name of the new customized printer in the Printer Name box.

  11. Modify the desired print settings (refer to Customizing Print Settings Before Printing Your Documents for detailed information) then click OK to confirm and print your document.