Q:
Thanks for the detailed explanation!
I do have a few more questions:
- Do you support search within PDF?
- If so, do you highlight the results? Is there a customizable search results form?
- Do you support all encodings including Hebrew and Arabic?
- Do you support right to left PDF documents?
A:
Do you support search within PDF?
Yes. To get started, please see FindText() method in PDFViewCtrl (http://www.pdftron.com/pdfnet/mobile/iOSHTMLDoc/src/interface_p_d_f_view_ctrl.html, http://www.pdftron.com/pdfnet/mobile/Javadoc/pdftron/PDF/PDFViewCtrl.html).
There is also a more low-level class ‘pdftron.PDF.TextSearch’ that can be used to search PDF based on regular expressions. The search results include positioning information, ambient strings, etc. For an example of how to use TextSearch see http://www.pdftron.com/pdfnet/samplecode.html#TextSearch.
Another relevant class is ‘pdftron.PDF.TextExtractor’ (http://www.pdftron.com/pdfnet/samplecode.html#TextExtract) which can provide positioning info for each glyph, word, line, block etc.
If so, do you highlight the results? Is there a customizable search results form?
PDFViewCtrl.FindText() automatically highlights results. You can also use TextSearch to make a custom search form.
Do you support all encodings including Hebrew and Arabic?
Yes, we support all Unicode including Hebrew and Arabic.
Do you support right to left PDF documents?
Yes, you would need to call PDFViewCtrl.SetRightToLeftLanguage(true) to switch text selection to right to left mode.
On Wednesday, December 11, 2013 9:44:38 AM UTC-8, Aaron Gravesdale wrote:
Q:
We are currently developing an application that reads PDF and provides annotations on top of it.
We would like to know whether it would be possible to do the following using your kit:
- User can highlight text using his finger like he would in any regular text. See example below:
- Extract the highlighted text to external resource (i.e. save the extracted text in an external file).
- Get the position of the highlighted text.
- Add a note icon beside that highlighted text.
- Make the highlighted text interactive - i.e. when clicking on it, I will be able to open an overlay layer.
- Provided that we extracted the highlighted text, we would like to display that annotation to another user using our app. Using your kit, I would like to be able to programmatically highlight that text and be able to hook to an event when it is clicked on.
A:
PDFNet should be able to handle all the mentioned requirements.
In general, sharing annotation data between documents with PDFNet is best performed through the XFDF file format as described in the following article:
http://blog.pdftron.com/2013/07/19/document-collaboration-with-pdfnet/
This XFDF format works across all PDFNet platforms, as well as Acrobat. Additional sample code showing the basics of importing and exporting annotations with XFDF is available at:
http://www.pdftron.com/pdfnet/samplecode.html#FDF
Because PDFNet already provides a file format for moving annotations between documents, some of your other requirements may be unnecessary — e.g., you probably want to avoid extracting text into your own file format, if you can simply store the annotation inside the XFDF instead. That said, PDFNet does provide support for each of the individual requirements you list.
Specifically:
User can highlight text using his finger like he would in any regular text.
PDFNet mobile platforms support highlight annotations out-of-the-box. We provide source code to implement all annotation tools (including text highlighting) and you are free to modify the code as required. To highlight text in the demo viewer, first select the text, then tap on the selection. A pop-up menu will appear where you can select the “highlight” option.
Get the position of the highlighted text.
Given a user’s selection of a highlight annotation at a specific coordinate, you can get its bounding box with
PDFViewCtrl.getAnnotationAt().GetRect(). Also, during text selection, you can obtain the position of the selected
region with PDFViewCtrl.GetSelection():Extract the highlighted text to external resource (i.e. save the
extracted text in an external file).Probably the simplest option is to use XFDF (as described above), however you can serialize the information in an alternate representation. For example, you can obtain text under highlight using TextExtractor.GetTextUnderAnnot(annot):
You can also extract full text from the page (including positioning information) as shown in TextExtract sample at:
http://www.pdftron.com/pdfnet/samplecode.html#TextExtract
Add a note icon beside that highlighted text.
If you wish to use a custom icon, you will need to set the annotation’s appearance stream, which could in your case be an image. For an example of how to set an annotation’s appearance stream, please see:
https://groups.google.com/forum/#!searchin/pdfnet-sdk/SetAppearance
You can also associate a pop-up annotation with a highlight (or any other markup annotation) with markup_annot.SetPopup():
I would like to be able to programmatically highlight that text and be able to hook to an event when it is clicked on.
Because we provide source code for all Tools and GUI elements you are free to tweak code, hook-in custom events, and make other customizations.