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

TOPIC:

Exception while calling Page_setAnnotEditText 8 years 3 months ago #10049

  • mobileAsd
  • mobileAsd's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
Hi, we are developing under the premium license, and try to add the text box to PDF documents. It seems very unstable to call the function Page_setAnnotEditText and often crashed when we input long text (in fact just around 100 characters). And from the thread www.radaeepdf.com/forum/ios-dev/1129-app...age-setannotedittext, it is said that there is a fix on this function, however we still meeting the crashing issue.
Our code basically using the logic of adding popup text from the sample app, i.e. open the TextAnnotViewController and then call the add text box function as below:

-(void)vAddTextBox:(int)x :(int)y :(NSString *)text
{
struct PDFV_POS pos;
[m_view vGetPos:&pos :x * m_scale :y * m_scale];
if(pos.pageno>=0)
{
PDFVPage *vpage = [m_view vGetPage:pos.pageno];
if( !vpage ) return;
PDFPage *page = [vpage GetPage];
if (!page) {
return;
}

float pWidth=[m_doc pageWidth:pos.pageno];
float pHeight=[m_doc pageHeight:pos.pageno];
float textScale=pWidth/PDF_NORMAL_SIZE_TEXT;
if (pHeight<pWidth) {
textScale=pHeight/PDF_NORMAL_SIZE_TEXT;
}
float actualTextSize = g_text_size*textScale;
UIFont *font = [UIFont fontWithName:@"STHeitiTC-Medium" size:actualTextSize];
NSString *displayText = [text stringByAppendingString:@" "];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:displayText];
[str addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, str.length)];
CGSize textBound = [str size];

PDF_RECT rect;

rect.left=pos.x;
rect.right=pos.x + textBound.width;
rect.top=pos.y;
rect.bottom=pos.y + textBound.height * 1.3;
m_modified = true;
PDFAnnot *annot = [page annotAtPoint:pos.x :pos.y];
if (!annot) {
DLog(@"New textbox is added!!!");
[page addEditTextBox:&rect :0xFF000000 :0 :0xFFFFFFFF :actualTextSize :g_text_color];
annot = [page annotAtIndex: [page annotCount] - 1];
} else {
if ([annot getEditType]==3 && [annot fieldType]==0) {
[annot getEditRect:&rect];
rect.right = rect.left + textBound.width;
rect.bottom = rect.top + textBound.height*1.3;
if ([m_delegate isTextColorChanged]) {
[annot setEditTextColor:g_text_color];
}
[annot setRect:&rect];
}
}
[annot setEditText:text];
[m_view vRenderSync:pos.pageno];
[m_doc save];
}
}


Don't know anything make it crash, please suggest, thanks.

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

Exception while calling Page_setAnnotEditText 8 years 3 months ago #10057

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
Hi,
the issue happens only in a specific case? for example only when you add a new editText or only when you update an existing editText? or in both cases?
Which library version are you using?
Can you reproduce the issue with the demo project?

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

Exception while calling Page_setAnnotEditText 8 years 2 months ago #10131

  • mobileAsd
  • mobileAsd's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
Hi, the issue happened in both new editText and update editText, and we are using 3.3.7, we haven't tested on the demo app yet. Will try it and reply the result, thanks.

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

Exception while calling Page_setAnnotEditText 8 years 2 months ago #10132

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
I also suggest to use the last sdk version

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

Exception while calling Page_setAnnotEditText 8 years 2 months ago #10164

  • mobileAsd
  • mobileAsd's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
Hi, we can simulate the problem in the sample application. You suggest we change to use the latest sdk, is it confirmed that the issue can be solved?

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

Exception while calling Page_setAnnotEditText 8 years 2 months ago #10166

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
Hi,

the last beta has also the fields editing feature, and it uses also the setEditText method.
The setEditText method of the stable version also works, but the project doesn't have the fields editing feature included.

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

  • Page:
  • 1
  • 2
Powered by Kunena Forum