Knowledge Base and examples

Knowledge Base - Caching highlights outside of PDF file (Android)

This article shows how to cache highlight outside the pdf, without changing the pdf structure.

You need a DB to save the highlighted page and coordinates, then you have to re-create the highlight when you re-open the pdf.

To calculate the first (m_index1) and last (m_index2) character index of the highlighted text : 

float pt[] = new float[2];
pt[0] = m_annot_pos.x;
pt[1] = m_annot_pos.y;
m_index1 = m_page.ObjsGetCharIndex(pt);
pt[0] = m_annot_page.ToPDFX(event.getX(), m_layout.vGetX());
pt[1] = m_annot_page.ToPDFY(event.getY(), m_layout.vGetY());
m_index2 = m_page.ObjsGetCharIndex(pt);

You should look at PDFLayoutView.onTouchSelect to better understand how it works.


To re-create the highlight you should use:

m_page.AddAnnotMarkup(m_index1, m_index2, type);
Applies To

RadaeePDF SDK for Android


Created : 2016-06-29 10:55:21, Last Modified : 2016-07-01 11:22:16