Foxit PDF SDK

Instance Methods | List of all members
FSReflowPage Class Reference
Inheritance diagram for FSReflowPage:

## Instance Methods
(float) | - getContentHeight
| Get content height after current reflow page object has been parsed. More...
(float) | - getContentWidth
| Get content width after current reflow page object has been parsed. More...
(FSMatrix2D *) | - getDisplayMatrix:offset_y:width:height:rotate:
| Get the display matrix, according to the offset of top side between current reflow page and screen. More...
(NSString *) | - getFocusData:point:
| Get focus data corresponding to a given position in device coordinate system. More...
(FSPointF *) | - getFocusPosition:focus_data:
| Get the position in device coordinate system corresponding to a given focus data. More...
(id) | - initWithOther:
| Constructor, with another reflow page object. More...
(id) | - initWithPage:
| Constructor, from a parsed PDF page. More...
(BOOL) | - isEmpty
| Check whether current object is empty or not. More...
(BOOL) | - isParsed
| Check if current reflow page has been parsed or not. More...
(void) | - setImageScale:
| Set image scale. This can be called before calling function FSReflowPage::startParse:. More...
(void) | - setLineSpace:
| Set line space. This can be called before calling function FSReflowPage::startParse:. More...
(void) | - setParseFlags:
| Set the parsing flag. This can be called before calling function FSReflowPage::startParse:. More...
(void) | - setScreenMargin:top:right:bottom:
| Set margin. This can be called before calling function FSReflowPage::startParse:. More...
(void) | - setScreenSize:height:
| Set screen size. This should be called before calling functions FSReflowPage::startParse: and FSReflowPage::setLineSpace:. More...
(void) | - setTopSpace:
| Set the top space. This can be called before calling function FSReflowPage::startParse:. More...
(void) | - setZoom:
| Set zoom factor. This can be called before calling function FSReflowPage::startParse:. More...
(FSProgressive *) | - startParse:
| Start to parse current reflow page. More...

## Detailed Description

In order to display page contents in a small screen device, Foxit PDF SDK introduces the concept of "reflow page". In the reflow page, original PDF page contents will be laid out to fit the specified screen size.
For a PDF page, user may wants to keep focusing on a location in the reflow page when user switches between this PDF page and its related reflow page, or switch among these related reflow pages which are in different size. In order to track the focus location, Foxit PDF SDK uses "focus data" to represent the focus location. Focus data is similar to bookmark or destination in PDF, but it is simpler. User can store the focus data (or save the data to file) so that user can retrieve the focus location again by the focus data later, even if the size of reflow page is changed.
A reflow page object should be constructed from a parsed PDF page. This class offers functions to:

- Start to parse a reflow page by functions FSReflowPage::startParse:. Before parsing a reflow page, use should use function FSReflowPage::setScreenSize:height: to specify the screen size for the reflow page. User can also use following functions to specify other factors which will affect on the parsing result for the reflow page: FSReflowPage::setZoom:, FSReflowPage::setParseFlags:, FSReflowPage::setLineSpace:, FSReflowPage::setImageScale:, FSReflowPage::setTopSpace:. If these function are not called before parsing a reflow page, default values will be used. Please refer to comment of these functions for more details.
- Get the actual content size and matrix of a parsed reflow page, by functions FSReflowPage::getContentWidth, FSReflowPage::getContentHeight,FSReflowPage::getDisplayMatrix:offset_y:width:height:rotate:.
- Get the focus data for a specified position in reflow page, by function FSReflowPage::getFocusData:point:, or retrieve the position by a focus data, by function FSReflowPage::getFocusPosition:focus_data:.

To render the reflow page, please use function FSRenderer::startRenderReflowPage:matrix:pause:.

See also
  FSPDFPage
  FSRenderer

## Method Documentation

## ◆ getContentHeight()

- (float) getContentHeight |  |  |

Get content height after current reflow page object has been parsed.

Returns
  Content height.

## ◆ getContentWidth()

- (float) getContentWidth |  |  |

Get content width after current reflow page object has been parsed.

Returns
  Content width.

## ◆ getDisplayMatrix:offset_y:width:height:rotate:()

- (FSMatrix2D *) getDisplayMatrix: |  | (float) | offset_x
offset_y: |  | (float) | offset_y
width: |  | (int) | width
height: |  | (int) | height
rotate: |  | (FSRotation) | rotate

Get the display matrix, according to the offset of top side between current reflow page and screen.

This function can only be used when reflow page has been parsed.

Parameters

  [in] | offset_x | Offset value, which means the offset from top side of current reflow page to the top side of screen.
  [in] | offset_y | Offset value, which means the offset from left side of current reflow page to the left side of screen.
  [in] | width | Width of the transformation area in screen, commonly in pixels.
  [in] | height | Height of the transformation area in screen, commonly in pixels.
  [in] | rotate | Rotation value. Please refer to values starting from FSRotation0 and this should be one of these values.

Returns
  The display matrix.

## ◆ getFocusData:point:()

- (NSString *) getFocusData: |  | (FSMatrix2D*) | matrix
point: |  | (FSPointF*) | point

Get focus data corresponding to a given position in device coordinate system.

This function can only be used when reflow page has been parsed.
Focus data, similar to bookmark or destination in PDF, is used to locate the position of a specified content in reflow page. For a PDF page, position of a specified content is fixed and will not be changed even if the size of related reflow page is changed. So focus data can be used to locate the same content from a PDF page in its related reflow pages with different sizes but same reflow content.
Usually, user can call function FSReflowPage::getFocusData:point: to get focus data for a specified location, and store the focus data. When the reflow page's size is changed, user can use the stored focus data in function FSReflowPage::getFocusPosition:focus_data: to get the new position and then still focus on or near the same content.

Parameters

  [in] | matrix | A matrix returned by function FSReflowPage::getDisplayMatrix:offset_y:width:height:rotate:.
  [in] | point | The point of a specified position, in device coordinate system.

Returns
  The focus data.

## ◆ getFocusPosition:focus_data:()

- (FSPointF *) getFocusPosition: |  | (FSMatrix2D*) | matrix
focus_data: |  | (NSString *) | focus_data

Get the position in device coordinate system corresponding to a given focus data.

This function can only be used when reflow page has been parsed.
Focus data, similar to bookmark or destination in PDF, is used to locate the position of a specified content in reflow page. For a PDF page, position of a specified content is fixed and will not be changed even if the size of related reflow page is changed. So focus data can be used to locate the same content from a PDF page in its related reflow pages with different sizes but same reflow content.
Usually, user can call function FSReflowPage::getFocusData:point: to get focus data for a specified location, and store the focus data. When the reflow page's size is changed, user can use the stored focus data in function FSReflowPage::getFocusPosition:focus_data: to get the new position and then still focus on or near the same content.

Parameters

  [in] | matrix | A matrix returned by function FSReflowPage::getDisplayMatrix:offset_y:width:height:rotate:.
  [in] | focus_data | Focus data used to get its corresponding position in device coordinate system, with specified matrix. This is retrieved by previous calling of function FSReflowPage::getFocusData:point:.

Returns
  The position in device coordinate system.

## ◆ initWithOther:()

- (id) initWithOther: |  | (FSReflowPage*) | other |

Constructor, with another reflow page object.

Parameters

  [in] | other | Another reflow page object.

## ◆ initWithPage:()

- (id) initWithPage: |  | (FSPDFPage*) | page |

Constructor, from a parsed PDF page.

Parameters

  [in] | page | A valid PDF page object which has been parsed.

## ◆ isEmpty()

- (BOOL) isEmpty |  |  |

Check whether current object is empty or not.

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

Returns
  YES means current object is empty, while NO means not.

## ◆ isParsed()

- (BOOL) isParsed |  |  |

Check if current reflow page has been parsed or not.

Returns
  YES means current reflow page has been parsed, while NO means current page has not been parsed yet.

## ◆ setImageScale:()

- (void) setImageScale: |  | (float) | image_scale |

Set image scale. This can be called before calling function FSReflowPage::startParse:.

Parameters

  [in] | image_scale | The image scale. This value should be positive number. If no image scale is set, value 1.0f will be used by default.

Returns
  None.

## ◆ setLineSpace:()

- (void) setLineSpace: |  | (float) | line_space |

Set line space. This can be called before calling function FSReflowPage::startParse:.

Parameters

  [in] | line_space | The line space. This value should between -25 to (screen height/2), screen height set by the function FSReflowPage::setScreenSize:height:. If no line space is set, value 0 will be used by default.

Returns
  None.

## ◆ setParseFlags:()

- (void) setParseFlags: |  | (unsigned int) | flags |

Set the parsing flag. This can be called before calling function FSReflowPage::startParse:.

Parameters

  [in] | flags | Parsing flags. Please refer to values starting from FSReflowPageNormal and this should be one or a combination of these values. If no parsing flag is set, value FSReflowPageNormal will be used by default.

Returns
  None.

## ◆ setScreenMargin:top:right:bottom:()

- (void) setScreenMargin: |  | (int) | left
top: |  | (int) | top
right: |  | (int) | right
bottom: |  | (int) | bottom

Set margin. This can be called before calling function FSReflowPage::startParse:.

If no margin has ever been set to current reflow page, Foxit PDF SDK will use value (0, 0, 0, 0) as default margin.
If new margin is set, the new margin will take effect until current reflow page has been re-parsed and rendered again.

Parameters

  [in] | left | The left margin. This value should between 0 and (screen width / 3), screen width set by the function FSReflowPage::setScreenSize:height:.
  [in] | top | The top margin. This value should between 0 and (screen height/ 3), screen height set by the function FSReflowPage::setScreenSize:height:.
  [in] | right | The right margin. This value should between 0 and (screen width / 3), screen width set by the function FSReflowPage::setScreenSize:height:.
  [in] | bottom | The bottom margin. This value should between 0 and (screen height / 3), screen height set by the function FSReflowPage::setScreenSize:height:.

Returns
  None.

## ◆ setScreenSize:height:()

- (void) setScreenSize: |  | (float) | width
height: |  | (float) | height

Set screen size. This should be called before calling functions FSReflowPage::startParse: and FSReflowPage::setLineSpace:.

Before parsing a reflow page and setting line space, user should call this function to set the screen size for parsing the reflow page.

Parameters

  [in] | width | The screen width.
  [in] | height | The screen height.

Returns
  None.

## ◆ setTopSpace:()

- (void) setTopSpace: |  | (float) | top_space |

Set the top space. This can be called before calling function FSReflowPage::startParse:.

This function is used to set the distance between the page's top and the screen's top. The distance will take effect when parsing a reflow page.

Parameters

  [in] | top_space | The top space. This value should between 0 and height. If no top space is set, value 0 will be used by default.

Returns
  None.

## ◆ setZoom:()

- (void) setZoom: |  | (int) | zoom |

Set zoom factor. This can be called before calling function FSReflowPage::startParse:.

If no zoom factor has ever been set to current reflow page, Foxit PDF SDK will use value 100 as default zoom factor, which means 100%.
If new zoom factor is set, the new zoom factor will take effect until current reflow page has been re-parsed and rendered again.

Parameters

  [in] | zoom | Zoom factor. The value represents the percent value, for example, 100 means 100%. This value should between 25 and 1000. If no zoom factor is set, value 100 will be used by default.

Returns
  None.

## ◆ startParse:()

- (FSProgressive *) startParse: |  | (id<FSPauseCallback>) | pause |

Start to parse current reflow page.

It may take a long time to parsing a reflow page, so Foxit PDF SDK uses a progressive process to do this. All the resources about reflow page will be loaded after the reflow page is parsed.
This function should be called before any getting function of current reflow page object can be used. Currently this function can not be supported if there are widget annotations in current page.

Parameters

  [in] | pause | Pause callback object which decides if the parsing process needs to be paused. This can be nil which means not to pause during the parsing process. If this is not nil, it should be a valid pause object implemented by user. Default value: nil.

Returns
  A progressive object. Please check the rate of current progress by function FSProgressive::getRateOfProgress. If the rate is not 100 yet, call function FSProgressive::resume to continue the progress until the progress is finished.