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 8 years 2 months ago #10096

  • 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
Hi Redaeepdf team,

I am trying to add text in pdf but I can't see the text at the same time. Until not scroll so how can I view the text while i add text.

Thanks,

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

how to refresh pdf page after add text 8 years 2 months ago #10098

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
I suggest you to use :
vRenderSync( PDFVPage page )
or
vRenderAsync( PDFVPage page )


For more info check this:

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

how to refresh pdf page after add text 8 years 2 months ago #10101

  • 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
thanks davide for your reply i tried above method but its not working the changes are not reflecting at screen

please view my source code and let me know what should i do?

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();

//add content to page
page.AddContent(content, true);
content.Destroy();
PDFView pdf= new PDFView(getApplicationContext());


PDFVPage pdfd= new PDFVPage(doc,currentpage_num);
pdf.vRenderAsync(pdfd);

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

how to refresh pdf page after add text 8 years 2 months ago #10120

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
u shall do like:
PDFView pdf= new PDFView(getApplicationContext());
pdf.open(doc, ...);//set document object to view.

//then add contents:
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();
//too many lines, other adding codes;
.......

PDFVPage vpage = pdf.vGetPage(currentpage_num);
pdf.vRenderAsync(vpage);

invalidate();//refresh to screen.

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

Last edit: by radaee.

how to refresh pdf page after add text 8 years 2 months ago #10141

  • 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
Hi radaee, i tried your suggested code but i could nod find any open method in PDFView class. pdf.open(doc,...) does not works . however its content public void vOpen(Document doc, int page_gap, int back_color, PDFViewListener listener) i tried with this method too but no luck

one more thing invalidate() method is undefined in activity .please suggest any working code thanks

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

how to refresh pdf page after add text 8 years 2 months ago #10145

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
sorry, may some misunderstood.
PDFView is not View class, but PDFReader extends from android.View.
ot better explan this, show sample codes in PDFReader class:
	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.
	}

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

Last edit: by radaee.
  • Page:
  • 1
  • 2
Powered by Kunena Forum