- Posts: 13
- 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 iOS development and PDF
Text Annotations are not parsed
9 years 7 months ago #11801
by valkuz1
Text Annotations are not parsed was created 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.
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.
9 years 7 months ago #11804
by emanuele
Replied by emanuele on topic Text Annotations are not parsed
Hi,
can you share the document used to test the reader?
We will check it to better understand the issue
can you share the document used to test the reader?
We will check it to better understand the issue
9 years 7 months ago #11805
by valkuz1
Replied by valkuz1 on topic Text Annotations are not parsed
Any document, various pdf versions - from 1.3 to 1.7, but for instance this, which is in the attachment.
9 years 7 months ago - 9 years 7 months ago #11806
by valkuz1
Replied by valkuz1 on topic Text Annotations are not parsed
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.
9 years 7 months ago #11808
by emanuele
Replied by emanuele on topic Text Annotations are not parsed
Hi,
I tried to iterate over the annotations of your pdf with this code (almost equal to your):
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]?
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]?
Time to create page: 0.428 seconds