- Posts: 1123
- Thank you received: 73
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
how to refresh pdf page after add text
10 years 7 months ago #10146
by radaee
Replied by radaee on topic how to refresh pdf page after add text
if u coding activity base on PDFView class directly(not use PDFReader class).
a sample ReaderActivity using ReaderController class, is the simplest sample.
a sample ReaderActivity using ReaderController class, is the simplest sample.
10 years 7 months ago #10147
by radaee
Replied by radaee on topic how to refresh pdf page after add text
sorry, somethink forgot.
end of PDFReader.PDFOpen(), there is 1 line code:
m_view.vOpen(m_doc, 4, back_color, this);
it means PDFReader object shall be listener for PDFView.
and PDFReader class there is a method:
when u call PDFView.vRenderAsync, it call listener.OnPDFInvalidate().
this implements from PDFReader class.
end of PDFReader.PDFOpen(), there is 1 line code:
m_view.vOpen(m_doc, 4, back_color, this);
it means PDFReader object shall be listener for PDFView.
and PDFReader class there is a method:
Code:
public void OnPDFInvalidate(boolean post)
{
postInvalidate();
}
this implements from PDFReader class.
- ankur123987
-
Topic Author
- Offline
- Premium Member
-
- Available as freelancer (ex website to app 30min)
Less
More
- Posts: 97
- Thank you received: 0
10 years 7 months ago #10148
by ankur123987
Replied by ankur123987 on topic how to refresh pdf page after add text
i tried this code as in PDFReader class but i am unable to get the PDFReaderListener interface in code as well above method works under ontouch event how can i implement the ontouch event at pdf . ?
PDFPos pos = m_view.vGetPos((int)event.getX(), (int)event.getY());
PDFVPage vpage = m_view.vGetPage(pos.pageno);
Page page = vpage.GetPage();
if( page != null )
{
float pt[] = new float[2];
pt[0] = pos.x;
pt[1] = pos.y;
page.AddAnnotText(pt);//add a text note annotation.
m_view.vRenderSync(vpage);//reflush to backing bitmap.
if( m_listener != null )
m_listener.OnPageModified(vpage.GetPageNo());//display to screen, this is important.
}
now please change the my code . i just want to changes reflect at same time as ink ,rect does .i am just adding text . could you implement the addtext functionality in your demo . i checked your demo RDPDFReader as well PDfreader but i did not not see any adding text or edittext programatically .
please check my code and please modify the code as according to you my code is following..
PageContent content = new PageContent();
content.Create();//create content, do not forget.
content.GSSave();
Matrix mat = new Matrix( 1, 1, 100, 500 );
content.GSSetMatrix(mat);
mat.Destroy();
Page page = doc.GetPage(currentpage_num);
Document.DocFont dfont = doc.NewFontCID("DroidSansFallback", 1 |
;//bold and embed in horizontal writing
ResFont rfont = page.AddResFont(dfont);
content.TextBegin();
content.TextSetFont(rfont, 20);//set font and size
content.SetFillColor(0xff9801);
content.SetStrokeColor(0x10);
content.TextSetCharSpace(0);
content.TextSetWordSpace(0.3f);
content.TextSetLeading(20);
content.TextSetRenderMode(2);//fill and stroke
content.TextSetHScale(120);//set horizontal scale
content.DrawText(getDate());
content.TextEnd();
content.GSRestore();
PDFView pdf= new PDFView(getApplicationContext());
PDFViewVert view = new PDFViewVert(getApplicationContext());
view.vSetPageAlign(1);
pdf=view;
pdf.vOpen(doc, currentpage_num, 0xFFCCCC, pdfviewlistner);
PDFVPage vpage = pdf.vGetPage(currentpage_num);
pdf.vRenderAsync(vpage);
please help
PDFPos pos = m_view.vGetPos((int)event.getX(), (int)event.getY());
PDFVPage vpage = m_view.vGetPage(pos.pageno);
Page page = vpage.GetPage();
if( page != null )
{
float pt[] = new float[2];
pt[0] = pos.x;
pt[1] = pos.y;
page.AddAnnotText(pt);//add a text note annotation.
m_view.vRenderSync(vpage);//reflush to backing bitmap.
if( m_listener != null )
m_listener.OnPageModified(vpage.GetPageNo());//display to screen, this is important.
}
now please change the my code . i just want to changes reflect at same time as ink ,rect does .i am just adding text . could you implement the addtext functionality in your demo . i checked your demo RDPDFReader as well PDfreader but i did not not see any adding text or edittext programatically .
please check my code and please modify the code as according to you my code is following..
PageContent content = new PageContent();
content.Create();//create content, do not forget.
content.GSSave();
Matrix mat = new Matrix( 1, 1, 100, 500 );
content.GSSetMatrix(mat);
mat.Destroy();
Page page = doc.GetPage(currentpage_num);
Document.DocFont dfont = doc.NewFontCID("DroidSansFallback", 1 |
ResFont rfont = page.AddResFont(dfont);
content.TextBegin();
content.TextSetFont(rfont, 20);//set font and size
content.SetFillColor(0xff9801);
content.SetStrokeColor(0x10);
content.TextSetCharSpace(0);
content.TextSetWordSpace(0.3f);
content.TextSetLeading(20);
content.TextSetRenderMode(2);//fill and stroke
content.TextSetHScale(120);//set horizontal scale
content.DrawText(getDate());
content.TextEnd();
content.GSRestore();
PDFView pdf= new PDFView(getApplicationContext());
PDFViewVert view = new PDFViewVert(getApplicationContext());
view.vSetPageAlign(1);
pdf=view;
pdf.vOpen(doc, currentpage_num, 0xFFCCCC, pdfviewlistner);
PDFVPage vpage = pdf.vGetPage(currentpage_num);
pdf.vRenderAsync(vpage);
please help
Time to create page: 0.351 seconds