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

Text Annotations are not parsed

More
9 years 7 months ago #11801 by valkuz1
Hi,

Apart from editing the PDF document via viewer (which I do successfully!), I need to do the following:

Just open the pdf file and prefill some text into text fields. (Without viewer)
However, when I open the PDF like this:

[doc open:_pdfPath :@""];
int pages = [doc pageCount];
for(int index = 0; index < pages; index++){
PDFPage *page = [doc page:index];
[page objsStart];
int annots = [page annotCount];
for(int annot = 0; annot < annots; annot++){
PDFAnnot *annotation = [page annotAtIndex:annot]; //iterate over annots
// I will get only these, fieldType of which is 1 or 4, but not 2!
}
}

I get only annotations of type 1 and 4, but none of type 2.

But, when I open the pdf via pdf viewer, I am able to edit text fields (and also use annotAtIndex methods and etc to correctly get my text annotations)

So,
1)Why the text annotations are not parsed?
2)What should be done?

Thanks.
More
9 years 7 months ago #11804 by emanuele
Hi,

can you share the document used to test the reader?
We will check it to better understand the issue
More
9 years 7 months ago #11805 by valkuz1
Any document, various pdf versions - from 1.3 to 1.7, but for instance this, which is in the attachment.
More
9 years 7 months ago - 9 years 7 months ago #11806 by valkuz1
When I open it via viewer, I can edit and save fields as I normal, but when I just want to do it programatically (open doc and iterate over the annots in order to fill the document), I get only these of type 1 and 4 (checkmarks and sigs), but not type 2( text fields)
Last edit: 9 years 7 months ago by valkuz1.
More
9 years 7 months ago #11808 by emanuele
Hi,
I tried to iterate over the annotations of your pdf with this code (almost equal to your):
Code:
PDFDoc *doc = [[PDFDoc alloc] init]; [doc open:filePath :@""]; int pages = [doc pageCount]; for(int index = 0; index < pages; index++){ PDFPage *page = [doc page:index]; [page objsStart]; int annots = [page annotCount]; for(int annot = 0; annot < annots; annot++){ PDFAnnot *annotation = [page annotAtIndex:annot]; //iterate over annots NSLog(@"Annot index: %i", [annotation getIndex]); NSLog(@"Annot edit type: %i", [annotation getEditType]); NSLog(@"Annot field type: %i", [annotation fieldType]); NSLog(@"Annot type: %i", [annotation type]); NSLog(@"Annot value: %@", [annotation getEditText]); } }

The annotation count is 62 and the log shows the edit fields correctly.
The annotation at index 0 is an edit text annot (type:20, field type:2); what is the result if you try to call [page annotAtIndex:0]?
More
9 years 7 months ago #11809 by valkuz1
sec
Time to create page: 0.428 seconds
Powered by Kunena Forum