- Posts: 97
- 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
how to move the added text at pdf
- ankur123987
-
Topic Author
- Offline
- Premium Member
-
- Available as freelancer (ex website to app 30min)
Less
More
10 years 1 month ago #10236
by ankur123987
how to move the added text at pdf was created by ankur123987
HI Radaeepdf team,
I am able to add the text at pdf file but is there any mechanism to move my added text at any place of pdf ?
Please help
I am able to add the text at pdf file but is there any mechanism to move my added text at any place of pdf ?
Please help
- max.pfeiffer
- Offline
- New Member
-
Less
More
- Posts: 14
- Thank you received: 1
10 years 1 month ago #10240
by max.pfeiffer
Replied by max.pfeiffer on topic how to move the added text at pdf
+1, same problem here.
- ankur123987
-
Topic Author
- Offline
- Premium Member
-
- Available as freelancer (ex website to app 30min)
Less
More
- Posts: 97
- Thank you received: 0
10 years 1 month ago #10241
by ankur123987
Replied by ankur123987 on topic how to move the added text at pdf
Hi Radaeepdf team,
is that feasible? i could not find any supported method regarding this .
Please help
is that feasible? i could not find any supported method regarding this .
Please help
10 years 1 month ago #10242
by Davide
Replied by Davide on topic how to move the added text at pdf
Hi,
to enable edit text moving you have to edit OnPDFSingleTapped method of PDFReader class as following:
to enable edit text moving you have to edit OnPDFSingleTapped method of PDFReader class as following:
Code:
public boolean OnPDFSingleTapped(float x, float y)
{
if( m_status == STA_NORMAL || m_status == STA_ANNOT )
{
m_annot_pos = m_view.vGetPos((int)x, (int)y);
m_annot_page = m_view.vGetPage(m_annot_pos.pageno);
final Page page = m_annot_page.GetPage();
if( page == null ) m_annot = null;
else m_annot = page.GetAnnotFromPoint(m_annot_pos.x, m_annot_pos.y);
if( m_annot == null )
{
m_annot_page = null;
m_annot_pos = null;
m_annot_rect = null;
m_view.vSetLock(0);
if( m_listener != null && m_status == STA_ANNOT )
m_listener.OnAnnotClicked(m_annot_page, null);
m_status = STA_NORMAL;
}
else
{
m_annot_rect = m_annot.GetRect();
int px = m_annot_page.GetVX(m_view.vGetX());
int py = m_annot_page.GetVY(m_view.vGetY());
float tmp = m_annot_rect[1];
m_annot_rect[0] = m_annot_page.ToDIBX(m_annot_rect[0]) + px;
m_annot_rect[1] = m_annot_page.ToDIBY(m_annot_rect[3]) + py;
m_annot_rect[2] = m_annot_page.ToDIBX(m_annot_rect[2]) + px;
m_annot_rect[3] = m_annot_page.ToDIBY(tmp) + py;
m_view.vSetLock(3);
m_status = STA_ANNOT;
if( m_doc.CanSave() && m_annot.GetEditType() > 3 ) //don't open edit text requetser
{
int[] location = new int[2];
getLocationOnScreen(location);
m_pEdit = new PopupWindow(LayoutInflater.from(getContext()).inflate(R.layout.pop_edit, null) );
m_pEdit.setFocusable(true);
m_pEdit.setTouchable(true);
BitmapDrawable bitmap = new BitmapDrawable();//add back
m_pEdit.setBackgroundDrawable(bitmap);
m_pEdit.setWidth((int)(m_annot_rect[2] - m_annot_rect[0]));
m_pEdit.setHeight((int)(m_annot_rect[3] - m_annot_rect[1]));
final EditText edit = (EditText)m_pEdit.getContentView().findViewById(R.id.annot_text);
edit.setBackgroundColor(0xFFFFFFC0);
m_pEdit.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
if (m_edit_type == 1)//edit box
{
m_annot.SetEditText(edit.getText().toString());
m_view.vRenderSync(m_annot_page);
if (m_listener != null)
m_listener.OnPageModified(m_annot_page.GetPageNo());
PDFEndAnnot();
}
m_edit_type = 0;
}
});
float fsize = m_annot.GetEditTextSize() * m_annot_page.GetScale();
edit.setTextSize(TypedValue.COMPLEX_UNIT_PX, fsize);
edit.setPadding(2, 2, 2, 2);
switch( m_annot.GetEditType() )
{
case 1:
edit.setSingleLine();
edit.setInputType(InputType.TYPE_CLASS_TEXT + InputType.TYPE_TEXT_VARIATION_NORMAL);
break;
case 2:
edit.setSingleLine();
edit.setInputType(InputType.TYPE_CLASS_TEXT + InputType.TYPE_TEXT_VARIATION_PASSWORD);
break;
case 3:
edit.setSingleLine(false);
edit.setInputType(InputType.TYPE_CLASS_TEXT + InputType.TYPE_TEXT_VARIATION_NORMAL);
break;
}
int maxlen = m_annot.GetEditMaxlen();
if( maxlen > 0 )
edit.setFilters(new InputFilter[]{new InputFilter.LengthFilter(maxlen)});
else
edit.setFilters(new InputFilter[]{new InputFilter.LengthFilter(1020)});
edit.setText(m_annot.GetEditText());
m_edit_type = 1;
m_pEdit.showAtLocation(this, Gravity.NO_GRAVITY, (int)m_annot_rect[0] + location[0], (int)m_annot_rect[1] + location[1]);
}
if( m_doc.CanSave() && m_annot.GetComboItemCount() >= 3 ) //move edit text
{
int[] location = new int[2];
getLocationOnScreen(location);
String opts[] = new String[m_annot.GetComboItemCount()];
int cur = 0;
while( cur < opts.length )
{
opts[cur] = m_annot.GetComboItem(cur);
cur++;
}
m_pCombo = new PopupWindow(LayoutInflater.from(getContext()).inflate(R.layout.pop_combo, null));
m_pCombo.setFocusable(true);
m_pCombo.setTouchable(true);
BitmapDrawable bitmap = new BitmapDrawable();//add back
m_pCombo.setBackgroundDrawable(bitmap);
m_pCombo.setWidth((int)(m_annot_rect[2] - m_annot_rect[0]));
if( (m_annot_rect[3] - m_annot_rect[1] - 4) * opts.length > 250 )
m_pCombo.setHeight(250);
else
m_pCombo.setHeight((int)(m_annot_rect[3] - m_annot_rect[1] - 4) * opts.length);
ComboList combo = (ComboList)m_pCombo.getContentView().findViewById(R.id.annot_combo);
combo.set_opts(opts);
combo.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
m_sel_index = i;
m_pCombo.dismiss();
}
});
m_pCombo.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
if (m_edit_type == 2)//combo
{
if (m_sel_index >= 0) {
m_annot.SetComboItem(m_sel_index);
m_view.vRenderSync(m_annot_page);
if (m_listener != null)
m_listener.OnPageModified(m_annot_page.GetPageNo());
}
m_sel_index = -1;
PDFEndAnnot();
}
m_edit_type = 0;
}
});
m_edit_type = 2;
m_sel_index = -1;
m_pCombo.showAtLocation(this, Gravity.NO_GRAVITY, (int)m_annot_rect[0] + location[0], (int)(m_annot_rect[3] + location[1]));
}
if( m_listener != null )
m_listener.OnAnnotClicked(m_annot_page, m_annot);
invalidate();
}
return true;
}
return false;
}
- ankur123987
-
Topic Author
- Offline
- Premium Member
-
- Available as freelancer (ex website to app 30min)
Less
More
- Posts: 97
- Thank you received: 0
10 years 1 month ago #10248
by ankur123987
Replied by ankur123987 on topic how to move the added text at pdf
Hi Davide,
Could you make this method is compatible with PDFLayoutView, if i use the PDFreader class then my other layouts does not work . I tried to add the text by using PDFReader as its lack of many methods for example (m_view.vGetPage ,m_view.vGetX(), m_view.vGetY() .. etc )
No redo and undo methods in PDFreader so cant use this class . I wanted maximum functionality that is available in only PDFLayoutView class . or in PDFLayoutListener class .
Please provide the methods for these class . I tried to above method with public boolean onSingleTapUp(MotionEvent e) function of PDFLayoutListener but nothing work
please help
Could you make this method is compatible with PDFLayoutView, if i use the PDFreader class then my other layouts does not work . I tried to add the text by using PDFReader as its lack of many methods for example (m_view.vGetPage ,m_view.vGetX(), m_view.vGetY() .. etc )
No redo and undo methods in PDFreader so cant use this class . I wanted maximum functionality that is available in only PDFLayoutView class . or in PDFLayoutListener class .
Please provide the methods for these class . I tried to above method with public boolean onSingleTapUp(MotionEvent e) function of PDFLayoutListener but nothing work
please help
- max.pfeiffer
- Offline
- New Member
-
Less
More
- Posts: 14
- Thank you received: 1
10 years 3 weeks ago - 10 years 3 weeks ago #10273
by max.pfeiffer
Replied by max.pfeiffer on topic how to move the added text at pdf
Hi Ankuri,
I just managed to do that using the PDFLayoutView class. You need to change the method "public boolean onSingleTapUp(MotionEvent e)" of the PDFGestureListener to make that work.
When single tapping a text annotion this method is displaying an edit text by standard. I changed that so it has the same behaviour when tapping on a stamp: you can move the text annotation around like the stamp.
In the attachment you find my class with the changes. I also modified other functions in that class to suit my needs. So be careful when using it.
Greetings,
Max
I just managed to do that using the PDFLayoutView class. You need to change the method "public boolean onSingleTapUp(MotionEvent e)" of the PDFGestureListener to make that work.
When single tapping a text annotion this method is displaying an edit text by standard. I changed that so it has the same behaviour when tapping on a stamp: you can move the text annotation around like the stamp.
In the attachment you find my class with the changes. I also modified other functions in that class to suit my needs. So be careful when using it.
Greetings,
Max
Last edit: 10 years 3 weeks ago by max.pfeiffer.
Time to create page: 0.420 seconds