Share Share
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1
  • 2

TOPIC:

how to refresh pdf page after add text 10 years 2 months ago #10146

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
if u coding activity base on PDFView class directly(not use PDFReader class).
a sample ReaderActivity using ReaderController class, is the simplest sample.

Please Log in or Create an account to join the conversation.

how to refresh pdf page after add text 10 years 2 months ago #10147

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
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:
	public void OnPDFInvalidate(boolean post)
	{
		postInvalidate();
	}
when u call PDFView.vRenderAsync, it call listener.OnPDFInvalidate().
this implements from PDFReader class.

Please Log in or Create an account to join the conversation.

how to refresh pdf page after add text 10 years 2 months ago #10148

  • ankur123987
  • ankur123987's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Available as freelancer (ex website to app 30min)
  • Posts: 97
  • Thank you received: 0
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 | 8);//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

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Powered by Kunena Forum