- Posts: 6
- Thank you received: 0
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Android development and PDF
Why can not remove selected text correctly?
IP: 192.168.0.71
11 years 10 months ago #6510
by discoby
Why can not remove selected text correctly? was created by discoby
We implement a function that some new texts will be selected and old ones will be released when user tapped. The question is not all old ones will be released correctly.
After doing PDFView.vRenderSync(...) some old selected texts are still selected (marked on screen).
Here is the code sample:
PDFView m_view;
Document m_doc;
void functionXXX(){
...
// release old selected texts first if they exist...
Page anntPage = m_doc.GetPage(m_pageno);
int AnnotCount = anntPage.GetAnnotCount();
if (AnnotCount > 0){
for (int z = 0 ; z < AnnotCount ; z++){
Annotation a = anntPage.GetAnnot(z); //
if (a != null) a.RemoveFromPage(); // <<< Problem: some times we will get null????
}
}
anntPage.Close();
PDFVPage vpage = m_view.vGetPage(m_pageno);
Page page_cur = vpage.GetPage();
...
for (...){
...// check char index is what we want...
page_cur.AddAnnotMarkup(hit_srart, hit_end, 9); // mark the texts we selected...
}
...
m_view.vRenderSync(vpage); // re-render the page...
} // End of function
Did i miss something?
After doing PDFView.vRenderSync(...) some old selected texts are still selected (marked on screen).
Here is the code sample:
PDFView m_view;
Document m_doc;
void functionXXX(){
...
// release old selected texts first if they exist...
Page anntPage = m_doc.GetPage(m_pageno);
int AnnotCount = anntPage.GetAnnotCount();
if (AnnotCount > 0){
for (int z = 0 ; z < AnnotCount ; z++){
Annotation a = anntPage.GetAnnot(z); //
if (a != null) a.RemoveFromPage(); // <<< Problem: some times we will get null????
}
}
anntPage.Close();
PDFVPage vpage = m_view.vGetPage(m_pageno);
Page page_cur = vpage.GetPage();
...
for (...){
...// check char index is what we want...
page_cur.AddAnnotMarkup(hit_srart, hit_end, 9); // mark the texts we selected...
}
...
m_view.vRenderSync(vpage); // re-render the page...
} // End of function
Did i miss something?
IP: 192.168.0.71
11 years 10 months ago - 11 years 10 months ago #6511
by discoby
Replied by discoby on topic Why can not remove selected text correctly?
Example:
// These texts on the screen are marked...
QQQQQQ
AAAAAA
ZZZZZZ
WWWWWW
// We tapped some new texts...
QQQQQQ <- should be released but still marked on the screen
ZZZZZZ <- should be released but still marked on the screen
DDDDDD <- new text marked on the screen
// These texts on the screen are marked...
QQQQQQ
AAAAAA
ZZZZZZ
WWWWWW
// We tapped some new texts...
QQQQQQ <- should be released but still marked on the screen
ZZZZZZ <- should be released but still marked on the screen
DDDDDD <- new text marked on the screen
Last edit: 11 years 10 months ago by freeed.
IP: 192.168.0.71
11 years 10 months ago #6512
by nermeen
Replied by nermeen on topic Why can not remove selected text correctly?
You need to implement the loop differently, as doing it like this,
wont work correctly, as after removing an annotation the annotation count is different and the annotation indices will be different
Code:
for (int z = 0 ; z < AnnotCount ; z++){
Annotation a = anntPage.GetAnnot(z); //
if (a != null) a.RemoveFromPage(); // <<< Problem: some times we will get null????
}
wont work correctly, as after removing an annotation the annotation count is different and the annotation indices will be different
IP: 192.168.0.71
11 years 10 months ago #6513
by discoby
Replied by discoby on topic Why can not remove selected text correctly?
Thanks for your reply!!!!
Time to create page: 0.497 seconds