Foxit PDF SDK

Public Member Functions | List of all members
foxit::pdf::PSI Class Reference
Inheritance diagram for foxit::pdf::PSI:

## Public Member Functions
| PSI (common::Bitmap &bitmap, bool simulate)
| Constructor, with a bitmap as canvas. More...
| PSI (const PSI &other)
| Constructor, with another PSI object. More...
| PSI (int width, int height, bool simulate)
| Constructor, with specified width and height for canvas. More...
| ~PSI ()
| Destructor.
void | AddPoint (const PointF &point, common::Path::PointType type, float pressure)
| Add a point. More...
annots::PSInk | ConvertToPDFAnnot (const PDFPage &page, const RectF &annot_rect, common::Rotation rotate)
| Convert a PSI object to a PSInk annotation and insert the PSInk annotation to a PDF page. More...
common::Bitmap | GetBitmap ()
| Get the canvas bitmap. More...
RectF | GetContentsRect ()
| Get contents rectangle. More...
bool | IsEmpty () const
| Check whether current object is empty or not. More...
bool | operator!= (const PSI &other) const
| Not equal operator. More...
PSI & | operator= (const PSI &other)
| Assign operator. More...
bool | operator== (const PSI &other) const
| Equal operator. More...
void | SetCallback (PSICallback *callback)
| Set a callback object for refreshing. More...
void | SetColor (RGB color)
| Set ink color. More...
void | SetDiameter (int diameter)
| Set ink diameter. More...
void | SetOpacity (float opacity)
| Set ink opacity. More...
Public Member Functions inherited from foxit::Base
FS_HANDLE | Handle () const
| Get the handle of current object. More...

## Detailed Description

PSI, "pressure sensitive ink", is specially defined for manual signature, and usually works together with a handwriting board or for a touchscreen. PSI contains private coordinates, and a canvas is created in its coordinates. Canvas limits operating area and generates appearance of PSI.
PSI is independent of PDF, and can even be used directly in the device screen. If user wants to save a PSI object to PDF file, please call function PSI::ConvertToPDFAnnot. This function will convert PSI data to a PSInk annotation (as a Foxit custom annotation type) and insert the PSInk annotation to the specified position in a PDF page.

See also
  annots::PSInk

## Constructor & Destructor Documentation

## ◆ PSI() [1/3]

foxit::pdf::PSI::PSI | ( | common::Bitmap & | bitmap,
|  | bool | simulate
| ) |  |

Constructor, with a bitmap as canvas.

Parameters

  [in] | bitmap | A bitmap used as canvas. It should be created with common::Bitmap::e_DIBArgb format. User should ensure this bitmap to keep valid until current PSI object is released.
  [in] | simulate | Used to decide whether to turn on simulation of PSI or not: true means to turn on simulation, and false means to turn off simulation. It can simulate handwriting weights by writing speed when simulation is on.

## ◆ PSI() [2/3]

foxit::pdf::PSI::PSI | ( | int | width,
|  | int | height,
|  | bool | simulate
| ) |  |

Constructor, with specified width and height for canvas.

Parameters

  [in] | width | Width of PSI canvas in device coordinate system. This shall be greater than 0.
  [in] | height | Height of PSI canvas in device coordinate system. This shall be greater than 0.
  [in] | simulate | Used to decide whether to turn on simulation of PSI or not: true means to turn on simulation, and false means to turn off simulation. It can simulate handwriting weights by writing speed when simulation is on.

## ◆ PSI() [3/3]

foxit::pdf::PSI::PSI | ( | const PSI & | other | ) |

Constructor, with another PSI object.

Parameters

  [in] | other | Another PSI object.

## Member Function Documentation

## ◆ AddPoint()

void foxit::pdf::PSI::AddPoint | ( | const PointF & | point,
|  | common::Path::PointType | type,
|  | float | pressure
| ) |  |

Add a point.

Parameters

  [in] | point | A point in canvas coordinate system.
  [in] | type | Point type. This should be one of following values: common::Path::e_TypeMoveTo, common::Path::e_TypeLineTo, common::Path::e_TypeLineToCloseFigure,
  [in] | pressure | Pressure value for this point. Valid range: from 0.0 to 1.0.

Returns
  None.

## ◆ ConvertToPDFAnnot()

annots::PSInk foxit::pdf::PSI::ConvertToPDFAnnot | ( | const PDFPage & | page,
|  | const RectF & | annot_rect,
|  | common::Rotation | rotate
| ) |  |

Convert a PSI object to a PSInk annotation and insert the PSInk annotation to a PDF page.

Actually, this function is to convert the path data of current PSI to a PSInk annotation, ignoring the canvas bitmap.
Before calling this function, user should ensure that current PSI object has contained a valid path (whose last point's type is common::Path::e_TypeLineToCloseFigure. Otherwise, the conversion will be failed and this function will throw exception foxit::e_ErrInvalidData.

Parameters

  [in] | page | A valid PDF page object, to which the PSI is expected to inserted.
  [in] | annot_rect | A rectangle to specify the position in the PDF page, where the new PSInk annotation will be inserted. It should be valid in PDF coordinate system.
  [in] | rotate | Rotation value. Currently, it can only be common::e_Rotation0.

Returns
  A new PSInk annotation object.

Note
  User do not need to call function annots::Annot::ResetAppearanceStream (inherited from PSInk's parent class) to reset the appearance of PSInk annotation after this conversion.

## ◆ GetBitmap()

common::Bitmap foxit::pdf::PSI::GetBitmap | ( |  | ) |

Get the canvas bitmap.

Returns
  Canvas bitmap.

## ◆ GetContentsRect()

RectF foxit::pdf::PSI::GetContentsRect | ( |  | ) |

Get contents rectangle.

Returns
  Contents rectangle, in device coordinate system. If current PSI object does not contain a valid path, a RectF object with all 0 values would be returned.

## ◆ IsEmpty()

bool foxit::pdf::PSI::IsEmpty | ( |  | ) | const

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
  true means current object is empty, while false means not.

## ◆ operator!=()

bool foxit::pdf::PSI::operator!= | ( | const PSI & | other | ) | const

Not equal operator.

Parameters

  [in] | other | Another PSI object. This function will check if current object is not equal to this one.

Returns
  true means not equal, while false means equal.

## ◆ operator=()

PSI& foxit::pdf::PSI::operator= | ( | const PSI & | other | ) |

Assign operator.

Parameters

  [in] | other | Another PSI object, whose value would be assigned to current object.

Returns
  Reference to current object itself.

## ◆ operator==()

bool foxit::pdf::PSI::operator== | ( | const PSI & | other | ) | const

Equal operator.

Parameters

  [in] | other | Another PSI object. This function will check if current object is equal to this one.

Returns
  true means equal, while false means not equal.

## ◆ SetCallback()

void foxit::pdf::PSI::SetCallback | ( | PSICallback * | callback | ) |

Set a callback object for refreshing.

Parameters

  [in] | callback | A callback object PSICallback which is implemented by user. Please ensure that the callback object keeps valid until the life-cycle of current PSI object ends.

Returns
  None.

## ◆ SetColor()

void foxit::pdf::PSI::SetColor | ( | RGB | color | ) |

Set ink color.

This should be set before adding first point to PSI object. If not set, the default value 0x000000 will be used.

Parameters

  [in] | color | Ink color. Format: 0xRRGGBB.

Returns
  None.

## ◆ SetDiameter()

void foxit::pdf::PSI::SetDiameter | ( | int | diameter | ) |

Set ink diameter.

This should be set before adding first point to PSI object. If not set, the default value 10 will be used.

Parameters

  [in] | diameter | Ink diameter. This should be bigger than 1.

Returns
  None.

## ◆ SetOpacity()

void foxit::pdf::PSI::SetOpacity | ( | float | opacity | ) |

Set ink opacity.

This should be set before adding first point to PSI object. If not set, the default value 1.0 will be used.

Parameters

  [in] | opacity | Ink opacity. Valid range: from 0.0 to 1.0. 0.0 means full transparency and 1.0 means full opaque.

Returns
  None.