Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about iOS development and PDF

Exception while calling Page_setAnnotEditText

More
10 years 8 months ago #10049 by mobileAsd
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.
More
10 years 8 months ago #10057 by emanuele
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?
More
10 years 7 months ago #10131 by mobileAsd
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.
More
10 years 7 months ago #10132 by emanuele
I also suggest to use the last sdk version
More
10 years 7 months ago #10164 by mobileAsd
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?
More
10 years 7 months ago #10166 by emanuele
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.
Time to create page: 0.452 seconds
Powered by Kunena Forum