Knowledge Base - RadaeePDF PDF, Xamarin plugin configurations

You can customize the Xamarin RadaeePDF viewer using the following methods:

  • Create an instance of RadaeePDFManager (Android) or RadaeePDFPlugin (iOS):
     RadaeePDFManager mPdfManager = new RadaeePDFManager(); (Android)
     RadaeePDFPlugin plugin = RadaeePDFPlugin.PluginInit; (iOS)
  • You can activate your license using:
     bool activated = mPdfManager.ActivateLicense(this, 2, "radaee", "This email address is being protected from spambots. You need JavaScript enabled to view it.", "LNJFDN-C89QFX-9ZOU9E-OQ31K2-FADG6Z-XEBCAO"); (Android)
     bool activated = plugin.ActivateLicenseWithBundleId("com.radaee.pdf.PDFViewer", "Radaee", "This email address is being protected from spambots. You need JavaScript enabled to view it.", "89WG9I-HCL62K-H3CRUZ-WAJQ9H-FADG6Z-XEBCAO", 2); (iOS)
    /**
    * Activates the SDK license.
    * Should be called before show, open methods
    *
    * @param context Context object must be derived from CoontextWrapper
    * @param licenseType 0: standard license, 1: professional license, 2: premium license.
    * @param companyName company name (not package name)
    * @param mail mail
    * @param key the license activation key
    * @return true if the license was activated correctly, false otherwise
    */
  • You can show a pdf (local or remote) using:
     mPdfManager.Show(this, "file:///mnt/sdcard/Download/Test.pdf", ""); (Android)
     plugin.Show(this, "file://Test.pdf", ""); (iOS)
     or
     mPdfManager.Show(this, "http://www.radaeepdf.com/documentation/MRBrochoure.pdf", ""); (Android)
     plugin.Show("http://www.radaeepdf.com/documentation/MRBrochoure.pdf", ""); (iOS)
    /**
    * Opens the passed file and shows the PDF reader.
    *
    * @param context the current context.
    * @param url the url can be remote (starts with http/https), or local
    * @param password the pdf's password, if no password, pass empty string
    * @param readOnlyMode if true, the document will be opened in read-only mode
    * @param automaticSave if true, the modifications will be saved automatically, else a requester to save will be shown
    * @param gotoPage if greater than 0, the reader will render directly the passed page (0-index: from 0 to Document.GetPageCount - 1)
    * @param bmpFormat bmp format, can be RGB_565 or ARGB_4444, default is ALPHA_8
    * @param author if not empty, it will be used to set annotations' author during creation.
    * @param layoutType determine the type of the layout to be used for rendering, (GPU or CPU) based layout, GPU_BASED_LAYOUT:0 (OpenGL), CPU_BASED_LAYOUT:1
    */
    You can open a pdf from Assets using:
  • mPdfManager.OpenFromAssets(this, "test.PDF", ""); (Android)
    plugin.OpenFromAssets("test.PDF", ""); (iOS)
    /**
    * Opens the passed assets file and shows the PDF reader.
    *
    * @param context the current context.
    * @param path the asset name/path
    * @param password the pdf's password, if no apssword, pass empty string
    */
  • In Android, if you want to receive some events from the viewer, you need to implement RadaeePluginCallback.IPDFReaderListener, and pass the activity to RadaeePDFManager as following:
     public class MainActivity : Activity, RadaeePluginCallback.IPDFReaderListener
     ...
     public class MainActivity : Activity, RadaeePluginCallback.IPDFReaderListener
     {
            private RadaeePDFManager mPdfManager;
    private static String TAG = "DEMO";
    protected override void OnCreate(Bundle bundle)
                  {
                       base.OnCreate(bundle);
                       SetContentView(Resource.Layout.Main);

                       mPdfManager = new RadaeePDFManager(this);
                       ...
                   }

    public void DidChangePage(int p0) {
       Log.Debug(TAG, "Page changed to " + p0);
      }

      public void DidCloseReader() {
       Log.Debug(TAG, "Did close reader");
      }

      public void DidSearchTerm(string p0, bool p1) {
       Log.Debug(TAG, "Did search term " + p0 + " and the result = " + p1);
      }

      public void DidShowReader() {
       Log.Debug(TAG, "Did show reader");
      }

      public void WillCloseReader() {
       Log.Debug(TAG, "Will close reader");
      }

      public void WillShowReader() {
       Log.Debug(TAG, "Will show reader");
      }
  • In iOS, if you want to receive some events from the viewer, you need to implement RadaeeDelegate:
    public class RadaeeDelegate : RadaeePDFPluginDelegate
    {
    RadaeePDFPlugin plugin;

    public RadaeeDelegate(RadaeePDFPlugin plugin)
    {
    this.plugin = plugin;
    }

    public override void WillShowReader()
    {
    Console.WriteLine("will show reader");
    }

    public override void DidShowReader()
    {

    Console.WriteLine("did show reader");
    }

    public override void WillCloseReader()
    {
    Console.WriteLine("will close reader");
    }

    public override void DidCloseReader()
    {
    Console.WriteLine("did close reader");
    }

    public override void DidChangePage(int page)
    {
    Console.WriteLine("did change page {0}", page);
    }


    public override void DidSearchTerm(string term, bool found)
    {
    Console.WriteLine("did search {0}", term);
    }

    public override void DidTapOnPage(int page, CGPoint point)
    {
    Console.WriteLine("did tap page {0}", page);
    }

    public override void DidDoubleTapOnPage(int page, CGPoint point)
    {
    Console.WriteLine("did double tap page {0}", page);
    }

    public override void DidLongPressOnPage(int page, CGPoint point)
    {
    Console.WriteLine("did long press page {0}", page);
    }

    public override void DidTapOnAnnotationOfType(int type, int page, CGPoint point)
    {
    Console.WriteLine("did tap annot of type {0} at page {1}", type, page);
    }

    public override void OnAnnotExported(string path)
    {
    Console.WriteLine("did export annot at path {0}", path);
    }
    }
    And then set a selector for your RadaeePDFPlugin object:

    //Set Callback for RadaeeDelegate
    RadaeeDelegate selector = new RadaeeDelegate(plugin);
    plugin.SetDelegate(selector);

You can use the following methods of RadaeePDFManager (Android) or RadaeePDFPlugin (iOS) to customize the layout and/or use exposed features :

/**
* Changes the Reader's view mode
* Should be called before show, open methods
*
* @param viewMode 0:vertical 3:single 4:dual 6:Dual with cover(1st page single)
*/
SetReaderViewMode(int viewMode)
/**
* Changes the reader's view background color.
* Should be called before show, open methods
*
* @param color format as 0xAARRGGBB
*/
SetReaderBGColor(int color)
/**
* Changes the thumbnail's view background color.
* Should be called before show, open methods
*
* @param color format as 0xAARRGGBB
*/
SetThumbnailBGColor(int color)
/**
* Changes the height of the thumbnail view.
* Should be called before show, open methods
*
* @param height height in dp, i.e. 100 = 100dp
*/
SetThumbHeight(int height)
/**
* Sets if the first page should be rendered as cover or dual
* Should be called before show, open methods
*
* @param firstPageCover if true the first page will be single, if false it will be dual (same as view_mode = 4)
*/
SetFirstPageCover(bool firstPageCover)
/**
* Gets the current page index, in case of dual it will return the page on the left
*
* @return the current page index (0-based), -1 otherwise
*/
int PageNumber
/**
* Changes the color of the reader toolbar's icons.
*
* @param color format as 0xAARRGGBB
*/
SetIconsBGColor(int color)
/**
* Changes the color of the reader's toolbar.
*
* @param color format as 0xAARRGGBB
*/
SetTitleBGColor(int color)
/**
* show/hide toolbar and thumbnails slider
*
* @param immersive if true the toolbar and thumbnail will be hidden (if visible),
* if false and hidden they will be shown
*/
SetImmersive(bool immersive)
/**
* Returns a json object that contains all the document form fields dictionary
*
* @return json object of all the document form fields dictionary (if-any), or ERROR otherwise
*/
String JsonFormFields()
/**
* Returns a json object that contains a specific page's form fields dictionary
*
* @param pageno the page number, 0-index (from 0 to Document.GetPageCount - 1)
* @return json object of the page's form fields dictionary (if-any), or ERROR otherwise
*/
String GetJsonFormFieldsAtPage(int pageno)
/**
* Using the passed json, you can set the value of form fields like: Text fields, checkbox,
* combo, radio buttons.
*
* @param json object of the document form fields dictionary
*/
String SetFormFieldsWithJSON(String json)
/**
* Returns document's pages count
*
* @return document's pages count, -1 in case of error
*/
int PageCount
/**
* extract the text content of the given page
*
* @param page the page number, 0-index (from 0 to Document.GetPageCount - 1)
* @return the given page's text
*/
String ExtractTextFromPage(int page)
/**
* encrypt document and save into another file.<br/>
* this method require premium license.
* @param dst path to save, same as path parameter of SaveAs.
* @param upswd user password, can be null (is the public password (shared with authorized users). It's sufficient to open the file with applied permission mask set).
* @param opswd owner password, can be null (is the password that allow opening the file without any restriction from the permission mask).
* @param perm permission to set, same as GetPermission() method.<br/>
* bit 1-2 reserved<br/>
* bit 3(0x4) print<br/>
* bit 4(0x8) modify<br/>
* bit 5(0x10) extract text or image<br/>
* others: see PDF reference
* @param method set 3 means using AES 256bits encrypt(Acrobat X), V=5 and R = 6 mode, others AES with V=4 and R=4 mode.
* @param id must be 32 bytes for file ID. it is divided to 2 array in native library, as each 16 bytes (something like the encryption seed or salt in some
* other encryption scheme. That id is a reserved code that make password stronger).
* @return Success of error.
*/
String EncryptDocAs(String dst, String upswd, String opswd, int perm, int method, String id) 
/**
* Adds the given page to the bookmarks.
*
* @param mContext context object
* @param filePath the orignal pdf file
* @param page 0 based page no.
* @param bookmarkLabel label of Bookmark (can be empty string)
* @return a string that indicates the result
*/
String addToBookmarks(Context mContext, String filePath, int page, String bookmarkLabel)
/**
* Removes the given page from bookmarks.
*
* @param page 0 based page no.
* @param filePath the orignal pdf file
* @return true or false.
*/
boolean removeBookmark(int page, String filePath)
/**
* returns a list of bookmarked pages in json format
* @param filePath the orignal pdf file
* @return json string or null ex: [{"Page": 4,"Label": "Page: 5"}, {"Page": 1,"Label": "Page: 2"}]
*/
String getBookmarksAsJson(String filePath)
Applies To

RadaeePDF SDK for Xamarin

Related Articles

How to create your own APP with Xamarin (Android) and RadaeePDF PDF reader

Details

Created : 2017-02-23 10:59:14, Last Modified : 2022-03-21 17:52:09

Order history

Login to handle your order history.