Some test text!

Search
Hamburger Icon

Xamarin / Android

View mode (Android)

There are a few view modes which can be adjusted to provide an optimal presentation such as layout, fit, or reflow. Additionally, you can present a view mode dialog allowing a user to change these settings.

Reflow document content in Android

This tutorial only applies to Xamarin.Android. See Xamarin.iOS equivalent here .
For Android, available in the full version of the library only. See Apryse full or standard?

Reflow makes the document more flexible and easier to read, especially on small devices. Apryse is able to extract the reflowable layout of each page in a PDF document to an HTML file. First, we explain how simple it is to show a widget that allows the user to swipe left or right through the pages of the document to see reflowable document pages. Then, we provide the methods necessary for converting a hard-layout PDF page to an HTML document page.

Show reflow pager

ReflowControl is a ViewPager that allows the user to flip left and right through the reflowable layout of pages in a PDF document.

Reflow

Implementation

To set up your layout with ReflowControl, add a <ReflowControl> element to your XML layout. For example, if each page in the swipe view should consume the entire layout, then your layout looks like this:

<pdftron.PDF.Controls.ReflowControl
    android:id="@+id/reflow"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Then, you need to attach a PDFDoc to the reflow pager:

var reflowControl = FindViewById<ReflowControl>(Resource.Id.reflow);
reflowControl.Setup(pdfDoc);

Scrolling direction

// horizontal (default)
reflowControl.Orientation = ReflowControl.Horizontal;
// vertical
reflowControl.Orientation = ReflowControl.Vertical;
That is everything you need to have a simple reflow pager.

Notify the reflow pager that the document has been modified

To refresh the reflow pager to show the latest changes on your document, you should let the reflow pager know that the document has been modified:

void NotifyReflowModified(ReflowControl reflowControl)
{
    if (reflowControl != null && reflowControl.IsReady) {
        reflowControl.NotifyPagesModified();
    }
}

Set the text size

It is possible to change the size of reflowable text. The default text size is 100; valid values are 5, 10, 25, 50, 75, 100, 125, 150, 200, 400, 800, and 1600. See the following code as an example:

void ChangeReflowSize(ReflowControl reflowControl, int percent)
{
    if (reflowControl != null && reflowControl.IsReady)
    {
        reflowControl.TextSizeInPercent = percent;
    }
}

Alternatively, you can zoom in/out to change the reflowable text size:

void ZoomReflow(ReflowControl reflowControl, bool zoomIn)
{
    if (reflowControl != null && reflowControl.IsReady) {
        if (zoomIn) {
            reflowControl.ZoomIn();
        } else {
            reflowControl.ZoomOut();
        }
    }
}

Assuming the current text size is 100%, by calling zoomReflow(reflowControl, true) and zoomReflow(reflowControl, false) the new text size will be 125% and 75% of the original size, respectively.

Set background color

There are three methods to change the background color:

setDayMode(): no background

setNightMode(): night background

setCustomColorMode(int): customized background

Set right-to-left direction

You can support right-to-left (RTL) languages by setting the direction of reflowable text by calling RightToLeftDirection

Get the answers you need: Chat with us